Skip to content

Instantly share code, notes, and snippets.

@evanleck
Created September 3, 2013 00:50
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/6418548 to your computer and use it in GitHub Desktop.
Save evanleck/6418548 to your computer and use it in GitHub Desktop.
Array.prototype.some shim for non-compliant browsers. Converted from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some.
# make sure we have some
unless Array::some
Array::some = (fun) -> #, thisp
"use strict"
throw new TypeError() unless this?
thisp = undefined
i = undefined
t = Object(this)
len = t.length >>> 0
throw new TypeError() if typeof fun isnt "function"
thisp = arguments_[1]
i = 0
while i < len
return true if i of t and fun.call(thisp, t[i], i, t)
i++
false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment