View Lens.js
const Set = (lens, value, target) => lens.set(value, target)
const View = (lens, target) => lens.get(target)
const Over = (lens, func, target) =>
Set(lens, func(View(lens, target), target), target)
const Compose = (...lenses) => {
lenses = lenses.reverse()
const itar = (i, target, value) => {
if (i === lenses.length) return value
return lenses[i].set(itar(i + 1, lenses[i].get(target), value), target)
View colorsublime.js
const R = require('ramda')
const O = require('observable-air')
const axios = require('axios')
const { JSDOM } = require('jsdom')
const makeRequest = url =>
axios.get(url).then(response => response.data).then(html => new JSDOM(html))
const fetchDOM = url => O.multicast(O.fromPromise(() => makeRequest(url)))
const fromArray = R.compose(O.fromArray, Array.from)
const findE = R.curry((sel, dom) =>
View rebase-onto
#!/usr/bin/env bash
git fetch origin
commitID=`git log origin/master..HEAD --oneline --pretty=format:"%h" | tail -1`
git rebase --onto origin/master $commitID~1 -i --preserve-merges --autosquash
View index.js
const flatMapLatest = (fn, stream) =>
stream.publish(s => s.flatMap(v => fn(v).takeUntil(s)));
const flatMapLatest = (fn, stream, resultSelector) => stream.publish(s => {
return s.flatMap(v => fn(v).map(v2 => resultSelector(v, v2)).takeUntil(s));
});
const delay = (source, delay) => source.flatMap(e => Rx.Observable.timer(delay).mapTo(e))
const debounceTime = (time, stream) => flatMapLatest(v => of(v).delay(time), stream);
View patch.js
const typeOf = ob => ob.toString()
const forEach = (fn, l) => typeOf(l) === '[object Object]'
? forEach(k => fn(l[k], k), Object.keys(l))
: Array.from(l).forEach(fn)
const patch = (elm, node) => {
if(elm === node) return elm
if(typeOf(elm) === '[object Text]') {
elm.textContent = node.textContent
View ActionLogger.ts
export function logger (action: any, state0: any, state1: any, effect: any) {
if (!getGlobalConfig().dispatcherLogs) return
let actionName: string[] = []
while (action instanceof Action) {
actionName.push(action.type)
action = action.value
}
console.groupCollapsed(actionName.join('/'))
console.log('ACTION', action)