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 default function debouncePromise(fn, delay) { | |
let time = null; | |
return (...args) => { | |
if (time) { | |
clearTimeout(time); | |
} | |
return new Promise((res, rej) => { | |
time = setTimeout(() => { | |
fn.apply(null, args) | |
.then((...resArgs) => res.apply(null, resArgs)) |
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 { get, set, isEqual } from 'lodash'; | |
import deepClone from 'clone-deep'; | |
const defaultOpts = { | |
parseValue: (v: any) => v, | |
parseState: (v: any) => v, | |
valueFn: 'value', | |
onChangeFn: 'onChange' | |
}; |
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
const plus = (a, b) => a + b; | |
const minus = (a, b) => a - b; | |
const multiply = (a, b) => a * b; | |
const divide = (a, b) => a / b; | |
const Calc = (a) => ({ | |
plus: (...b) => Calc(b.reduce(plus, a)), | |
minus: (...b) => Calc(b.reduce(minus, a)), | |
multiply: (...b) => Calc(b.reduce(multiply, a)), | |
divide: (...b) => Calc(b.reduce(divide, a)), |
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 seeder from './seeder'; | |
seeder({ model: 'User' }) | |
.clear() | |
.seed() | |
.fail() | |
.clear() | |
.catch((err:Error) => { | |
console.log( err.stack ) | |
console.error('chain catch'); |
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
module helpers { | |
'use strict'; | |
export class DiffHelper { | |
public diff(a, b, seed = {}) { | |
const keys = this.arrayUnique(Object.keys(a).concat(Object.keys(b))); |