moderndash 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -75
- package/dist/index.cjs +66 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +125 -113
- package/dist/index.js +62 -69
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/src/array/chunk.ts +0 -31
- package/src/array/difference.ts +0 -21
- package/src/array/differenceBy.ts +0 -30
- package/src/array/differenceWith.ts +0 -31
- package/src/array/dropRightWhile.ts +0 -28
- package/src/array/dropWhile.ts +0 -24
- package/src/array/index.ts +0 -21
- package/src/array/intersection.ts +0 -20
- package/src/array/intersectionBy.ts +0 -26
- package/src/array/intersectionWith.ts +0 -33
- package/src/array/sample.ts +0 -18
- package/src/array/sampleSize.ts +0 -31
- package/src/array/shuffle.ts +0 -33
- package/src/array/takeRightWhile.ts +0 -33
- package/src/array/takeWhile.ts +0 -33
- package/src/array/uniq.ts +0 -18
- package/src/array/uniqBy.ts +0 -25
- package/src/array/uniqWith.ts +0 -20
- package/src/array/unzip.ts +0 -20
- package/src/array/unzipWith.ts +0 -26
- package/src/array/zip.ts +0 -17
- package/src/array/zipWith.ts +0 -28
- package/src/collection/countBy.ts +0 -38
- package/src/collection/groupBy.ts +0 -32
- package/src/collection/index.ts +0 -3
- package/src/collection/sortBy.ts +0 -15
- package/src/function/after.ts +0 -29
- package/src/function/before.ts +0 -31
- package/src/function/debounce.ts +0 -125
- package/src/function/index.ts +0 -7
- package/src/function/memoize.ts +0 -63
- package/src/function/once.ts +0 -22
- package/src/function/throttle.ts +0 -13
- package/src/function/times.ts +0 -24
- package/src/helpers/collections.ts +0 -5
- package/src/helpers/shortHands.ts +0 -17
- package/src/helpers/stringModifiers.ts +0 -18
- package/src/helpers/typeofChecks.ts +0 -3
- package/src/index.ts +0 -7
- package/src/lang/index.ts +0 -4
- package/src/lang/isEmpty.ts +0 -51
- package/src/lang/isEqual.ts +0 -80
- package/src/lang/isEqualWith.ts +0 -34
- package/src/lang/isPlainObject.ts +0 -3
- package/src/object/index.ts +0 -1
- package/src/object/pick.ts +0 -21
- package/src/string/camelCase.ts +0 -30
- package/src/string/capitalize.ts +0 -14
- package/src/string/deburr.ts +0 -20
- package/src/string/escape.ts +0 -21
- package/src/string/escapeRegExp.ts +0 -15
- package/src/string/index.ts +0 -11
- package/src/string/kebabCase.ts +0 -25
- package/src/string/pascalCase.ts +0 -26
- package/src/string/snakeCase.ts +0 -30
- package/src/string/startCase.ts +0 -25
- package/src/string/stripSpecialChars.ts +0 -17
- package/src/string/unescape.ts +0 -22
- package/src/types.ts +0 -15
package/dist/index.d.ts
CHANGED
|
@@ -18,13 +18,33 @@ type MinimumTwoArrays<TInput> = [TInput[], TInput[], ...TInput[][]];
|
|
|
18
18
|
type IterateeFunction<T> = (value: T) => unknown;
|
|
19
19
|
type PropertyShorthand<T> = keyof T;
|
|
20
20
|
type RecordKey = string | number | symbol;
|
|
21
|
-
type ArrayOrRecord<TInput> = TInput[] | Record<RecordKey, TInput>;
|
|
22
21
|
type NoUnion<T, U = T> = T extends U ? [U] extends [T] ? T : never : never;
|
|
23
22
|
/**
|
|
24
23
|
* @description Generic function type, should fit any function
|
|
25
24
|
* @typeParam TFunc - The input function type
|
|
26
25
|
*/
|
|
27
|
-
type GenericFunction<TFunc extends (...args:
|
|
26
|
+
type GenericFunction<TFunc extends (...args: any) => any> = (...args: Parameters<TFunc>) => ReturnType<TFunc>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Creates an object composed of keys generated from the results of running
|
|
30
|
+
* each element of `collection` thru `iteratee`. The corresponding value of
|
|
31
|
+
* each key is the number of times the key was returned by `iteratee`.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const users = [
|
|
35
|
+
* { 'user': 'barney', 'active': true },
|
|
36
|
+
* { 'user': 'betty', 'active': true },
|
|
37
|
+
* { 'user': 'fred', 'active': false }
|
|
38
|
+
* ]
|
|
39
|
+
*
|
|
40
|
+
* count(users, value => value.active);
|
|
41
|
+
* // => { 'true': 2, 'false': 1 }
|
|
42
|
+
* @category Array
|
|
43
|
+
* @param iteratee - The iteratee to transform keys.
|
|
44
|
+
* @param collection - The array or record to iterate over.
|
|
45
|
+
* @returns Returns the composed aggregate object.
|
|
46
|
+
*/
|
|
47
|
+
declare function count<TInput, TKey extends RecordKey>(array: TInput[], iteratee: (value: TInput) => TKey): Record<TKey, number>;
|
|
28
48
|
|
|
29
49
|
/**
|
|
30
50
|
* Creates an array of `array` values not included in the other given arrays. The order and references of result values are determined by the first array.
|
|
@@ -63,19 +83,17 @@ declare function differenceBy<T>(iteratee: IterateeFunction<T> | PropertyShortha
|
|
|
63
83
|
|
|
64
84
|
/**
|
|
65
85
|
* This method is like `difference` except that it accepts `comparator`
|
|
66
|
-
* which is invoked to compare elements of `array` to `values`.
|
|
67
|
-
* references of result values are determined by the first array.
|
|
68
|
-
* is invoked with two arguments: (arrVal, othVal).
|
|
69
|
-
*
|
|
70
|
-
* **Note:** Unlike `pullAllWith`, this method returns a new array.
|
|
86
|
+
* which is invoked to compare elements of `array` to `values`.
|
|
87
|
+
* The order and references of result values are determined by the first array.
|
|
88
|
+
* The comparator is invoked with two arguments: (arrVal, othVal).
|
|
71
89
|
*
|
|
90
|
+
* @example
|
|
91
|
+
* differenceWith(isEqual, [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }], [{ 'x': 1, 'y': 2 }])
|
|
92
|
+
* // => [{ 'x': 2, 'y': 1 }]
|
|
72
93
|
* @category Array
|
|
73
94
|
* @param comparator - The comparator invoked per element.
|
|
74
95
|
* @param arrays - First array to inspect. Others are excluded.
|
|
75
96
|
* @returns Returns the new array of filtered values.
|
|
76
|
-
* @example
|
|
77
|
-
* differenceWith(isEqual, [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }], [{ 'x': 1, 'y': 2 }])
|
|
78
|
-
* // => [{ 'x': 2, 'y': 1 }]
|
|
79
97
|
*/
|
|
80
98
|
declare function differenceWith<T>(comparator: (a: T, b: T) => boolean, ...arrays: MinimumTwoArrays<T>): T[];
|
|
81
99
|
|
|
@@ -98,7 +116,7 @@ declare function differenceWith<T>(comparator: (a: T, b: T) => boolean, ...array
|
|
|
98
116
|
* dropRightWhile(({ active }) => active, users)
|
|
99
117
|
* // => objects for ['barney']
|
|
100
118
|
*/
|
|
101
|
-
declare function dropRightWhile<T>(predicate: (value: T) => boolean
|
|
119
|
+
declare function dropRightWhile<T>(array: T[], predicate: (value: T) => boolean): T[];
|
|
102
120
|
|
|
103
121
|
/**
|
|
104
122
|
* Creates a slice of `array` excluding elements dropped from the beginning.
|
|
@@ -119,7 +137,27 @@ declare function dropRightWhile<T>(predicate: (value: T) => boolean, array: T[])
|
|
|
119
137
|
* dropWhile(({ active }) => active, users)
|
|
120
138
|
* // => objects for ['pebbles']
|
|
121
139
|
*/
|
|
122
|
-
declare function dropWhile<T>(predicate: (value: T) => boolean
|
|
140
|
+
declare function dropWhile<T>(array: T[], predicate: (value: T) => boolean): T[];
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Creates an object composed of keys generated from the results of running
|
|
144
|
+
* each element of `collection` thru `iteratee`. The order of grouped values
|
|
145
|
+
* is determined by the order they occur in `collection`. The corresponding
|
|
146
|
+
* value of each key is an array of elements responsible for generating the
|
|
147
|
+
* key.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* group([6.1, 4.2, 6.3], Math.floor)
|
|
151
|
+
* // => { '4': [4.2], '6': [6.1, 6.3] }
|
|
152
|
+
*
|
|
153
|
+
* group([6.1, 4.2, 6.3], value => value > 5)
|
|
154
|
+
* // => { 'false': [4.2], 'true': [6.1, 6.3] }
|
|
155
|
+
* @category Array
|
|
156
|
+
* @param collection - The array or object to iterate over.
|
|
157
|
+
* @param iteratee - The iteratee to transform keys.
|
|
158
|
+
* @returns Returns the composed aggregate object.
|
|
159
|
+
*/
|
|
160
|
+
declare function group<T, U extends RecordKey>(array: T[], iteratee: (value: T) => U): Record<U, T[]>;
|
|
123
161
|
|
|
124
162
|
/**
|
|
125
163
|
* Creates an array of unique values that are included in all given arrays.
|
|
@@ -173,14 +211,14 @@ declare function intersectionWith<T>(comparator: (a: T, b: T) => boolean, ...arr
|
|
|
173
211
|
/**
|
|
174
212
|
* Gets a random element from `array`.
|
|
175
213
|
*
|
|
176
|
-
* @category Array
|
|
177
|
-
* @param array - The array to sample.
|
|
178
|
-
* @returns Returns the random element.
|
|
179
214
|
* @example
|
|
180
215
|
* sample([1, 2, 3, 4])
|
|
181
216
|
* // => 2
|
|
217
|
+
* @category Array
|
|
218
|
+
* @param array - The array to sample.
|
|
219
|
+
* @returns Returns the random element.
|
|
182
220
|
*/
|
|
183
|
-
declare function sample<
|
|
221
|
+
declare function sample<TInput>(array: TInput[]): TInput | undefined;
|
|
184
222
|
|
|
185
223
|
/**
|
|
186
224
|
* Gets `n` random elements at unique keys from `array` up to the
|
|
@@ -197,22 +235,39 @@ declare function sample<T>(array: T[]): T | undefined;
|
|
|
197
235
|
* sampleSize([1, 2, 3], 4)
|
|
198
236
|
* // => [2, 3, 1]
|
|
199
237
|
*/
|
|
200
|
-
declare function sampleSize<TInput>(
|
|
238
|
+
declare function sampleSize<TInput>(array: TInput[], size: number): TInput[];
|
|
201
239
|
|
|
202
240
|
/**
|
|
203
241
|
* Creates an array of shuffled values, using a version of the
|
|
204
242
|
* [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
|
|
205
243
|
*
|
|
206
|
-
* @since 0.1.0
|
|
207
|
-
* @category Array
|
|
208
|
-
* @param array - The array or object to shuffle.
|
|
209
|
-
* @returns Returns the new shuffled array.
|
|
210
244
|
* @example
|
|
211
245
|
* shuffle([1, 2, 3, 4])
|
|
212
246
|
* // => [4, 1, 3, 2]
|
|
247
|
+
* @category Array
|
|
248
|
+
* @param array - The array or object to shuffle.
|
|
249
|
+
* @returns Returns the new shuffled array.
|
|
213
250
|
*/
|
|
214
251
|
declare function shuffle<TInput>(array: TInput[]): TInput[];
|
|
215
252
|
|
|
253
|
+
/**
|
|
254
|
+
* Sorts the array in ascending or descending order.
|
|
255
|
+
* An iteratee function is optional to sort the array based on a specific property.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* sort([1, 2, 3, 4], 'desc')
|
|
259
|
+
* // => [4, 3, 2, 1]
|
|
260
|
+
*
|
|
261
|
+
* sort([{ a: 1 }, { a: 2 }, { a: 3 }], 'asc', item => item.a)
|
|
262
|
+
* // => [{ a: 1 }, { a: 2 }, { a: 3 }]
|
|
263
|
+
* @category Array
|
|
264
|
+
* @param array - The array to sort.
|
|
265
|
+
* @param order - The order in which to sort the array.
|
|
266
|
+
* @param iteratee - The iteratee function to sort the array based on a specific property.
|
|
267
|
+
* @returns Returns the sorted array.
|
|
268
|
+
*/
|
|
269
|
+
declare function sort<TInput>(array: TInput[], order?: 'asc' | 'desc', iteratee?: (item: TInput) => number | bigint | Date | string): TInput[];
|
|
270
|
+
|
|
216
271
|
/**
|
|
217
272
|
* Creates a slice of `array` with elements taken from the end. Elements are
|
|
218
273
|
* taken until `predicate` returns falsey. The predicate is invoked with
|
|
@@ -253,7 +308,7 @@ declare function takeRightWhile<T>(predicate: (elem: T) => boolean, array: T[]):
|
|
|
253
308
|
* takeWhile(({ active }) => active, users)
|
|
254
309
|
* // => objects for ['barney', 'fred']
|
|
255
310
|
*/
|
|
256
|
-
declare function takeWhile<T>(predicate: (elem: T) => boolean
|
|
311
|
+
declare function takeWhile<T>(array: T[], predicate: (elem: T) => boolean): T[];
|
|
257
312
|
|
|
258
313
|
/**
|
|
259
314
|
* Creates a duplicate-free version of an array, in which only the first occurrence of each element is kept.
|
|
@@ -282,7 +337,7 @@ declare function uniq<TInput>(array: TInput[]): TInput[];
|
|
|
282
337
|
* uniqBy(Math.floor, [2.1, 1.2, 2.3])
|
|
283
338
|
* // => [2.1, 1.2]
|
|
284
339
|
*/
|
|
285
|
-
declare function uniqBy<T>(iteratee: IterateeFunction<T> | PropertyShorthand<T
|
|
340
|
+
declare function uniqBy<T>(array: T[], iteratee: IterateeFunction<T> | PropertyShorthand<T>): T[];
|
|
286
341
|
|
|
287
342
|
/**
|
|
288
343
|
* This method is like `uniq` except that it accepts `comparator` which is invoked to compare elements of `array`.
|
|
@@ -298,41 +353,39 @@ declare function uniqBy<T>(iteratee: IterateeFunction<T> | PropertyShorthand<T>,
|
|
|
298
353
|
* uniqWith(isEqual, objects)
|
|
299
354
|
* // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
|
|
300
355
|
*/
|
|
301
|
-
declare function uniqWith<TInput>(comparator: (a: TInput, b: TInput) => boolean
|
|
356
|
+
declare function uniqWith<TInput>(array: TInput[], comparator: (a: TInput, b: TInput) => boolean): TInput[];
|
|
302
357
|
|
|
303
358
|
/**
|
|
304
359
|
* This method is like `zip` except that it accepts an array of grouped
|
|
305
360
|
* elements and creates an array regrouping the elements to their pre-zip configuration.
|
|
306
361
|
*
|
|
307
|
-
* @category Array
|
|
308
|
-
* @param array - The array of grouped elements to process.
|
|
309
|
-
* @returns Returns the new array of regrouped elements.
|
|
310
362
|
* @example
|
|
311
363
|
* const zipped = zip(['a', 'b'], [1, 2], [true, false])
|
|
312
364
|
* // => [['a', 1, true], ['b', 2, false]]
|
|
313
365
|
*
|
|
314
366
|
* unzip(zipped)
|
|
315
367
|
* // => [['a', 'b'], [1, 2], [true, false]]
|
|
368
|
+
* @category Array
|
|
369
|
+
* @param array - The array of grouped elements to process.
|
|
370
|
+
* @returns Returns the new array of regrouped elements.
|
|
316
371
|
*/
|
|
317
372
|
declare function unzip<TInput extends unknown[]>(array: TInput[]): TInput[];
|
|
318
373
|
|
|
319
374
|
/**
|
|
320
|
-
* This method is like `unzip` except that it accepts `iteratee` to specify
|
|
321
|
-
* how regrouped values should be combined. The iteratee is invoked with the
|
|
322
|
-
* elements of each group: (...group).
|
|
375
|
+
* This method is like `unzip` except that it accepts `iteratee` to specify how regrouped values should be combined.
|
|
323
376
|
*
|
|
324
|
-
* @category Array
|
|
325
|
-
* @param iteratee - The function to combine regrouped values.
|
|
326
|
-
* @param array - The array of grouped elements to process.
|
|
327
|
-
* @returns Returns the new array of regrouped elements.
|
|
328
377
|
* @example
|
|
329
378
|
* const zipped = zip([1, 2], [10, 20], [100, 200])
|
|
330
379
|
* // => [[1, 10, 100], [2, 20, 200]]
|
|
331
380
|
*
|
|
332
381
|
* unzipWith(add, zipped)
|
|
333
382
|
* // => [3, 30, 300]
|
|
383
|
+
* @category Array
|
|
384
|
+
* @param iteratee - The function to combine regrouped values.
|
|
385
|
+
* @param array - The array of grouped elements to process.
|
|
386
|
+
* @returns Returns the new array of regrouped elements.
|
|
334
387
|
*/
|
|
335
|
-
declare function unzipWith<TInput extends unknown[], TOutput>(iteratee: (...t: TInput) => TOutput
|
|
388
|
+
declare function unzipWith<TInput extends unknown[], TOutput>(array: TInput[], iteratee: (...t: TInput) => TOutput): TOutput[];
|
|
336
389
|
|
|
337
390
|
/**
|
|
338
391
|
* Creates an array of grouped elements, the first of which contains the first elements of the given arrays,
|
|
@@ -365,62 +418,21 @@ type UnZip<A extends readonly unknown[]> = {
|
|
|
365
418
|
*/
|
|
366
419
|
declare function zipWith<Args extends unknown[], TOutput>(combineFunc: (...args: Args) => TOutput, ...arrays: UnZip<Args>): TOutput[];
|
|
367
420
|
|
|
368
|
-
/**
|
|
369
|
-
* Creates an object composed of keys generated from the results of running
|
|
370
|
-
* each element of `collection` thru `iteratee`. The corresponding value of
|
|
371
|
-
* each key is the number of times the key was returned by `iteratee`.
|
|
372
|
-
*
|
|
373
|
-
* @example
|
|
374
|
-
* const users = [
|
|
375
|
-
* { 'user': 'barney', 'active': true },
|
|
376
|
-
* { 'user': 'betty', 'active': true },
|
|
377
|
-
* { 'user': 'fred', 'active': false }
|
|
378
|
-
* ]
|
|
379
|
-
*
|
|
380
|
-
* countBy(users, value => value.active);
|
|
381
|
-
* // => { 'true': 2, 'false': 1 }
|
|
382
|
-
* @category Collection
|
|
383
|
-
* @param iteratee - The iteratee to transform keys.
|
|
384
|
-
* @param collection - The array or record to iterate over.
|
|
385
|
-
* @returns Returns the composed aggregate object.
|
|
386
|
-
*/
|
|
387
|
-
declare function countBy<TInput, TKey extends RecordKey>(collection: ArrayOrRecord<TInput>, iteratee: (value: TInput) => TKey): Record<TKey, number>;
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Creates an object composed of keys generated from the results of running
|
|
391
|
-
* each element of `collection` thru `iteratee`. The order of grouped values
|
|
392
|
-
* is determined by the order they occur in `collection`. The corresponding
|
|
393
|
-
* value of each key is an array of elements responsible for generating the
|
|
394
|
-
* key.
|
|
395
|
-
*
|
|
396
|
-
* @example
|
|
397
|
-
* groupBy([6.1, 4.2, 6.3], Math.floor)
|
|
398
|
-
* // => { '4': [4.2], '6': [6.1, 6.3] }
|
|
399
|
-
* @category Collection
|
|
400
|
-
* @param collection - The array or object to iterate over.
|
|
401
|
-
* @param iteratee - The iteratee to transform keys.
|
|
402
|
-
* @returns Returns the composed aggregate object.
|
|
403
|
-
*/
|
|
404
|
-
declare function groupBy<T, U extends RecordKey>(collection: ArrayOrRecord<T>, iteratee: (value: T) => U): Record<U, T[]>;
|
|
405
|
-
|
|
406
|
-
declare function sortBy<T, U>(iteratee: (item: T) => NoUnion<number | bigint | Date | string, U>, array: T[]): T[];
|
|
407
|
-
|
|
408
421
|
/**
|
|
409
422
|
* The opposite of `before`. This method creates a function that invokes `func` once it's called `n` or more times.
|
|
410
423
|
*
|
|
411
|
-
* @category Function
|
|
412
|
-
* @param n The number of calls before `func` is invoked.
|
|
413
|
-
* @param func The function to restrict.
|
|
414
|
-
* @returns Returns the new restricted function.
|
|
415
424
|
* @example
|
|
416
425
|
* const caution = () => console.log("Caution!");
|
|
417
|
-
*
|
|
418
426
|
* const afterFN = after(2, caution);
|
|
419
427
|
*
|
|
420
428
|
* afterFN()
|
|
421
429
|
* afterFN()
|
|
422
430
|
* afterFN()
|
|
423
431
|
* // => `caution` is invoked after called twice
|
|
432
|
+
* @category Function
|
|
433
|
+
* @param n The number of calls before `func` is invoked.
|
|
434
|
+
* @param func The function to restrict.
|
|
435
|
+
* @returns Returns the new restricted function.
|
|
424
436
|
*/
|
|
425
437
|
declare function after<TFunc extends GenericFunction<TFunc>>(n: number, func: TFunc): (...args: Parameters<TFunc>) => ReturnType<TFunc> | undefined;
|
|
426
438
|
|
|
@@ -443,7 +455,7 @@ declare function after<TFunc extends GenericFunction<TFunc>>(n: number, func: TF
|
|
|
443
455
|
* reducedCaution()
|
|
444
456
|
* // => `caution` is invoked twice
|
|
445
457
|
*/
|
|
446
|
-
declare function before<TFunc extends
|
|
458
|
+
declare function before<TFunc extends GenericFunction<TFunc>>(n: number, func: TFunc): TFunc;
|
|
447
459
|
|
|
448
460
|
declare function debounce<TFunc extends GenericFunction<TFunc>>(fn: TFunc, wait?: number, options?: {
|
|
449
461
|
leading?: boolean;
|
|
@@ -457,18 +469,12 @@ declare function debounce<TFunc extends GenericFunction<TFunc>>(fn: TFunc, wait?
|
|
|
457
469
|
* arguments provided to the memoized function. By default, all arguments
|
|
458
470
|
* provided to the memoized function are used as the map cache key.
|
|
459
471
|
*
|
|
460
|
-
*
|
|
472
|
+
* The cache is exposed as the `cache` property on the memoized
|
|
461
473
|
* function. Its creation may be customized by replacing the `memoize.Cache`
|
|
462
474
|
* constructor with one whose instances implement the
|
|
463
475
|
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
|
|
464
476
|
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
|
|
465
477
|
*
|
|
466
|
-
* @category Function
|
|
467
|
-
* @param func - The function to have its output memoized.
|
|
468
|
-
* @param resolver - The function to resolve the cache key.
|
|
469
|
-
* @typeParam TFunc - The input function type
|
|
470
|
-
* @typeParam Cache - The cache map type
|
|
471
|
-
* @returns Returns the new memoized function.
|
|
472
478
|
* @example
|
|
473
479
|
* const object = \{ 'a': 1, 'b': 2 \}
|
|
474
480
|
*
|
|
@@ -490,24 +496,28 @@ declare function debounce<TFunc extends GenericFunction<TFunc>>(fn: TFunc, wait?
|
|
|
490
496
|
*
|
|
491
497
|
* // Replace `memoize.Cache`.
|
|
492
498
|
* memoize.Cache = WeakMap
|
|
499
|
+
* @category Function
|
|
500
|
+
* @param func - The function to have its output memoized.
|
|
501
|
+
* @param resolver - The function to resolve the cache key.
|
|
502
|
+
* @returns Returns the new memoized function.
|
|
493
503
|
*/
|
|
494
504
|
declare function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map<string | symbol, ReturnType<TFunc>>>(func: TFunc, resolver?: ((...args: Parameters<TFunc>) => string | symbol)): TFunc & {
|
|
495
505
|
cache: Cache;
|
|
496
506
|
};
|
|
497
507
|
|
|
498
508
|
/**
|
|
499
|
-
* Creates a function that is restricted to invoking `func` once.
|
|
500
|
-
* to the function return the value of the first invocation.
|
|
501
|
-
* invoked with the `this` binding and arguments of the created function.
|
|
509
|
+
* Creates a function that is restricted to invoking `func` once.
|
|
510
|
+
* Repeat calls to the function return the value of the first invocation.
|
|
502
511
|
*
|
|
503
|
-
* @category Function
|
|
504
|
-
* @param func - The function to restrict.
|
|
505
|
-
* @returns Returns the new restricted function.
|
|
506
512
|
* @example
|
|
507
513
|
* const initialize = once(() => console.log('initialize'))
|
|
508
514
|
* initialize()
|
|
509
515
|
* initialize()
|
|
510
516
|
* // => `createApplication` is invoked once
|
|
517
|
+
*
|
|
518
|
+
* @category Function
|
|
519
|
+
* @param func - The function to restrict.
|
|
520
|
+
* @returns Returns the new restricted function.
|
|
511
521
|
*/
|
|
512
522
|
declare function once<TFunc extends GenericFunction<TFunc>>(func: TFunc): TFunc;
|
|
513
523
|
|
|
@@ -517,8 +527,10 @@ declare function throttle<TFunc extends GenericFunction<TFunc>>(func: TFunc, wai
|
|
|
517
527
|
}): (this: ThisParameterType<TFunc>, ...args: Parameters<TFunc>) => ReturnType<TFunc>;
|
|
518
528
|
|
|
519
529
|
/**
|
|
520
|
-
* Invokes
|
|
521
|
-
* each invocation.
|
|
530
|
+
* Invokes a function `n` times, returning an array of the results of
|
|
531
|
+
* each invocation.
|
|
532
|
+
*
|
|
533
|
+
* The function is invoked with one argument: `index`
|
|
522
534
|
*
|
|
523
535
|
* @example
|
|
524
536
|
* times(3, index => console.log("Run", index)))
|
|
@@ -529,10 +541,10 @@ declare function throttle<TFunc extends GenericFunction<TFunc>>(func: TFunc, wai
|
|
|
529
541
|
* // => [0, 0, 0, 0]
|
|
530
542
|
* @category Function
|
|
531
543
|
* @param n - The number of times to invoke `func`.
|
|
532
|
-
* @param
|
|
533
|
-
* @returns Returns
|
|
544
|
+
* @param func - The function invoked per iteration.
|
|
545
|
+
* @returns Returns an array of results.
|
|
534
546
|
*/
|
|
535
|
-
declare function times<
|
|
547
|
+
declare function times<TInput>(n: number, func: (index: number) => TInput): TInput[];
|
|
536
548
|
|
|
537
549
|
/**
|
|
538
550
|
* Checks if `value` is an empty object, collection, map, or set.
|
|
@@ -543,9 +555,6 @@ declare function times<T>(n: number, func: (index: number) => T): T[];
|
|
|
543
555
|
* Array-like values such as `arguments` objects, arrays, buffers, strings, or
|
|
544
556
|
* Similarly, maps and sets are considered empty if they have a `size` of `0`.
|
|
545
557
|
*
|
|
546
|
-
* @category Lang
|
|
547
|
-
* @param value - The value to check.
|
|
548
|
-
* @returns Returns `true` if `value` is empty, else `false`.
|
|
549
558
|
* @example
|
|
550
559
|
* isEmpty(null)
|
|
551
560
|
* // => true
|
|
@@ -564,6 +573,9 @@ declare function times<T>(n: number, func: (index: number) => T): T[];
|
|
|
564
573
|
*
|
|
565
574
|
* isEmpty({ 'a': 1 })
|
|
566
575
|
* // => false
|
|
576
|
+
* @category Lang
|
|
577
|
+
* @param value - The value to check.
|
|
578
|
+
* @returns Returns `true` if given vlaue is empty, else `false`.
|
|
567
579
|
*/
|
|
568
580
|
declare function isEmpty(value: string | object | null | undefined): boolean;
|
|
569
581
|
|
|
@@ -585,7 +597,7 @@ declare function isEmpty(value: string | object | null | undefined): boolean;
|
|
|
585
597
|
* var object = { 'a': 1 };
|
|
586
598
|
* var other = { 'a': 1 };
|
|
587
599
|
*
|
|
588
|
-
*
|
|
600
|
+
* isEqual(object, other);
|
|
589
601
|
* // => true
|
|
590
602
|
*
|
|
591
603
|
* object === other;
|
|
@@ -600,10 +612,6 @@ declare function isEqual(value1: unknown, value2: unknown): boolean;
|
|
|
600
612
|
* six arguments: (objValue, othValue [, index|key, object, other, stack]).
|
|
601
613
|
*
|
|
602
614
|
* @category Lang
|
|
603
|
-
* @param value1 - The value to compare.
|
|
604
|
-
* @param value2 - The other value to compare.
|
|
605
|
-
* @param customizer - The function to customize comparisons.
|
|
606
|
-
* @returns Returns `true` if the values are equivalent, else `false`.
|
|
607
615
|
* @example
|
|
608
616
|
* function isGreeting(value) {
|
|
609
617
|
* return /^h(?:i|ello)$/.test(value);
|
|
@@ -620,6 +628,10 @@ declare function isEqual(value1: unknown, value2: unknown): boolean;
|
|
|
620
628
|
*
|
|
621
629
|
* isEqualWith(array, other, customizer);
|
|
622
630
|
* // => true
|
|
631
|
+
* @param a - The value to compare.
|
|
632
|
+
* @param b - The other value to compare.
|
|
633
|
+
* @param customizer - The function to customize comparisons.
|
|
634
|
+
* @returns Returns `true` if the values are equivalent, else `false`.
|
|
623
635
|
*/
|
|
624
636
|
declare function isEqualWith<T>(a: T, b: T, customizer: (value: T) => unknown): boolean;
|
|
625
637
|
|
|
@@ -638,7 +650,7 @@ declare function isPlainObject(value: unknown): value is object;
|
|
|
638
650
|
* @param keys - The property paths to pick.
|
|
639
651
|
* @returns Returns the new object.
|
|
640
652
|
*/
|
|
641
|
-
declare function pick<
|
|
653
|
+
declare function pick<TInput, Key extends keyof TInput>(object: TInput, keys: Key[]): Pick<TInput, Key>;
|
|
642
654
|
|
|
643
655
|
/**
|
|
644
656
|
* Converts `string` to camelCase.
|
|
@@ -729,11 +741,11 @@ declare function kebabCase(str: string): string;
|
|
|
729
741
|
* Converts a string to PascalCase.
|
|
730
742
|
*
|
|
731
743
|
* @example
|
|
732
|
-
*
|
|
744
|
+
* pascalCase('Foo Bar')
|
|
733
745
|
* // => 'FooBar'
|
|
734
|
-
*
|
|
746
|
+
* pascalCase('fooBar')
|
|
735
747
|
* // => 'FooBar'
|
|
736
|
-
*
|
|
748
|
+
* pascalCase('__FOO_BAR__')
|
|
737
749
|
* // => 'FooBar'
|
|
738
750
|
* @category String
|
|
739
751
|
* @param str - The string to convert.
|
|
@@ -785,7 +797,7 @@ declare function startCase(str: string): string;
|
|
|
785
797
|
* @param str - The string to remove special characters from.
|
|
786
798
|
* @returns Returns the string with special characters removed.
|
|
787
799
|
*/
|
|
788
|
-
declare function
|
|
800
|
+
declare function stripSpecial(str: string): string;
|
|
789
801
|
|
|
790
802
|
/**
|
|
791
803
|
* Converts the HTML entities `&`, `<`, `>`, `"` and `'`
|
|
@@ -800,4 +812,4 @@ declare function stripSpecialChars(str: string): string;
|
|
|
800
812
|
*/
|
|
801
813
|
declare function unescape(str: string): string;
|
|
802
814
|
|
|
803
|
-
export {
|
|
815
|
+
export { GenericFunction, IterateeFunction, MinimumTwoArrays, NoUnion, PropertyShorthand, RecordKey, after, before, camelCase, capitalize, chunk, count, debounce, deburr, difference, differenceBy, differenceWith, dropRightWhile, dropWhile, escape, escapeRegExp, group, intersection, intersectionBy, intersectionWith, isEmpty, isEqual, isEqualWith, isPlainObject, kebabCase, memoize, once, pascalCase, pick, sample, sampleSize, shuffle, snakeCase, sort, startCase, stripSpecial, takeRightWhile, takeWhile, throttle, times, unescape, uniq, uniqBy, uniqWith, unzip, unzipWith, zip, zipWith };
|