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
| export const takeChain (timeout, types, task, ...args) => fork(function * () { | |
| while (true) { | |
| const BREAK_TYPE = `BREAK_${performance.now()}`; | |
| const collectedActions = [yield take(types)]; | |
| yield fork(putDelayed, timeout, BREAK_TYPE); | |
| while (true) { | |
| const { action, canceled } = yield race({ | |
| action: take(types), |
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
| import { default as parse } from 'date-fns/parse'; | |
| import { default as isValid } from 'date-fns/isValid'; | |
| // like parse but second argument must array of strings | |
| // returns date | |
| export const parseMultiple = ( | |
| dateString, | |
| formatString, | |
| referenceDate, | |
| options |
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
| export const $ = selectors => document.querySelector(selectors); | |
| export const $$ = selectors => document.querySelectorAll(selectors); | |
| // on(div, 'click touch', () => {}); | |
| export const on = (target, eventNames, handler, options) => { | |
| const eventNamesList = eventNames.split(' '); | |
| eventNamesList.forEach(eventName => { | |
| target.addEventListener(eventName, handler, options); |
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
| import { toRadians, toDegrees } from './math.js'; | |
| export const Vec2 = { | |
| of (x, y) { | |
| return { x, y }; | |
| }, | |
| length (v) { | |
| return Math.sqrt(v.x ** 2 + v.y ** 2); | |
| }, |
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
| import isEqual from 'lodash/isEqual'; | |
| import { useState, useEffect, useRef, useMemo as defaultUseMemo } from 'react'; | |
| export const useOnMount = callback => { | |
| useEffect(callback, []); | |
| }; | |
| export const useForceUpdate = () => { | |
| const [, setState] = useState(null); | |
| return () => setState(Math.random()); |
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
| export const ajax = (url, { | |
| method = 'GET', | |
| contentType = 'application/x-www-form-urlencoded; charset=UTF-8'; | |
| data, | |
| onDone, | |
| } = {}) => { | |
| const xhr = new XMLHttpRequest(); | |
| if (typeof onDone === 'function') { | |
| const handler = () => onDone(xhr); |
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
| import fs from 'fs'; | |
| import path from 'path'; | |
| export function readdirRecuriveSync(dir, filelist) { | |
| filelist = filelist || []; | |
| var files = fs.readdirSync(dir); | |
| files.forEach(function (file) { | |
| file = path.join(dir, file); |
NewerOlder