Skip to content

Instantly share code, notes, and snippets.

@evanleck
Created September 3, 2013 00:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evanleck/6418552 to your computer and use it in GitHub Desktop.
Save evanleck/6418552 to your computer and use it in GitHub Desktop.
A custom include function to shortcut around the rather robust verbiage required for the "some" method.
# include
# depends on some, a shim for which can be found at https://gist.github.com/l3ck/6418548
if "function" isnt typeof Array::include
Array::include = (sought_value) ->
"use strict"
# throw on null
throw new TypeError("Array.prototype.include called on null or undefined") if null is this or "undefined" is typeof this
@some (element, index, array) ->
element is sought_value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment