- Tests has been added to cover my changes.
- All new and existing tests passed (
npm run test
).
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 obj = { | |
'a': (a: string, b: number): string => `${a}: ${b}`, | |
'b': (b: number): string => `${b}`, | |
'c': (): number => 42, | |
} | |
const getFn = <K extends keyof typeof obj>(key: K, ...params: Parameters<typeof obj[K]>) => { | |
return (obj[key] as (...args: Parameters<typeof obj[K]>) => ReturnType<typeof obj[K]>)(...params) | |
} |
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 obj = { | |
'a': (a: string, b: number): string => `${a}: ${b}`, | |
'b': (b: number): string => `${b}`, | |
'c': (): string => 'c', | |
} | |
const getFn = <K extends keyof typeof obj>(key: K) => { | |
return obj[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
export type User = { | |
name: string, | |
shortName: string, | |
fullName: string, | |
role: string, | |
lineNames: ReadonlyArray<string> | |
} |
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 * as React from 'react' | |
import { Middleware } from 'redux' | |
// https://github.com/shiningjason/react-enhanced-reducer-hook | |
function compose(...fns: any): any { | |
if (fns.length === 0) { | |
return (arg: any) => arg | |
} | |
if (fns.length === 1) { |
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
function get<T, | |
K0 extends keyof T, | |
K1 extends keyof T[K0], | |
K2 extends keyof T[K0][K1], | |
K3 extends keyof T[K0][K1][K2], | |
K4 extends keyof T[K0][K1][K2][K3], | |
K5 extends keyof T[K0][K1][K2][K3][K4]> | |
(obj: T, k0: K0, k1?: K1, k2?: K2, k3?: K3, k4?: K4, k5?: K5) { | |
return Array.from(arguments).slice(1).reduce((prefix, val) => (prefix && prefix[val]) ? prefix[val] : null, obj) | |
} |
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
test |
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
compare -dissimilarity-threshold 1 -fuzz '10%' -metric RMSE 2.png 3.png lol.png |
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
{ | |
"name": "lorem-ipsum", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"build": "npm run js:watch & npm run less:watch & npm run jade:watch", | |
"jade:watch": "jade -w ./src/*.jade -o ./dist", | |
"less:watch": "pleeease-watch", | |
"js:watch": "babel ./src/index.js --watch --out-file ./dist/main.js", |
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
function t(s, d) { | |
for (var p in d) | |
s = s.replace(new RegExp('{' + p + '}', 'g'), d[p]); | |
return s; | |
} |
NewerOlder