This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const streamMaker = (f) => { | |
const aux = x => [f(x), () => aux(x + 1)] | |
return () => aux(0) | |
} | |
const ones2 = streamMaker(x => x + 100) | |
const numberUntil = (s, predict) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _ = { '@@functional/placeholder': true } | |
const isPlaceholder = (a = {}) => typeof a === 'object' | |
&& a['@@functional/placeholder'] === true | |
const fill = (cache = [], rest = []) => { | |
const emptyIndexs = cache.reduce((acc, x, index) => { | |
if (isPlaceholder(x)) { | |
acc.push(index) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// an enhanced version of ramda path | |
const isNil = x => x == undefined // eslint-disable-line | |
const path = (paths = [], obj) => paths.reduce((acc, current) => { | |
if (isNil(acc)) { | |
return acc | |
} | |
if (Array.isArray(acc) && (typeof current === 'object')) { | |
return acc.map(item => Object.keys(current).reduce((filtered, key) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cond = (pairs = []) => (data) => { | |
for (let i = 0; i < pairs.length; i++) { | |
const [f, res] = pairs[i] | |
const isTrue = typeof f === 'function' ? f(data) : f | |
if (isTrue) { | |
return res | |
} | |
} | |
return undefined | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const deconstructObserver = (...stores)=> Component => { | |
const merge = (acc, store) => { | |
return R.merge(acc, toJS(store)) | |
} | |
const ObserbverComponent = observer(() => { | |
const store = R.reduce(merge, {})(stores) | |
return <Component {...store} ></Component> | |
}) | |
return ObserbverComponent |