Merge pull request #4640 from nfantone/lodash/sample-arraywrapper

Add sample() to LoDashArrayWrapper interface
This commit is contained in:
Masahiro Wakame
2015-06-27 13:26:32 +09:00
2 changed files with 15 additions and 1 deletions
+2
View File
@@ -605,6 +605,8 @@ result = <IFoodCombined[]>_(foodsCombined).reject({ 'type': 'fruit' }).value();
result = <number>_.sample([1, 2, 3, 4]);
result = <number[]>_.sample([1, 2, 3, 4], 2);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).sample();
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).sample(2);
result = <number[]>_.shuffle([1, 2, 3, 4, 5, 6]);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3]).shuffle();
+13 -1
View File
@@ -22,7 +22,7 @@ declare module _ {
* forEach, forEachRight, forIn, forInRight, forOwn, forOwnRight, functions, groupBy,
* indexBy, initial, intersection, invert, invoke, keys, map, max, memoize, merge, min,
* object, omit, once, pairs, partial, partialRight, pick, pluck, pull, push, range, reject,
* remove, rest, reverse, shuffle, slice, sort, sortBy, splice, tap, throttle, times,
* remove, rest, reverse, sample, shuffle, slice, sort, sortBy, splice, tap, throttle, times,
* toArray, transform, union, uniq, unshift, unzip, values, where, without, wrap, and zip
*
* The non-chainable wrapper functions are:
@@ -4559,6 +4559,18 @@ declare module _ {
sample<T>(collection: Dictionary<T>, n: number): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.sample
**/
sample(n: number): LoDashArrayWrapper<T>;
/**
* @see _.sample
**/
sample(): LoDashArrayWrapper<T>;
}
//_.shuffle
interface LoDashStatic {
/**