Created
December 30, 2010 00:07
-
-
Save cj/759250 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_.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