From e7858021ac6b291cbeea99275866a0b888bc645d Mon Sep 17 00:00:00 2001 From: Brian Zengel Date: Fri, 18 Oct 2013 20:54:33 -0400 Subject: [PATCH] _.shuffle definitions --- lodash/lodash-tests.ts | 2 ++ lodash/lodash.d.ts | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 71bfb043a..494337270 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -345,6 +345,8 @@ result = _.reject(foodsCombined, { 'type': 'fruit' }); result = _.sample([1, 2, 3, 4]); result = _.sample([1, 2, 3, 4], 2); +result = _.shuffle([1, 2, 3, 4, 5, 6]); + result = _.some([null, 0, 'yes', false], Boolean); result = _.some(foodsCombined, 'organic'); result = _.some(foodsCombined, { 'type': 'meat' }); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index ea6ec7a3a..95b3186eb 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1534,6 +1534,13 @@ declare module _ { **/ export function sample(collection: Collection, n: number): T[]; + /** + * Creates an array of shuffled values, using a version of the Fisher-Yates shuffle. + * See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. + * @param collection The collection to shuffle. + * @return Returns a new shuffled collection. + **/ + export function shuffle(list: Collection): T[]; /** * Checks if the callback returns a truey value for any element of a collection. The function @@ -1656,12 +1663,7 @@ declare module _ { iterator: string, context?: any): T[]; - /** - * Returns a shuffled copy of the list, using a version of the Fisher-Yates shuffle. - * @param list List to shuffle. - * @return Shuffled copy of `list`. - **/ - export function shuffle(list: Collection): T[]; + /** * Converts the list (anything that can be iterated over), into a real Array. Useful for transmuting