Merge pull request #8 from pyoor/master

Add Random.pop() and placeholder for unit tests
This commit is contained in:
Christoph Diehl 2017-04-12 17:18:04 +02:00 committed by GitHub
commit 30a9c59613
2 changed files with 10 additions and 0 deletions

View File

@ -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;
}
};

View File

@ -117,4 +117,5 @@ shuffle(arr)
shuffled(arr)
subset(list, limit)
choose(list, flat=true)
pop(arr)
*/