Skip to content

Instantly share code, notes, and snippets.

@crioux
Created May 15, 2017 04:43
Show Gist options
  • Save crioux/e72f7087a2257f3bfdf0cc8a7cb2461e to your computer and use it in GitHub Desktop.
Save crioux/e72f7087a2257f3bfdf0cc8a7cb2461e to your computer and use it in GitHub Desktop.
Javascript method names abbreviator
//shrink=n=>n[0]+n.split('').map(c=>(c<='Z')?c:'').join('')
//keys = (_=o=>o?Object.keys(o).concat(_(o.__proto__)):[])
//abbrev=function(x) { keys(x).forEach(k=>(x[shrink(k)]=x[k])) }
//shrink=n=>n[0]+n.split('').map(c=>(c<='Z')?c:'').join('')
//abbrev=function(x) { (_=o=>o?Object.keys(o).concat(_(o.__proto__)):[])(x).forEach(k=>(x[shrink(k)]=x[k])) }
abbrev=function(x) { (_=o=>o&&(Object.keys(o).forEach(k=>(x[(n=>n[0]+n.split('').map(c=>(c<='Z')?c:'').join(''))(k)]=x[k])),_(o.__proto__)))(x) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment