diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 44cf8d387..71bfb043a 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -342,6 +342,9 @@ result = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 = result = _.reject(foodsCombined, 'organic'); result = _.reject(foodsCombined, { 'type': 'fruit' }); +result = _.sample([1, 2, 3, 4]); +result = _.sample([1, 2, 3, 4], 2); + 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 a6b3d6fff..ea6ec7a3a 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1521,6 +1521,20 @@ declare module _ { collection: Collection, whereValue: Dictionary): T[]; + /** + * Retrieves a random element or n random elements from a collection. + * @param collection The collection to sample. + * @return Returns the random sample(s) of collection. + **/ + export function sample(collection: Collection): T; + + /** + * @see _.sample + * @param n The number of elements to sample. + **/ + export function sample(collection: Collection, n: number): T[]; + + /** * Checks if the callback returns a truey value for any element of a collection. The function * returns as soon as it finds a passing value and does not iterate over the entire collection. @@ -1649,18 +1663,6 @@ declare module _ { **/ export function shuffle(list: Collection): T[]; - /** - * Produce a random sample from the `list`. Pass a number to return `n` random elements from the list. Otherwise a single random item will be returned. - * @param list List to sample. - * @return Random sample of `n` elements in `list`. - **/ - export function sample(list: Collection, n: number): T[]; - - /** - * @see _.sample - **/ - export function sample(list: Collection): T; - /** * Converts the list (anything that can be iterated over), into a real Array. Useful for transmuting * the arguments object.