Skip to content

Instantly share code, notes, and snippets.

@wildeyes
Created December 14, 2015 08:30
Show Gist options
  • Save wildeyes/5877dec004effcc81e3f to your computer and use it in GitHub Desktop.
Save wildeyes/5877dec004effcc81e3f to your computer and use it in GitHub Desktop.
My favourite, essential " polyfills " for projects with coffeescripts.
# xxx turn this into a bower/npm module
Object.defineProperty Array.prototype, "last", { get: -> this[this.length - 1]}
Object.defineProperty Array.prototype, "first", { get: -> this[0]}
Function::property = (prop, desc) ->
Object.defineProperty @prototype, prop, desc
Function::getter = (prop, get) ->
Object.defineProperty @prototype, prop, {get, configurable: yes}
Function::setter = (prop, set) ->
Object.defineProperty @prototype, prop, {set, configurable: yes}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment