Skip to content

Instantly share code, notes, and snippets.

function compile (pattern, mapping) {
pattern = pattern || '';
var i,
ch,
last,
attrName,
sequenceLength = 0,
len = pattern.length,
@ewebdev
ewebdev / overload.js
Created April 15, 2018 12:17
Overloading Javascript Functions
const overload = (() => {
const noop = () => {};
const typeOf = (p) => (Object.prototype.toString.call(p).slice(8,-1));
return (fns) => (function (...args) {
const key = args.map(typeOf).join('_');
return (fns[key] || noop).apply(this, args);
});
})();