Skip to content

Instantly share code, notes, and snippets.

@cj
Created December 30, 2010 00:07
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 cj/759250 to your computer and use it in GitHub Desktop.
Save cj/759250 to your computer and use it in GitHub Desktop.
_.mixin
array_shift: (inputArr) ->
props = false
shift = undefined
pr = ''
allDigits = /^\d$/
int_ct = -1
_checkToUpIndices = (arr, ct, key) ->
#Deal with situation, e.g., if encounter index 4 and try to set it to 0, but 0 exists later in loop (need to
#increment all subsequent (skipping current key, since we need its value below) until find unused)
if arr[ct] isnt undefined
tmp= ct
ct += 1
if ct is key then ct += 1
ct= _checkToUpIndices(arr, ct, key)
arr[ct]= arr[tmp]
delete arr[tmp]
return ct
if inputArr.length is 0 then null
if inputArr.length > 0 then _.array_shift(inputArr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment