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 auto = rules => | |
(strs, ...vars) => strs.map((str, i) => { | |
if (i >= vars.length) return str; | |
const v = vars[i]; | |
const r = rules[typeof v]; | |
return str + (r ? r(v) : v); | |
}).join(''); | |
// examples: | |
const t = auto({ boolean: v => v || '', object: JSON.stringify }); |
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
Object.prototype.pipe = function pipe(fn) { return fn(this.constructor(this)); } |
OlderNewer