npm-lodash

Description
A comprehensive JavaScript utility library with 296+ functions for arrays, objects, strings, and functional programming
Author
tessl
Last updated

How to use

npx @tessl/cli registry install tessl/npm-lodash@4.9.0

lang-methods.md docs/

1
# Language Methods
2
3
Comprehensive type checking predicates and value conversion utilities for JavaScript types, cloning, and value comparison operations.
4
5
## Capabilities
6
7
### Clone
8
9
Creates a shallow clone of value.
10
11
```javascript { .api }
12
/**
13
* Creates a shallow clone of `value`.
14
* @param value - The value to clone
15
* @returns Returns the cloned value
16
*/
17
function clone<T>(value: T): T;
18
```
19
20
### Clone Deep
21
22
Creates a deep clone of value.
23
24
```javascript { .api }
25
/**
26
* This method is like `clone` except that it recursively clones `value`.
27
* @param value - The value to recursively clone
28
* @returns Returns the deep cloned value
29
*/
30
function cloneDeep<T>(value: T): T;
31
```
32
33
### Clone Deep With
34
35
Like cloneDeep except that it accepts customizer which is invoked to produce the cloned value.
36
37
```javascript { .api }
38
/**
39
* This method is like `cloneDeep` except that it accepts `customizer`
40
* which is invoked to produce the cloned value.
41
* @param value - The value to recursively clone
42
* @param customizer - The function to customize cloning
43
* @returns Returns the deep cloned value
44
*/
45
function cloneDeepWith<T>(
46
value: T,
47
customizer?: (value: any, key?: string | number, object?: any, stack?: any) => any
48
): T;
49
```
50
51
### Clone With
52
53
Like clone except that it accepts customizer which is invoked to produce the cloned value.
54
55
```javascript { .api }
56
/**
57
* This method is like `clone` except that it accepts `customizer` which
58
* is invoked to produce the cloned value.
59
* @param value - The value to clone
60
* @param customizer - The function to customize cloning
61
* @returns Returns the cloned value
62
*/
63
function cloneWith<T>(
64
value: T,
65
customizer?: (value: any, key?: string | number, object?: any, stack?: any) => any
66
): T;
67
```
68
69
### Conforms To
70
71
Checks if object conforms to source by invoking the predicate properties of source with the corresponding property values of object.
72
73
```javascript { .api }
74
/**
75
* Checks if `object` conforms to `source` by invoking the predicate
76
* properties of `source` with the corresponding property values of `object`.
77
* @param object - The object to inspect
78
* @param source - The object of property predicates to conform to
79
* @returns Returns `true` if `object` conforms, else `false`
80
*/
81
function conformsTo<T>(object: T, source: Record<keyof T, (value: any) => boolean>): boolean;
82
```
83
84
### Eq
85
86
Performs a SameValueZero comparison between two values to determine if they are equivalent.
87
88
```javascript { .api }
89
/**
90
* Performs a [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
91
* comparison between two values to determine if they are equivalent.
92
* @param value - The value to compare
93
* @param other - The other value to compare
94
* @returns Returns `true` if the values are equivalent, else `false`
95
*/
96
function eq(value: any, other: any): boolean;
97
```
98
99
### Gt
100
101
Checks if value is greater than other.
102
103
```javascript { .api }
104
/**
105
* Checks if `value` is greater than `other`.
106
* @param value - The value to compare
107
* @param other - The other value to compare
108
* @returns Returns `true` if `value` is greater than `other`, else `false`
109
*/
110
function gt(value: any, other: any): boolean;
111
```
112
113
### Gte
114
115
Checks if value is greater than or equal to other.
116
117
```javascript { .api }
118
/**
119
* Checks if `value` is greater than or equal to `other`.
120
* @param value - The value to compare
121
* @param other - The other value to compare
122
* @returns Returns `true` if `value` is greater than or equal to `other`, else `false`
123
*/
124
function gte(value: any, other: any): boolean;
125
```
126
127
### Is Arguments
128
129
Checks if value is likely an arguments object.
130
131
```javascript { .api }
132
/**
133
* Checks if `value` is likely an `arguments` object.
134
* @param value - The value to check
135
* @returns Returns `true` if `value` is an `arguments` object, else `false`
136
*/
137
function isArguments(value?: any): value is IArguments;
138
```
139
140
### Is Array
141
142
Checks if value is classified as an Array object.
143
144
```javascript { .api }
145
/**
146
* Checks if `value` is classified as an `Array` object.
147
* @param value - The value to check
148
* @returns Returns `true` if `value` is an array, else `false`
149
*/
150
function isArray(value?: any): value is any[];
151
```
152
153
### Is Array Buffer
154
155
Checks if value is classified as an ArrayBuffer object.
156
157
```javascript { .api }
158
/**
159
* Checks if `value` is classified as an `ArrayBuffer` object.
160
* @param value - The value to check
161
* @returns Returns `true` if `value` is an array buffer, else `false`
162
*/
163
function isArrayBuffer(value?: any): value is ArrayBuffer;
164
```
165
166
### Is Array Like
167
168
Checks if value is array-like.
169
170
```javascript { .api }
171
/**
172
* Checks if `value` is array-like. A value is considered array-like if it's
173
* not a function and has a `value.length` that's an integer greater than or
174
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
175
* @param value - The value to check
176
* @returns Returns `true` if `value` is array-like, else `false`
177
*/
178
function isArrayLike(value?: any): value is ArrayLike<any>;
179
```
180
181
### Is Array Like Object
182
183
Checks if value is array-like object.
184
185
```javascript { .api }
186
/**
187
* This method is like `isArrayLike` except that it also checks if `value`
188
* is an object.
189
* @param value - The value to check
190
* @returns Returns `true` if `value` is an array-like object, else `false`
191
*/
192
function isArrayLikeObject(value?: any): value is ArrayLike<any> & object;
193
```
194
195
### Is Boolean
196
197
Checks if value is classified as a boolean primitive or object.
198
199
```javascript { .api }
200
/**
201
* Checks if `value` is classified as a boolean primitive or object.
202
* @param value - The value to check
203
* @returns Returns `true` if `value` is a boolean, else `false`
204
*/
205
function isBoolean(value?: any): value is boolean;
206
```
207
208
### Is Buffer
209
210
Checks if value is a buffer.
211
212
```javascript { .api }
213
/**
214
* Checks if `value` is a buffer.
215
* @param value - The value to check
216
* @returns Returns `true` if `value` is a buffer, else `false`
217
*/
218
function isBuffer(value?: any): boolean;
219
```
220
221
### Is Date
222
223
Checks if value is classified as a Date object.
224
225
```javascript { .api }
226
/**
227
* Checks if `value` is classified as a `Date` object.
228
* @param value - The value to check
229
* @returns Returns `true` if `value` is a date object, else `false`
230
*/
231
function isDate(value?: any): value is Date;
232
```
233
234
### Is Element
235
236
Checks if value is likely a DOM element.
237
238
```javascript { .api }
239
/**
240
* Checks if `value` is likely a DOM element.
241
* @param value - The value to check
242
* @returns Returns `true` if `value` is a DOM element, else `false`
243
*/
244
function isElement(value?: any): boolean;
245
```
246
247
### Is Empty
248
249
Checks if value is an empty object, collection, map, or set.
250
251
```javascript { .api }
252
/**
253
* Checks if `value` is an empty object, collection, map, or set.
254
* Objects are considered empty if they have no own enumerable string keyed
255
* properties. Array-like values such as `arguments` objects, arrays, buffers,
256
* strings, or jQuery-like collections are considered empty if they have a
257
* `length` of `0`. Similarly, maps and sets are considered empty if they have
258
* a `size` of `0`.
259
* @param value - The value to check
260
* @returns Returns `true` if `value` is empty, else `false`
261
*/
262
function isEmpty(value?: any): boolean;
263
```
264
265
### Is Equal
266
267
Performs a deep comparison between two values to determine if they are equivalent.
268
269
```javascript { .api }
270
/**
271
* Performs a deep comparison between two values to determine if they are
272
* equivalent.
273
* @param value - The value to compare
274
* @param other - The other value to compare
275
* @returns Returns `true` if the values are equivalent, else `false`
276
*/
277
function isEqual(value: any, other: any): boolean;
278
```
279
280
### Is Equal With
281
282
Like isEqual except that it accepts customizer which is invoked to compare values.
283
284
```javascript { .api }
285
/**
286
* This method is like `isEqual` except that it accepts `customizer` which
287
* is invoked to compare values.
288
* @param value - The value to compare
289
* @param other - The other value to compare
290
* @param customizer - The function to customize comparisons
291
* @returns Returns `true` if the values are equivalent, else `false`
292
*/
293
function isEqualWith(
294
value: any,
295
other: any,
296
customizer?: (objValue: any, othValue: any, key?: PropertyKey, object?: any, other?: any, stack?: any) => boolean | undefined
297
): boolean;
298
```
299
300
### Is Error
301
302
Checks if value is an Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, or URIError object.
303
304
```javascript { .api }
305
/**
306
* Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
307
* `SyntaxError`, `TypeError`, or `URIError` object.
308
* @param value - The value to check
309
* @returns Returns `true` if `value` is an error object, else `false`
310
*/
311
function isError(value?: any): value is Error;
312
```
313
314
### Is Finite
315
316
Checks if value is a finite primitive number.
317
318
```javascript { .api }
319
/**
320
* Checks if `value` is a finite primitive number.
321
* @param value - The value to check
322
* @returns Returns `true` if `value` is a finite number, else `false`
323
*/
324
function isFinite(value?: any): value is number;
325
```
326
327
### Is Function
328
329
Checks if value is classified as a Function object.
330
331
```javascript { .api }
332
/**
333
* Checks if `value` is classified as a `Function` object.
334
* @param value - The value to check
335
* @returns Returns `true` if `value` is a function, else `false`
336
*/
337
function isFunction(value?: any): value is Function;
338
```
339
340
### Is Integer
341
342
Checks if value is an integer.
343
344
```javascript { .api }
345
/**
346
* Checks if `value` is an integer.
347
* @param value - The value to check
348
* @returns Returns `true` if `value` is an integer, else `false`
349
*/
350
function isInteger(value?: any): value is number;
351
```
352
353
### Is Length
354
355
Checks if value is a valid array-like length.
356
357
```javascript { .api }
358
/**
359
* Checks if `value` is a valid array-like length.
360
* @param value - The value to check
361
* @returns Returns `true` if `value` is a valid length, else `false`
362
*/
363
function isLength(value?: any): boolean;
364
```
365
366
### Is Map
367
368
Checks if value is classified as a Map object.
369
370
```javascript { .api }
371
/**
372
* Checks if `value` is classified as a `Map` object.
373
* @param value - The value to check
374
* @returns Returns `true` if `value` is a map, else `false`
375
*/
376
function isMap(value?: any): value is Map<any, any>;
377
```
378
379
### Is Match
380
381
Performs a partial deep comparison between object and source to determine if object contains equivalent property values.
382
383
```javascript { .api }
384
/**
385
* Performs a partial deep comparison between `object` and `source` to
386
* determine if `object` contains equivalent property values.
387
* @param object - The object to inspect
388
* @param source - The object of property values to match
389
* @returns Returns `true` if `object` is a match, else `false`
390
*/
391
function isMatch(object: any, source: any): boolean;
392
```
393
394
### Is Match With
395
396
Like isMatch except that it accepts customizer which is invoked to compare values.
397
398
```javascript { .api }
399
/**
400
* This method is like `isMatch` except that it accepts `customizer` which
401
* is invoked to compare values.
402
* @param object - The object to inspect
403
* @param source - The object of property values to match
404
* @param customizer - The function to customize comparisons
405
* @returns Returns `true` if `object` is a match, else `false`
406
*/
407
function isMatchWith(
408
object: any,
409
source: any,
410
customizer?: (objValue: any, srcValue: any, key?: PropertyKey, object?: any, source?: any) => boolean | undefined
411
): boolean;
412
```
413
414
### Is NaN
415
416
Checks if value is NaN.
417
418
```javascript { .api }
419
/**
420
* Checks if `value` is `NaN`.
421
* @param value - The value to check
422
* @returns Returns `true` if `value` is `NaN`, else `false`
423
*/
424
function isNaN(value?: any): boolean;
425
```
426
427
### Is Native
428
429
Checks if value is a pristine native function.
430
431
```javascript { .api }
432
/**
433
* Checks if `value` is a pristine native function.
434
* @param value - The value to check
435
* @returns Returns `true` if `value` is a native function, else `false`
436
*/
437
function isNative(value?: any): boolean;
438
```
439
440
### Is Nil
441
442
Checks if value is null or undefined.
443
444
```javascript { .api }
445
/**
446
* Checks if `value` is `null` or `undefined`.
447
* @param value - The value to check
448
* @returns Returns `true` if `value` is nullish, else `false`
449
*/
450
function isNil(value?: any): value is null | undefined;
451
```
452
453
### Is Null
454
455
Checks if value is null.
456
457
```javascript { .api }
458
/**
459
* Checks if `value` is `null`.
460
* @param value - The value to check
461
* @returns Returns `true` if `value` is `null`, else `false`
462
*/
463
function isNull(value?: any): value is null;
464
```
465
466
### Is Number
467
468
Checks if value is classified as a Number primitive or object.
469
470
```javascript { .api }
471
/**
472
* Checks if `value` is classified as a `Number` primitive or object.
473
* @param value - The value to check
474
* @returns Returns `true` if `value` is a number, else `false`
475
*/
476
function isNumber(value?: any): value is number;
477
```
478
479
### Is Object
480
481
Checks if value is the language type of Object.
482
483
```javascript { .api }
484
/**
485
* Checks if `value` is the [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
486
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
487
* @param value - The value to check
488
* @returns Returns `true` if `value` is an object, else `false`
489
*/
490
function isObject(value?: any): value is object;
491
```
492
493
### Is Object Like
494
495
Checks if value is object-like.
496
497
```javascript { .api }
498
/**
499
* Checks if `value` is object-like. A value is object-like if it's not `null`
500
* and has a `typeof` result of "object".
501
* @param value - The value to check
502
* @returns Returns `true` if `value` is object-like, else `false`
503
*/
504
function isObjectLike(value?: any): boolean;
505
```
506
507
### Is Plain Object
508
509
Checks if value is a plain object, that is, an object created by the Object constructor or one with a [[Prototype]] of null.
510
511
```javascript { .api }
512
/**
513
* Checks if `value` is a plain object, that is, an object created by the
514
* `Object` constructor or one with a `[[Prototype]]` of `null`.
515
* @param value - The value to check
516
* @returns Returns `true` if `value` is a plain object, else `false`
517
*/
518
function isPlainObject(value?: any): boolean;
519
```
520
521
### Is RegExp
522
523
Checks if value is classified as a RegExp object.
524
525
```javascript { .api }
526
/**
527
* Checks if `value` is classified as a `RegExp` object.
528
* @param value - The value to check
529
* @returns Returns `true` if `value` is a regexp, else `false`
530
*/
531
function isRegExp(value?: any): value is RegExp;
532
```
533
534
### Is Safe Integer
535
536
Checks if value is a safe integer.
537
538
```javascript { .api }
539
/**
540
* Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
541
* double precision number which isn't the result of a rounded unsafe integer.
542
* @param value - The value to check
543
* @returns Returns `true` if `value` is a safe integer, else `false`
544
*/
545
function isSafeInteger(value?: any): value is number;
546
```
547
548
### Is Set
549
550
Checks if value is classified as a Set object.
551
552
```javascript { .api }
553
/**
554
* Checks if `value` is classified as a `Set` object.
555
* @param value - The value to check
556
* @returns Returns `true` if `value` is a set, else `false`
557
*/
558
function isSet(value?: any): value is Set<any>;
559
```
560
561
### Is String
562
563
Checks if value is classified as a String primitive or object.
564
565
```javascript { .api }
566
/**
567
* Checks if `value` is classified as a `String` primitive or object.
568
* @param value - The value to check
569
* @returns Returns `true` if `value` is a string, else `false`
570
*/
571
function isString(value?: any): value is string;
572
```
573
574
### Is Symbol
575
576
Checks if value is classified as a Symbol primitive or object.
577
578
```javascript { .api }
579
/**
580
* Checks if `value` is classified as a `Symbol` primitive or object.
581
* @param value - The value to check
582
* @returns Returns `true` if `value` is a symbol, else `false`
583
*/
584
function isSymbol(value?: any): value is symbol;
585
```
586
587
### Is Typed Array
588
589
Checks if value is classified as a typed array.
590
591
```javascript { .api }
592
/**
593
* Checks if `value` is classified as a typed array.
594
* @param value - The value to check
595
* @returns Returns `true` if `value` is a typed array, else `false`
596
*/
597
function isTypedArray(value?: any): value is TypedArray;
598
```
599
600
### Is Undefined
601
602
Checks if value is undefined.
603
604
```javascript { .api }
605
/**
606
* Checks if `value` is `undefined`.
607
* @param value - The value to check
608
* @returns Returns `true` if `value` is `undefined`, else `false`
609
*/
610
function isUndefined(value?: any): value is undefined;
611
```
612
613
### Is Weak Map
614
615
Checks if value is classified as a WeakMap object.
616
617
```javascript { .api }
618
/**
619
* Checks if `value` is classified as a `WeakMap` object.
620
* @param value - The value to check
621
* @returns Returns `true` if `value` is a weak map, else `false`
622
*/
623
function isWeakMap(value?: any): value is WeakMap<any, any>;
624
```
625
626
### Is Weak Set
627
628
Checks if value is classified as a WeakSet object.
629
630
```javascript { .api }
631
/**
632
* Checks if `value` is classified as a `WeakSet` object.
633
* @param value - The value to check
634
* @returns Returns `true` if `value` is a weak set, else `false`
635
*/
636
function isWeakSet(value?: any): value is WeakSet<any>;
637
```
638
639
### Lt
640
641
Checks if value is less than other.
642
643
```javascript { .api }
644
/**
645
* Checks if `value` is less than `other`.
646
* @param value - The value to compare
647
* @param other - The other value to compare
648
* @returns Returns `true` if `value` is less than `other`, else `false`
649
*/
650
function lt(value: any, other: any): boolean;
651
```
652
653
### Lte
654
655
Checks if value is less than or equal to other.
656
657
```javascript { .api }
658
/**
659
* Checks if `value` is less than or equal to `other`.
660
* @param value - The value to compare
661
* @param other - The other value to compare
662
* @returns Returns `true` if `value` is less than or equal to `other`, else `false`
663
*/
664
function lte(value: any, other: any): boolean;
665
```
666
667
### To Array
668
669
Converts value to an array.
670
671
```javascript { .api }
672
/**
673
* Converts `value` to an array.
674
* @param value - The value to convert
675
* @returns Returns the converted array
676
*/
677
function toArray<T>(value: ArrayLike<T> | T): T[];
678
```
679
680
### To Finite
681
682
Converts value to a finite number.
683
684
```javascript { .api }
685
/**
686
* Converts `value` to a finite number.
687
* @param value - The value to convert
688
* @returns Returns the converted number
689
*/
690
function toFinite(value?: any): number;
691
```
692
693
### To Integer
694
695
Converts value to an integer.
696
697
```javascript { .api }
698
/**
699
* Converts `value` to an integer.
700
* @param value - The value to convert
701
* @returns Returns the converted integer
702
*/
703
function toInteger(value?: any): number;
704
```
705
706
### To Length
707
708
Converts value to an integer suitable for use as the length of an array-like object.
709
710
```javascript { .api }
711
/**
712
* Converts `value` to an integer suitable for use as the length of an
713
* array-like object.
714
* @param value - The value to convert
715
* @returns Returns the converted integer
716
*/
717
function toLength(value?: any): number;
718
```
719
720
### To Number
721
722
Converts value to a number.
723
724
```javascript { .api }
725
/**
726
* Converts `value` to a number.
727
* @param value - The value to process
728
* @returns Returns the number
729
*/
730
function toNumber(value?: any): number;
731
```
732
733
### To Plain Object
734
735
Converts value to a plain object flattening inherited enumerable string keyed properties of value to own properties of the plain object.
736
737
```javascript { .api }
738
/**
739
* Converts `value` to a plain object flattening inherited enumerable string
740
* keyed properties of `value` to own properties of the plain object.
741
* @param value - The value to convert
742
* @returns Returns the converted plain object
743
*/
744
function toPlainObject(value?: any): any;
745
```
746
747
### To Safe Integer
748
749
Converts value to a safe integer.
750
751
```javascript { .api }
752
/**
753
* Converts `value` to a safe integer. A safe integer can be compared and
754
* represented correctly.
755
* @param value - The value to convert
756
* @returns Returns the converted integer
757
*/
758
function toSafeInteger(value?: any): number;
759
```
760
761
### To String
762
763
Converts value to a string.
764
765
```javascript { .api }
766
/**
767
* Converts `value` to a string. An empty string is returned for `null`
768
* and `undefined` values. The sign of `-0` is preserved.
769
* @param value - The value to convert
770
* @returns Returns the converted string
771
*/
772
function toString(value?: any): string;
773
```
774
775
## Types
776
777
```javascript { .api }
778
type ArrayLike<T> = {
779
readonly length: number;
780
readonly [n: number]: T;
781
};
782
783
type PropertyKey = string | number | symbol;
784
785
type TypedArray =
786
| Int8Array
787
| Uint8Array
788
| Uint8ClampedArray
789
| Int16Array
790
| Uint16Array
791
| Int32Array
792
| Uint32Array
793
| Float32Array
794
| Float64Array;
795
```