Merge pull request #8 from pyoor/master
Add Random.pop() and placeholder for unit tests
This commit is contained in:
commit
30a9c59613
2 changed files with 10 additions and 0 deletions
|
@ -141,5 +141,14 @@ var random = {
|
|||
result.push(this.pick(list));
|
||||
}
|
||||
return result;
|
||||
},
|
||||
pop: function (arr) {
|
||||
// Removes and returns a random item from an array
|
||||
var i, obj;
|
||||
|
||||
obj = Random.item(arr);
|
||||
arr.splice(arr.indexOf(obj), 1);
|
||||
|
||||
return obj;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -117,4 +117,5 @@ shuffle(arr)
|
|||
shuffled(arr)
|
||||
subset(list, limit)
|
||||
choose(list, flat=true)
|
||||
pop(arr)
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue