Skip to content

Instantly share code, notes, and snippets.

@gabejohnson
Created February 17, 2017 15:30

Revisions

  1. gabejohnson created this gist Feb 17, 2017.
    13 changes: 13 additions & 0 deletions method-aliases.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    const alias = prefix => T => {
    const getKeys = o => Object.keys(o)
    .filter(k => k.startsWith(prefix+'/'))
    .map(k => k.split('/')[1]);

    const scaryMutateObject = o => getKeys(o).forEach(k => o[k] = o[prefix+'/'+k]);

    scaryMutateObject(T);
    scaryMutateObject(T.prototype);
    // I'M RETURNING UNDEFINED!!!
    }

    const aliasFL = alias('fantasy-land');