Skip to content

Instantly share code, notes, and snippets.

View jczimm's full-sized avatar

Jacob Zimmerman jczimm

View GitHub Profile
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 });
@jczimm
jczimm / quick-pipe.js
Created February 10, 2021 01:00
Hack to implement piping without experimental pipeline operator (|>)
Object.prototype.pipe = function pipe(fn) { return fn(this.constructor(this)); }