Skip to content

Instantly share code, notes, and snippets.

@gabejohnson
Created February 17, 2017 15:30
Show Gist options
  • Save gabejohnson/49928e051cf43cf6bf97162edcf08f24 to your computer and use it in GitHub Desktop.
Save gabejohnson/49928e051cf43cf6bf97162edcf08f24 to your computer and use it in GitHub Desktop.
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');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment