Skip to content

Commit d8bfbf6

Browse files
committed
Merge pull request DefinitelyTyped#4640 from nfantone/lodash/sample-arraywrapper
Add sample() to LoDashArrayWrapper interface
2 parents 06efba4 + 7da2851 commit d8bfbf6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lodash/lodash-tests.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,8 @@ result = <IFoodCombined[]>_(foodsCombined).reject({ 'type': 'fruit' }).value();
605605

606606
result = <number>_.sample([1, 2, 3, 4]);
607607
result = <number[]>_.sample([1, 2, 3, 4], 2);
608+
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).sample();
609+
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).sample(2);
608610

609611
result = <number[]>_.shuffle([1, 2, 3, 4, 5, 6]);
610612
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3]).shuffle();

lodash/lodash.d.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ declare module _ {
2222
* forEach, forEachRight, forIn, forInRight, forOwn, forOwnRight, functions, groupBy,
2323
* indexBy, initial, intersection, invert, invoke, keys, map, max, memoize, merge, min,
2424
* object, omit, once, pairs, partial, partialRight, pick, pluck, pull, push, range, reject,
25-
* remove, rest, reverse, shuffle, slice, sort, sortBy, splice, tap, throttle, times,
25+
* remove, rest, reverse, sample, shuffle, slice, sort, sortBy, splice, tap, throttle, times,
2626
* toArray, transform, union, uniq, unshift, unzip, values, where, without, wrap, and zip
2727
*
2828
* The non-chainable wrapper functions are:
@@ -4559,6 +4559,18 @@ declare module _ {
45594559
sample<T>(collection: Dictionary<T>, n: number): T[];
45604560
}
45614561

4562+
interface LoDashArrayWrapper<T> {
4563+
/**
4564+
* @see _.sample
4565+
**/
4566+
sample(n: number): LoDashArrayWrapper<T>;
4567+
4568+
/**
4569+
* @see _.sample
4570+
**/
4571+
sample(): LoDashArrayWrapper<T>;
4572+
}
4573+
45624574
//_.shuffle
45634575
interface LoDashStatic {
45644576
/**

0 commit comments

Comments
 (0)