@kizmann/pico-js 0.4.15 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/pico-js.js +370 -2
- package/dist/pico-js.js.map +1 -1
- package/docs/index.html +12 -0
- package/docs/utility/any.md +427 -0
- package/package.json +2 -1
- package/src/utility/array.js +4 -0
- package/src/utility/number.js +1 -1
- package/tsconfig.json +14 -0
- package/types/index.d.ts +25 -0
- package/types/utility/any.d.ts +66 -0
- package/types/utility/array.d.ts +46 -0
- package/types/utility/now.d.ts +148 -0
- package/types/utility/number.d.ts +31 -0
- package/types/utility/object.d.ts +54 -0
- package/types/utility/string.d.ts +33 -0
- package/webservy.json +6 -0
package/docs/index.html
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
7
|
+
<title>Document</title>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
</body>
|
12
|
+
</html>
|
@@ -0,0 +1,427 @@
|
|
1
|
+
# Any Utility
|
2
|
+
|
3
|
+
The `Any` class provides a wide range of utility functions for various data type checks, conversions, and operations such as debounce and throttle. This class is part of a larger utility library and can be imported as shown below.
|
4
|
+
|
5
|
+
Here is a list of all headlines with anchor links:
|
6
|
+
|
7
|
+
- [isEmpty](#isempty)
|
8
|
+
- [isNull](#isnull)
|
9
|
+
- [isEqual](#isequal)
|
10
|
+
- [isString](#isstring)
|
11
|
+
- [isNumber](#isnumber)
|
12
|
+
- [isBool](#isbool)
|
13
|
+
- [isFunction](#isfunction)
|
14
|
+
- [isObject](#isobject)
|
15
|
+
- [isPlain](#isplain)
|
16
|
+
- [isArray](#isarray)
|
17
|
+
- [isDate](#isdate)
|
18
|
+
- [string](#string)
|
19
|
+
- [convertString](#convertstring)
|
20
|
+
- [integer](#integer)
|
21
|
+
- [float](#float)
|
22
|
+
- [bool](#bool)
|
23
|
+
- [boolean](#boolean)
|
24
|
+
- [convertBool](#convertbool)
|
25
|
+
- [convertBoolean](#convertboolean)
|
26
|
+
- [convertDatetime](#convertdatetime)
|
27
|
+
- [vals](#vals)
|
28
|
+
- [keys](#keys)
|
29
|
+
- [async](#async)
|
30
|
+
- [delay](#delay)
|
31
|
+
- [debounce](#debounce)
|
32
|
+
- [throttle](#throttle)
|
33
|
+
- [framerate](#framerate)
|
34
|
+
- [form](#form)
|
35
|
+
|
36
|
+
You can click on any of these links to navigate to the respective section in the documentation.
|
37
|
+
|
38
|
+
## Import
|
39
|
+
|
40
|
+
```javascript
|
41
|
+
import { Any } from "../index.js";
|
42
|
+
```
|
43
|
+
|
44
|
+
## Methods
|
45
|
+
|
46
|
+
### [isEmpty](#isempty)
|
47
|
+
|
48
|
+
Checks if a value is empty.
|
49
|
+
|
50
|
+
- **Parameters**:
|
51
|
+
- `val`: The value to check.
|
52
|
+
- **Returns**: `true` if the value is empty, `false` otherwise.
|
53
|
+
|
54
|
+
```javascript
|
55
|
+
Any.isEmpty(''); // true
|
56
|
+
Any.isEmpty([]); // true
|
57
|
+
Any.isEmpty({}); // true
|
58
|
+
Any.isEmpty(0); // false
|
59
|
+
```
|
60
|
+
|
61
|
+
### [isNull](#isnull)
|
62
|
+
|
63
|
+
Checks if a value is `null`.
|
64
|
+
|
65
|
+
- **Parameters**:
|
66
|
+
- `val`: The value to check.
|
67
|
+
- **Returns**: `true` if the value is `null`, `false` otherwise.
|
68
|
+
|
69
|
+
```javascript
|
70
|
+
Any.isNull(null); // true
|
71
|
+
Any.isNull(undefined); // false
|
72
|
+
```
|
73
|
+
|
74
|
+
### [isEqual](#isequal)
|
75
|
+
|
76
|
+
Checks if two values are equal.
|
77
|
+
|
78
|
+
- **Parameters**:
|
79
|
+
- `obj`: The first value.
|
80
|
+
- `val`: The second value.
|
81
|
+
- **Returns**: `true` if the values are equal, `false` otherwise.
|
82
|
+
|
83
|
+
```javascript
|
84
|
+
Any.isEqual(1, '1'); // false
|
85
|
+
Any.isEqual({a: 1}, {a: 1}); // true
|
86
|
+
```
|
87
|
+
|
88
|
+
### [isString](#isstring)
|
89
|
+
|
90
|
+
Checks if a value is a string.
|
91
|
+
|
92
|
+
- **Parameters**:
|
93
|
+
- `val`: The value to check.
|
94
|
+
- **Returns**: `true` if the value is a string, `false` otherwise.
|
95
|
+
|
96
|
+
```javascript
|
97
|
+
Any.isString('hello'); // true
|
98
|
+
Any.isString(123); // false
|
99
|
+
```
|
100
|
+
|
101
|
+
### [isNumber](#isnumber)
|
102
|
+
|
103
|
+
Checks if a value is a number or a numeric string.
|
104
|
+
|
105
|
+
- **Parameters**:
|
106
|
+
- `val`: The value to check.
|
107
|
+
- **Returns**: `true` if the value is a number or numeric string, `false` otherwise.
|
108
|
+
|
109
|
+
```javascript
|
110
|
+
Any.isNumber(123); // true
|
111
|
+
Any.isNumber('123'); // true
|
112
|
+
Any.isNumber('abc'); // false
|
113
|
+
```
|
114
|
+
|
115
|
+
### [isBool](#isbool)
|
116
|
+
|
117
|
+
Checks if a value is a boolean or a boolean string.
|
118
|
+
|
119
|
+
- **Parameters**:
|
120
|
+
- `val`: The value to check.
|
121
|
+
- **Returns**: `true` if the value is a boolean or boolean string, `false` otherwise.
|
122
|
+
|
123
|
+
```javascript
|
124
|
+
Any.isBool(true); // true
|
125
|
+
Any.isBool('false'); // true
|
126
|
+
Any.isBool('yes'); // false
|
127
|
+
```
|
128
|
+
|
129
|
+
### [isFunction](#isfunction)
|
130
|
+
|
131
|
+
Checks if a value is a function.
|
132
|
+
|
133
|
+
- **Parameters**:
|
134
|
+
- `val`: The value to check.
|
135
|
+
- **Returns**: `true` if the value is a function, `false` otherwise.
|
136
|
+
|
137
|
+
```javascript
|
138
|
+
Any.isFunction(function() {}); // true
|
139
|
+
Any.isFunction(() => {}); // true
|
140
|
+
```
|
141
|
+
|
142
|
+
### [isObject](#isobject)
|
143
|
+
|
144
|
+
Checks if a value is an object.
|
145
|
+
|
146
|
+
- **Parameters**:
|
147
|
+
- `val`: The value to check.
|
148
|
+
- **Returns**: `true` if the value is an object, `false` otherwise.
|
149
|
+
|
150
|
+
```javascript
|
151
|
+
Any.isObject({}); // true
|
152
|
+
Any.isObject(null); // false
|
153
|
+
```
|
154
|
+
|
155
|
+
### [isPlain](#isplain)
|
156
|
+
|
157
|
+
Checks if a value is a plain object.
|
158
|
+
|
159
|
+
- **Parameters**:
|
160
|
+
- `val`: The value to check.
|
161
|
+
- **Returns**: `true` if the value is a plain object, `false` otherwise.
|
162
|
+
|
163
|
+
```javascript
|
164
|
+
Any.isPlain({}); // true
|
165
|
+
Any.isPlain(new Date()); // false
|
166
|
+
```
|
167
|
+
|
168
|
+
### [isArray](#isarray)
|
169
|
+
|
170
|
+
Checks if a value is an array.
|
171
|
+
|
172
|
+
- **Parameters**:
|
173
|
+
- `val`: The value to check.
|
174
|
+
- **Returns**: `true` if the value is an array, `false` otherwise.
|
175
|
+
|
176
|
+
```javascript
|
177
|
+
Any.isArray([]); // true
|
178
|
+
Any.isArray({}); // false
|
179
|
+
```
|
180
|
+
|
181
|
+
### [isDate](#isdate)
|
182
|
+
|
183
|
+
Checks if a value is a `Date` object.
|
184
|
+
|
185
|
+
- **Parameters**:
|
186
|
+
- `val`: The value to check.
|
187
|
+
- **Returns**: `true` if the value is a `Date` object, `false` otherwise.
|
188
|
+
|
189
|
+
```javascript
|
190
|
+
Any.isDate(new Date()); // true
|
191
|
+
Any.isDate('2021-01-01'); // false
|
192
|
+
```
|
193
|
+
|
194
|
+
### [string](#string)
|
195
|
+
|
196
|
+
Converts a value to a string.
|
197
|
+
|
198
|
+
- **Parameters**:
|
199
|
+
- `val`: The value to convert.
|
200
|
+
- **Returns**: The value as a string.
|
201
|
+
|
202
|
+
```javascript
|
203
|
+
Any.string(123); // '123'
|
204
|
+
```
|
205
|
+
|
206
|
+
### [convertString](#convertstring)
|
207
|
+
|
208
|
+
Converts a value to a string or returns a default string if the value is empty.
|
209
|
+
|
210
|
+
- **Parameters**:
|
211
|
+
- `val`: The value to convert.
|
212
|
+
- `empty`: The default string if the value is empty (default is `'-'`).
|
213
|
+
- **Returns**: The value as a string or the default string if empty.
|
214
|
+
|
215
|
+
```javascript
|
216
|
+
Any.convertString(123); // '123'
|
217
|
+
Any.convertString('', '-'); // '-'
|
218
|
+
```
|
219
|
+
|
220
|
+
### [integer](#integer)
|
221
|
+
|
222
|
+
Converts a value to an integer.
|
223
|
+
|
224
|
+
- **Parameters**:
|
225
|
+
- `val`: The value to convert.
|
226
|
+
- **Returns**: The value as an integer.
|
227
|
+
|
228
|
+
```javascript
|
229
|
+
Any.integer('123'); // 123
|
230
|
+
```
|
231
|
+
|
232
|
+
### [float](#float)
|
233
|
+
|
234
|
+
Converts a value to a float.
|
235
|
+
|
236
|
+
- **Parameters**:
|
237
|
+
- `val`: The value to convert.
|
238
|
+
- **Returns**: The value as a float.
|
239
|
+
|
240
|
+
```javascript
|
241
|
+
Any.float('123.45'); // 123.45
|
242
|
+
```
|
243
|
+
|
244
|
+
### [bool](#bool)
|
245
|
+
|
246
|
+
Converts a value to a boolean.
|
247
|
+
|
248
|
+
- **Parameters**:
|
249
|
+
- `val`: The value to convert.
|
250
|
+
- **Returns**: The value as a boolean.
|
251
|
+
|
252
|
+
```javascript
|
253
|
+
Any.bool('true'); // true
|
254
|
+
Any.bool(0); // false
|
255
|
+
```
|
256
|
+
|
257
|
+
### [boolean](#boolean)
|
258
|
+
|
259
|
+
Alias for `bool`.
|
260
|
+
|
261
|
+
- **Parameters**:
|
262
|
+
- `val`: The value to convert.
|
263
|
+
- **Returns**: The value as a boolean.
|
264
|
+
|
265
|
+
```javascript
|
266
|
+
Any.boolean('yes'); // true
|
267
|
+
Any.boolean('no'); // false
|
268
|
+
```
|
269
|
+
|
270
|
+
### [convertBool](#convertbool)
|
271
|
+
|
272
|
+
Converts a value to a boolean string representation.
|
273
|
+
|
274
|
+
- **Parameters**:
|
275
|
+
- `val`: The value to convert.
|
276
|
+
- `yes`: The string to return if the value is truthy (default is `'Yes'`).
|
277
|
+
- `no`: The string to return if the value is falsy (default is `'No'`).
|
278
|
+
- **Returns**: The string representation of the boolean value.
|
279
|
+
|
280
|
+
```javascript
|
281
|
+
Any.convertBool(true); // 'Yes'
|
282
|
+
Any.convertBool(false); // 'No'
|
283
|
+
```
|
284
|
+
|
285
|
+
### [convertBoolean](#convertboolean)
|
286
|
+
|
287
|
+
Alias for `convertBool`.
|
288
|
+
|
289
|
+
- **Parameters**:
|
290
|
+
- `val`: The value to convert.
|
291
|
+
- `yes`: The string to return if the value is truthy (default is `'Yes'`).
|
292
|
+
- `no`: The string to return if the value is falsy (default is `'No'`).
|
293
|
+
- **Returns**: The string representation of the boolean value.
|
294
|
+
|
295
|
+
```javascript
|
296
|
+
Any.convertBoolean('1'); // 'Yes'
|
297
|
+
Any.convertBoolean('0'); // 'No'
|
298
|
+
```
|
299
|
+
|
300
|
+
### [convertDatetime](#convertdatetime)
|
301
|
+
|
302
|
+
Converts a value to a formatted datetime string.
|
303
|
+
|
304
|
+
- **Parameters**:
|
305
|
+
- `val`: The value to convert.
|
306
|
+
- `format`: The datetime format (default is `'YYYY-MM-DD hh:mm:ss'`).
|
307
|
+
- `empty`: The default string if the value is empty (default is `'-'`).
|
308
|
+
- **Returns**: The formatted datetime string or the default string if empty.
|
309
|
+
|
310
|
+
```javascript
|
311
|
+
Any.convertDatetime(new Date(), 'MM/DD/YYYY'); // '05/28/2024'
|
312
|
+
```
|
313
|
+
|
314
|
+
### [vals](#vals)
|
315
|
+
|
316
|
+
Gets the values of an object.
|
317
|
+
|
318
|
+
- **Parameters**:
|
319
|
+
- `obj`: The object to get values from.
|
320
|
+
- **Returns**: An array of the object's values.
|
321
|
+
|
322
|
+
```javascript
|
323
|
+
Any.vals({a: 1, b: 2}); // [1, 2]
|
324
|
+
```
|
325
|
+
|
326
|
+
### [keys](#keys)
|
327
|
+
|
328
|
+
Gets the keys of an object.
|
329
|
+
|
330
|
+
- **Parameters**:
|
331
|
+
- `obj`: The object to get keys from.
|
332
|
+
- **Returns**: An array of the object's keys.
|
333
|
+
|
334
|
+
```javascript
|
335
|
+
Any.keys({a: 1, b: 2}); // ['a', 'b']
|
336
|
+
```
|
337
|
+
|
338
|
+
### [async](#async)
|
339
|
+
|
340
|
+
Executes a callback asynchronously.
|
341
|
+
|
342
|
+
- **Parameters**:
|
343
|
+
- `callback`: The callback function.
|
344
|
+
- `...args`: The arguments to pass to the callback.
|
345
|
+
- **Returns**: The `Any` class.
|
346
|
+
|
347
|
+
```javascript
|
348
|
+
Any.async(() => console.log('Async call'));
|
349
|
+
```
|
350
|
+
|
351
|
+
### [delay](#delay)
|
352
|
+
|
353
|
+
Executes a callback after a delay.
|
354
|
+
|
355
|
+
- **Parameters**:
|
356
|
+
- `callback`: The callback function.
|
357
|
+
- `delay`: The delay in milliseconds (default is `100`).
|
358
|
+
- `...args`: The arguments to pass to the callback.
|
359
|
+
- **Returns**: The `Any` class.
|
360
|
+
|
361
|
+
```javascript
|
362
|
+
Any.delay(() => console.log('Delayed call'), 500);
|
363
|
+
```
|
364
|
+
|
365
|
+
### [debounce](#debounce)
|
366
|
+
|
367
|
+
Creates a debounced function that delays invoking the callback
|
368
|
+
|
369
|
+
until after the specified delay.
|
370
|
+
|
371
|
+
- **Parameters**:
|
372
|
+
- `callback`: The callback function.
|
373
|
+
- `delay`: The delay in milliseconds (default is `100`).
|
374
|
+
- `ref`: Optional reference to store the debounce timer.
|
375
|
+
- **Returns**: A debounced function.
|
376
|
+
|
377
|
+
```javascript
|
378
|
+
const debouncedFn = Any.debounce(() => console.log('Debounced call'), 300);
|
379
|
+
debouncedFn();
|
380
|
+
```
|
381
|
+
|
382
|
+
### [throttle](#throttle)
|
383
|
+
|
384
|
+
Creates a throttled function that only invokes the callback at most once per every specified delay.
|
385
|
+
|
386
|
+
- **Parameters**:
|
387
|
+
- `callback`: The callback function.
|
388
|
+
- `delay`: The delay in milliseconds (default is `100`).
|
389
|
+
- `ref`: Optional reference to store the throttle state.
|
390
|
+
- **Returns**: A throttled function.
|
391
|
+
|
392
|
+
```javascript
|
393
|
+
const throttledFn = Any.throttle(() => console.log('Throttled call'), 300);
|
394
|
+
throttledFn();
|
395
|
+
```
|
396
|
+
|
397
|
+
### [framerate](#framerate)
|
398
|
+
|
399
|
+
Creates a function that invokes the callback at a specified frame rate.
|
400
|
+
|
401
|
+
- **Parameters**:
|
402
|
+
- `callback`: The callback function.
|
403
|
+
- `rate`: The frame rate in frames per second (default is `30`).
|
404
|
+
- `ref`: Optional reference to store the last invocation time.
|
405
|
+
- **Returns**: A function that enforces the specified frame rate.
|
406
|
+
|
407
|
+
```javascript
|
408
|
+
const frameRateFn = Any.framerate(() => console.log('Frame rate call'), 60);
|
409
|
+
frameRateFn();
|
410
|
+
```
|
411
|
+
|
412
|
+
### [form](#form)
|
413
|
+
|
414
|
+
Creates a `FormData` object from a plain object.
|
415
|
+
|
416
|
+
- **Parameters**:
|
417
|
+
- `obj`: The plain object to convert.
|
418
|
+
- **Returns**: A `FormData` object.
|
419
|
+
|
420
|
+
```javascript
|
421
|
+
const formData = Any.form({a: 1, b: 2});
|
422
|
+
```
|
423
|
+
|
424
|
+
## License
|
425
|
+
|
426
|
+
This documentation is based on the source code of the `Any` class. The `Any` class is part of a utility library. Please refer to the library's license for more information.
|
427
|
+
```
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@kizmann/pico-js",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.5.1",
|
4
4
|
"license": "MIT",
|
5
5
|
"type": "module",
|
6
6
|
"private": false,
|
@@ -8,6 +8,7 @@
|
|
8
8
|
"repository": "https://github.com/vankizmann/pico-js",
|
9
9
|
"main": "src/index.js",
|
10
10
|
"unpkg": "dist/pico-js.js",
|
11
|
+
"types": "types/index.d.ts",
|
11
12
|
"scripts": {
|
12
13
|
"build": "webpack --hide-modules --mode=production --config webpack.config.cjs",
|
13
14
|
"watch": "webpack --watch --hide-modules --mode=development --config webpack.config.cjs"
|
package/src/utility/array.js
CHANGED
package/src/utility/number.js
CHANGED
package/tsconfig.json
ADDED
package/types/index.d.ts
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
// types/index.d.ts
|
2
|
+
import { Arr } from "./utility/array";
|
3
|
+
import { Obj } from "./utility/object";
|
4
|
+
import { Any } from "./utility/any";
|
5
|
+
import { Num } from "./utility/number";
|
6
|
+
import { Str } from "./utility/string";
|
7
|
+
import { Now } from "./utility/now";
|
8
|
+
|
9
|
+
export declare module "@kizmann/pico-js" {
|
10
|
+
|
11
|
+
const Arr: Arr;
|
12
|
+
const Obj: Obj;
|
13
|
+
const Any: Any;
|
14
|
+
const Str: Str;
|
15
|
+
const Num: Num;
|
16
|
+
const Now: Now;
|
17
|
+
|
18
|
+
export {
|
19
|
+
Arr, Obj, Any, Str, Num, Now
|
20
|
+
};
|
21
|
+
|
22
|
+
export default {
|
23
|
+
Arr, Obj, Any, Str, Num, Now
|
24
|
+
};
|
25
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
// types/utility/any.d.ts
|
2
|
+
|
3
|
+
|
4
|
+
import { Arr } from "./array";
|
5
|
+
import { Obj } from "./object";
|
6
|
+
import { Now } from "./now";
|
7
|
+
|
8
|
+
declare class Any {
|
9
|
+
static isEmpty(val : any) : boolean;
|
10
|
+
|
11
|
+
static isNull(val : any) : boolean;
|
12
|
+
|
13
|
+
static isEqual(obj : any, val : any) : boolean;
|
14
|
+
|
15
|
+
static isString(val : any) : boolean;
|
16
|
+
|
17
|
+
static isNumber(val : any) : boolean;
|
18
|
+
|
19
|
+
static isBool(val : any) : boolean;
|
20
|
+
|
21
|
+
static isFunction(val : any) : boolean;
|
22
|
+
|
23
|
+
static isObject(val : any) : boolean;
|
24
|
+
|
25
|
+
static isPlain(val : any) : boolean;
|
26
|
+
|
27
|
+
static isArray(val : any) : boolean;
|
28
|
+
|
29
|
+
static isDate(val : any) : boolean;
|
30
|
+
|
31
|
+
static string(val : any) : string;
|
32
|
+
|
33
|
+
static convertString(val : any, empty? : string) : string;
|
34
|
+
|
35
|
+
static integer(val : any) : number;
|
36
|
+
|
37
|
+
static float(val : any) : number;
|
38
|
+
|
39
|
+
static bool(val : any) : boolean;
|
40
|
+
|
41
|
+
static boolean(val : any) : boolean;
|
42
|
+
|
43
|
+
static convertBool(val : any, yes? : string, no? : string) : string;
|
44
|
+
|
45
|
+
static convertBoolean(val : any, yes? : string, no? : string) : string;
|
46
|
+
|
47
|
+
static convertDatetime(val : any, format? : string, empty? : string) : string;
|
48
|
+
|
49
|
+
static vals(obj : any) : any[];
|
50
|
+
|
51
|
+
static keys(obj : any) : string[];
|
52
|
+
|
53
|
+
static async(callback : (...args : any[]) => void, ...args : any[]) : Any;
|
54
|
+
|
55
|
+
static delay(callback : (...args : any[]) => void, delay? : number, ...args : any[]) : Any;
|
56
|
+
|
57
|
+
static debounce(callback : (...args : any[]) => void, delay? : number, ref? : any) : (...args : any[]) => void;
|
58
|
+
|
59
|
+
static throttle(callback : (...args : any[]) => void, delay? : number, ref? : any) : (...args : any[]) => void;
|
60
|
+
|
61
|
+
static framerate(callback : (...args : any[]) => void, rate? : number, ref? : any) : (...args : any[]) => void;
|
62
|
+
|
63
|
+
static form(obj : any) : FormData;
|
64
|
+
}
|
65
|
+
|
66
|
+
export default Any;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
// types/utility/array.d.ts
|
2
|
+
|
3
|
+
declare class Arr {
|
4
|
+
static make(count: number): number[];
|
5
|
+
static all<T>(arr: T | T[]): T[];
|
6
|
+
static get<T>(arr: T[], index: number, fallback?: T): T;
|
7
|
+
static set<T>(arr: T[], index: number, value: T): T;
|
8
|
+
static first<T>(arr: T[], fallback?: T): T;
|
9
|
+
static second<T>(arr: T[], fallback?: T): T;
|
10
|
+
static third<T>(arr: T[], fallback?: T): T;
|
11
|
+
static last<T>(arr: T[], fallback?: T): T;
|
12
|
+
static prepend<T>(arr: T[], val: T): T[];
|
13
|
+
static append<T>(arr: T[], val: T): T[];
|
14
|
+
static sort<T>(obj: AnyObject, key: string | ((a: T, b: T) => number)): T[];
|
15
|
+
static sortString<T>(obj: AnyObject, key: string): T[];
|
16
|
+
static filter<T>(arr: T[], filter: any): T[];
|
17
|
+
static filterIndex(arr: any[], filter: any): number[];
|
18
|
+
static find<T>(arr: T[], val: any, fallback?: T): T;
|
19
|
+
static findIndex(arr: any[], val: any, fallback?: number): number;
|
20
|
+
static has<T>(arr: T[], val: any): boolean;
|
21
|
+
static add<T>(arr: T[], val: T, finder?: any): T[];
|
22
|
+
static replace<T>(arr: T[], val: T, finder?: any): T[];
|
23
|
+
static remove<T>(arr: T[], val: any): T[];
|
24
|
+
static toggle<T>(arr: T[], val: T): T[];
|
25
|
+
static removeIndex<T>(arr: T[], val: number): T[];
|
26
|
+
static insert<T>(arr: T[], key: number, val: T): T[];
|
27
|
+
static slice<T>(arr: T[], key: number, count?: number): T[];
|
28
|
+
static splice<T>(arr: T[], key: number, count?: number): T[];
|
29
|
+
static equal<T>(arr1: T[], arr2: T[]): boolean;
|
30
|
+
static includes<T>(arr: T[], val: T): boolean;
|
31
|
+
static contains<T>(arr: T[], val: T[]): boolean;
|
32
|
+
static concat<T>(arr: T[], ...args: T[]): T[];
|
33
|
+
static clone<T>(arr: T[]): T[];
|
34
|
+
static merge<T>(arr: T[], ...args: T[]): T[];
|
35
|
+
static push<T>(arr: T[], ...args: T[]): T[];
|
36
|
+
static diff<T>(arr: T[], val: T[]): T[];
|
37
|
+
static intersect<T>(...args: T[][]): T[];
|
38
|
+
static chunk<T>(arr: T[], chunk?: number): T[][];
|
39
|
+
static reduce<T, U>(arr: T[], callback: (accumulator: U, currentValue: T, currentIndex: number, array: T[]) => U, accumulator: U): U;
|
40
|
+
static extract<T>(arr: T[], path: string): any[];
|
41
|
+
static each<T>(arr: T[], callback: (val: T, key: number | string) => any): any[];
|
42
|
+
static map<T>(arr: T[], callback: (val: T, key: number | string) => any): T[];
|
43
|
+
static recursive<T>(arr: T[], key: string, callback: (val: any, cascade: any[]) => any, cascade?: any[]): T[];
|
44
|
+
}
|
45
|
+
|
46
|
+
export default Arr;
|