This file contains 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
// inspired by https://golang.org/pkg/context/ | |
function noop() { | |
} | |
function makeBarrier() { | |
let open; | |
const whenOpened = new Promise((resolve, reject) => { | |
open = resolve; | |
}); |
This file contains 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
export { | |
whenElementVisible | |
} | |
const threshold = [0, 0.25, 0.5, 0.75, 1]; | |
const rootMargin = '40px'; | |
const observer = new window.IntersectionObserver(observerCallback, { threshold, rootMargin }); | |
const callbacks = window.callbacks = new WeakMap(); |
This file contains 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
import { EventEmitter } from "./event" | |
const print = console.log.bind(console) | |
const _indexedDB = (window.indexedDB | |
|| window["mozIndexedDB"] | |
|| window["webkitIndexedDB"] | |
|| window["msIndexedDB"]) as IDBFactory | |
This file contains 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
function generateAllCombinations(listsOfArgs) { | |
return listsOfArgs.reduce((acc, list) => mix(acc, list), []); | |
} | |
function mix(listA, listB) { | |
if (listA.length === 0) return listB; | |
if (listB.length === 0) return listA; | |
const result = []; |