A framework that lets you write your entire UI
- as functions
- with React hooks
- without React
- without classes
- without vDOM/DOM diffing
- without web components
- without build step
A framework that lets you write your entire UI
// Law of Absurd Reduces: Everything that can be implemented with reduce() will eventually be implemented with reduce() | |
/** | |
* @param {Object} chainableFunctions object where each key is the name of a function and it's value is the function itself | |
*/ | |
const createChainables = (chainableFunctions) => ({ | |
chain(initialValue) { | |
const operations = []; | |
const evaluate = () => operations.reduce( | |
(value, [func, ...args]) => func(value, ...args), |
function chain(value) { | |
return { | |
/** | |
* @param {function|string} func function or function name (in chained value) | |
* @param {...any} args | |
*/ | |
fn(func, ...args) { | |
if (typeof func === 'string') { | |
return chain(value[func](...args)); | |
} |
const postAndCancelPrevCall = (() => { | |
let cancelTokenInstance; | |
return async (body) => { | |
try { | |
if (cancelTokenInstance) { | |
cancelTokenInstance.cancel('cancelled by user'); | |
} | |
cancelTokenInstance = CancelToken.source(); | |
const axiosResponse = await axios.post(body, { | |
cancelToken: cancelTokenInstance.token |
const { isPlainObject } = require('lodash'); | |
function objectRecursionAndTransformationTemplate(obj) { | |
if (!obj || !(isPlainObject(obj) || Array.isArray(obj))) { | |
// put your primitive val transformations here | |
return obj; | |
} | |
if (Array.isArray(obj)) { | |
// put your array transformations here | |
return obj.map(objectRecursionAndTransformationTemplate); |
# exclude node_modules folder and files like .DS_STORE on OSX | |
rsync -rv --exclude 'node_modules' --exclude '.*' --delete-after --ignore-errors . [email protected]:AppDirectory/ | |
# execute yarn install | |
ssh [email protected] 'cd AppDirectory && yarn install' |
const redis = require('redis'); | |
const bluebird = require('bluebird'); | |
const redisClient = redis.createClient({}); | |
bluebird.promisifyAll(Object.getPrototypeOf(redisClient)); | |
const luaScript = ` | |
local newPayload = ARGV[1] | |
local newVersionStr, newData = ARGV[1]:match("^([0-9]+)|(.+)$") | |
local prevVal = redis.call("get", KEYS[1]) or nil |
const d3 = require('d3'); | |
const d3hsluv = require('d3-hsluv'); | |
const { generateContrastColors } = require('./leonardo'); | |
Object.assign(d3, d3hsluv); | |
function interpolateLumArray(newColors) { | |
const lums = []; | |
for (let i = 0; i < newColors.length; i += 1) { |
// Deprecated: Dont use this. Just use fnv1a hash | |
function randomlyDistributedHash(s) { | |
// fnv1a hash | |
var h = 0x811c9dc5; | |
for (var i = 0, l = s.length; i < l; i++) { | |
h ^= s.charCodeAt(i); | |
h += (h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24); | |
} | |
h = (h >>> 0); | |