@kizmann/pico-js 2.0.7 → 2.0.9

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.
Files changed (97) hide show
  1. package/dist/pico-js.browser.js +1 -1
  2. package/dist/pico-js.browser.js.map +1 -1
  3. package/dist/pico-js.esm.js +1 -1
  4. package/dist/pico-js.esm.js.map +1 -1
  5. package/package.json +4 -6
  6. package/src/dom/{DomAttribute.js → DomAttribute.ts} +40 -63
  7. package/src/dom/{DomBuilder.js → DomBuilder.ts} +27 -44
  8. package/src/dom/{DomEvent.js → DomEvent.ts} +101 -76
  9. package/src/dom/{DomFinder.js → DomFinder.ts} +103 -139
  10. package/src/dom/DomForm.ts +38 -0
  11. package/src/dom/{DomGlobal.js → DomGlobal.ts} +34 -51
  12. package/src/dom/{DomInview.js → DomInview.ts} +37 -57
  13. package/src/dom/DomMeta.ts +48 -0
  14. package/src/dom/DomObserver.ts +17 -0
  15. package/src/dom/{DomPopover.js → DomPopover.ts} +20 -39
  16. package/src/dom/{DomRectangle.js → DomRectangle.ts} +70 -87
  17. package/src/format/{FormatFile.js → FormatFile.ts} +12 -23
  18. package/src/format/{FormatOption.js → FormatOption.ts} +15 -24
  19. package/src/format/{FormatParam.js → FormatParam.ts} +14 -25
  20. package/src/format/{FormatParser.js → FormatParser.ts} +29 -39
  21. package/src/format/{FormatUrl.js → FormatUrl.ts} +9 -21
  22. package/src/index.browser.ts +32 -0
  23. package/src/index.esm.ts +64 -0
  24. package/src/now/{NowDefault.js → NowDefault.ts} +86 -121
  25. package/src/now/{NowFormat.js → NowFormat.ts} +23 -28
  26. package/src/now/{NowGrid.js → NowGrid.ts} +41 -58
  27. package/src/now/{NowHuman.js → NowHuman.ts} +18 -27
  28. package/src/now/{NowMatch.js → NowMatch.ts} +22 -28
  29. package/src/now/{NowRange.js → NowRange.ts} +13 -22
  30. package/src/now/{NowWalker.js → NowWalker.ts} +65 -71
  31. package/src/tool/{scope.js → scope.ts} +41 -11
  32. package/src/utils/{Array.js → Array.ts} +187 -152
  33. package/src/utils/{Cookie.js → Cookie.ts} +15 -12
  34. package/src/utils/{Data.js → Data.ts} +17 -17
  35. package/src/utils/Dom.ts +204 -0
  36. package/src/utils/Format.ts +48 -0
  37. package/src/utils/{Hash.js → Hash.ts} +20 -20
  38. package/src/utils/{Locale.js → Locale.ts} +21 -21
  39. package/src/utils/{Mixed.js → Mixed.ts} +104 -61
  40. package/src/utils/{Now.js → Now.ts} +68 -69
  41. package/src/utils/{Number.js → Number.ts} +34 -36
  42. package/src/utils/{Object.js → Object.ts} +68 -122
  43. package/src/utils/{Route.js → Route.ts} +11 -9
  44. package/src/utils/{Runner.js → Runner.ts} +89 -77
  45. package/src/utils/{Signal.js → Signal.ts} +35 -22
  46. package/src/utils/{String.js → String.ts} +79 -69
  47. package/src/wip/{Element.js → Element.ts} +2 -2
  48. package/src/wip/{Map.js → Map.ts} +1 -1
  49. package/types/dom/DomAttribute.d.ts +16 -27
  50. package/types/dom/DomBuilder.d.ts +6 -9
  51. package/types/dom/DomEvent.d.ts +19 -24
  52. package/types/dom/DomFinder.d.ts +38 -61
  53. package/types/dom/DomForm.d.ts +7 -10
  54. package/types/dom/DomGlobal.d.ts +8 -15
  55. package/types/dom/DomInview.d.ts +9 -19
  56. package/types/dom/DomMeta.d.ts +9 -16
  57. package/types/dom/DomObserver.d.ts +4 -8
  58. package/types/dom/DomPopover.d.ts +8 -11
  59. package/types/dom/DomRectangle.d.ts +21 -35
  60. package/types/format/FormatFile.d.ts +5 -8
  61. package/types/format/FormatOption.d.ts +6 -8
  62. package/types/format/FormatParam.d.ts +6 -9
  63. package/types/format/FormatParser.d.ts +10 -18
  64. package/types/format/FormatUrl.d.ts +5 -8
  65. package/types/index.esm.d.ts +25 -37
  66. package/types/now/NowDefault.d.ts +30 -99
  67. package/types/now/NowFormat.d.ts +8 -21
  68. package/types/now/NowGrid.d.ts +24 -46
  69. package/types/now/NowHuman.d.ts +10 -11
  70. package/types/now/NowMatch.d.ts +6 -4
  71. package/types/now/NowRange.d.ts +5 -8
  72. package/types/now/NowWalker.d.ts +6 -4
  73. package/types/tool/scope.d.ts +11 -3
  74. package/types/utils/Array.d.ts +83 -101
  75. package/types/utils/Cookie.d.ts +11 -8
  76. package/types/utils/Data.d.ts +7 -7
  77. package/types/utils/Dom.d.ts +63 -96
  78. package/types/utils/Format.d.ts +15 -28
  79. package/types/utils/Hash.d.ts +21 -21
  80. package/types/utils/Locale.d.ts +9 -9
  81. package/types/utils/Mixed.d.ts +19 -32
  82. package/types/utils/Now.d.ts +51 -56
  83. package/types/utils/Number.d.ts +9 -20
  84. package/types/utils/Object.d.ts +21 -36
  85. package/types/utils/Route.d.ts +5 -2
  86. package/types/utils/Runner.d.ts +45 -38
  87. package/types/utils/Signal.d.ts +16 -16
  88. package/types/utils/String.d.ts +40 -76
  89. package/src/dom/DomForm.js +0 -59
  90. package/src/dom/DomMeta.js +0 -68
  91. package/src/dom/DomObserver.js +0 -38
  92. package/src/index.browser.js +0 -36
  93. package/src/index.esm.js +0 -80
  94. package/src/utils/Dom.js +0 -214
  95. package/src/utils/Format.js +0 -62
  96. package/types/wip/Element.d.ts +0 -119
  97. package/types/wip/Map.d.ts +0 -254
@@ -1,4 +1,4 @@
1
- import { Obj, Mix, Any } from "../index.esm.js";
1
+ import { Obj, Mix, Any, Arr } from "../index.esm.ts";
2
2
 
3
3
  export class PicoArray
4
4
  {
@@ -12,7 +12,7 @@ export class PicoArray
12
12
  * @param {any} value Value to wrap
13
13
  * @returns {Array<any>} Wrapped array
14
14
  */
15
- static all(value)
15
+ static all(value : any) : Array<any>
16
16
  {
17
17
  return Mix.isArr(value) ? value : [value];
18
18
  }
@@ -28,7 +28,7 @@ export class PicoArray
28
28
  * @param {any} [fallback] Fallback value
29
29
  * @returns {any} Item or fallback
30
30
  */
31
- static get(value, index, fallback = null)
31
+ static get(value : any, index : number, fallback : any = null) : any
32
32
  {
33
33
  if ( !Mix.isArr(value) ) {
34
34
  return value;
@@ -46,12 +46,12 @@ export class PicoArray
46
46
  *
47
47
  * @example Arr.set([1,2], 0, 9) // => [9,2]
48
48
  *
49
- * @param {Array<any>} target Target array
49
+ * @param {any} target Target array
50
50
  * @param {number} index Index to set
51
51
  * @param {any} value Value to set
52
52
  * @returns {any} Splice result
53
53
  */
54
- static set(target, index, value)
54
+ static set(target : any, index : number, value : any) : any
55
55
  {
56
56
  return this.splice(target, index, 1, value);
57
57
  }
@@ -61,15 +61,41 @@ export class PicoArray
61
61
  *
62
62
  * @example Arr.unset([1,2], 0) // => [1]
63
63
  *
64
- * @param {Array<any>} target Target array
64
+ * @param {any} target Target array
65
65
  * @param {number} index Index to remove
66
66
  * @returns {any} Splice result
67
67
  */
68
- static unset(target, index)
68
+ static unset(target : any, index : number) : any
69
69
  {
70
70
  return this.splice(target, index, 1);
71
71
  }
72
72
 
73
+ static prev(target : any, index : number) : number
74
+ {
75
+ if ( Mix.isEmpty(target) || !Mix.isArr(target) ) {
76
+ return 0;
77
+ }
78
+
79
+ if ( index - 1 < 0 ) {
80
+ return target.length - 1;
81
+ }
82
+
83
+ return index - 1;
84
+ }
85
+
86
+ static next(target : any, index : number) : number
87
+ {
88
+ if ( Mix.isEmpty(target) || !Mix.isArr(target) ) {
89
+ return 0;
90
+ }
91
+
92
+ if ( index + 1 > target.length ) {
93
+ return 0;
94
+ }
95
+
96
+ return index + 1;
97
+ }
98
+
73
99
  /**
74
100
  * Create array with callback values
75
101
  *
@@ -80,7 +106,7 @@ export class PicoArray
80
106
  * @param {any} [cb] Value or mapper
81
107
  * @returns {Array<any>} Generated array
82
108
  */
83
- static make(length, cb = null)
109
+ static make(length : number, cb : any = null) : Array<any>
84
110
  {
85
111
  let result = new Array(length);
86
112
 
@@ -88,7 +114,7 @@ export class PicoArray
88
114
  cb = (i) => i;
89
115
  }
90
116
 
91
- for ( let i = 0; i < length; i ++ ) {
117
+ for ( let i = 0; i < length; i++ ) {
92
118
  result[i] = typeof cb === 'function' ? cb(i) : cb;
93
119
  }
94
120
 
@@ -105,10 +131,10 @@ export class PicoArray
105
131
  * @param {any} search Search value
106
132
  * @returns {boolean} True if found
107
133
  */
108
- static has(value, search)
134
+ static has(value : any, search : any) : boolean
109
135
  {
110
136
  if ( !Mix.isPrim(search) ) {
111
- return this.findIndex(value, search) !== - 1;
137
+ return this.findIndex(value, search) !== -1;
112
138
  }
113
139
 
114
140
  if ( !Mix.isRef(value) ) {
@@ -119,11 +145,11 @@ export class PicoArray
119
145
  value = Mix.vals(value);
120
146
  }
121
147
 
122
- let index = value.findIndex((val) => {
148
+ let index = value.findIndex((val : any) => {
123
149
  return val == search;
124
150
  });
125
151
 
126
- return index !== - 1;
152
+ return index !== -1;
127
153
  }
128
154
 
129
155
  /**
@@ -131,10 +157,10 @@ export class PicoArray
131
157
  *
132
158
  * @example Arr.unique(["a","a"]) // => ["a"]
133
159
  *
134
- * @param {Array<any>} value Input list
160
+ * @param {any[]} value Input list
135
161
  * @returns {Array<any>} Unique list
136
162
  */
137
- static unique(value)
163
+ static unique(value : any[]) : Array<any>
138
164
  {
139
165
  let buffer = {};
140
166
 
@@ -150,15 +176,15 @@ export class PicoArray
150
176
  *
151
177
  * @example Arr.lengths([1],[2]) // => true
152
178
  *
153
- * @param {Array<any>} value Base array
154
- * @param {...Array<any>} args Other arrays
179
+ * @param {any[]} value Base array
180
+ * @param {[...any[]]} args Other arrays
155
181
  * @returns {boolean} True if equal
156
182
  */
157
- static lengths(value, ...args)
183
+ static lengths(value : any[], ...args : [...any[]]) : boolean
158
184
  {
159
185
  let length = value.length;
160
186
 
161
- for ( let i = 0; i < args.length; i ++ ) {
187
+ for ( let i = 0; i < args.length; i++ ) {
162
188
  if ( args[i].length !== length ) {
163
189
  return false;
164
190
  }
@@ -172,11 +198,11 @@ export class PicoArray
172
198
  *
173
199
  * @example Arr.first([1,2]) // => 1
174
200
  *
175
- * @param {Array<any>} value Input array
201
+ * @param {any} value Input array
176
202
  * @param {any} [fallback] Fallback value
177
203
  * @returns {any} First item
178
204
  */
179
- static first(value, fallback = null)
205
+ static first(value : any, fallback : any = null) : any
180
206
  {
181
207
  return this.get(value, 0, fallback);
182
208
  }
@@ -186,11 +212,11 @@ export class PicoArray
186
212
  *
187
213
  * @example Arr.second([1,2]) // => 2
188
214
  *
189
- * @param {Array<any>} value Input array
215
+ * @param {any} value Input array
190
216
  * @param {any} [fallback] Fallback value
191
217
  * @returns {any} Second item
192
218
  */
193
- static second(value, fallback = null)
219
+ static second(value : any, fallback : any = null) : any
194
220
  {
195
221
  return this.get(value, 2, fallback);
196
222
  }
@@ -200,11 +226,11 @@ export class PicoArray
200
226
  *
201
227
  * @example Arr.third([1,2,3]) // => 3
202
228
  *
203
- * @param {Array<any>} value Input array
229
+ * @param {any} value Input array
204
230
  * @param {any} [fallback] Fallback value
205
231
  * @returns {any} Third item
206
232
  */
207
- static third(value, fallback = null)
233
+ static third(value : any, fallback : any = null) : any
208
234
  {
209
235
  return this.get(value, 2, fallback);
210
236
  }
@@ -214,11 +240,11 @@ export class PicoArray
214
240
  *
215
241
  * @example Arr.last([1,2]) // => 2
216
242
  *
217
- * @param {Array<any>} value Input array
243
+ * @param {any} value Input array
218
244
  * @param {any} [fallback] Fallback value
219
245
  * @returns {any} Last item
220
246
  */
221
- static last(value, fallback = null)
247
+ static last(value : any, fallback : any = null) : any
222
248
  {
223
249
  return this.get(value, value.length - 1, fallback);
224
250
  }
@@ -229,11 +255,11 @@ export class PicoArray
229
255
  * @example Arr.each([1], v => v+1) // => [2]
230
256
  *
231
257
  * @param {any} value Input list
232
- * @param {function} cb Map callback
258
+ * @param {Function} cb Map callback
233
259
  * @param {any} [retval] Forced return
234
260
  * @returns {any} Mapped array
235
261
  */
236
- static each(value, cb, retval = null)
262
+ static each(value : any, cb : Function, retval : any = null) : any
237
263
  {
238
264
  if ( Mix.isObj(value) ) {
239
265
  return this.eachObj(value, cb, retval);
@@ -245,7 +271,7 @@ export class PicoArray
245
271
 
246
272
  let result = new Array(value.length);
247
273
 
248
- for ( let i = 0; i < value.length; i ++ ) {
274
+ for ( let i = 0; i < value.length; i++ ) {
249
275
  result[i] = cb(value[i], i);
250
276
  }
251
277
 
@@ -258,11 +284,11 @@ export class PicoArray
258
284
  * @example Arr.eachObj({a:1}, (v,k) => v+1) // => [2]
259
285
  *
260
286
  * @param {any} value Input object
261
- * @param {function} cb Iterate callback
287
+ * @param {Function} cb Iterate callback
262
288
  * @param {any} [retval] Return value override
263
289
  * @returns {any} Mapped values or retval
264
290
  */
265
- static eachObj(value, cb, retval = null)
291
+ static eachObj(value : any, cb : Function, retval : any = null) : any
266
292
  {
267
293
  if ( Mix.isArr(value) ) {
268
294
  return this.each(value, cb, retval);
@@ -285,16 +311,16 @@ export class PicoArray
285
311
  * @example Arr.map([1], v => v+1) // => [2]
286
312
  *
287
313
  * @param {any} value Input list
288
- * @param {function} cb Map callback
314
+ * @param {Function} cb Map callback
289
315
  * @returns {any} Mutated input
290
316
  */
291
- static map(value, cb)
317
+ static map(value : any, cb : Function) : any
292
318
  {
293
319
  let [isArr, keys] = [
294
320
  Mix.isArr(value), Mix.keys(value)
295
321
  ];
296
322
 
297
- let fn = (key) => {
323
+ let fn = (key : any) => {
298
324
  return isArr ? parseInt(key) : key;
299
325
  };
300
326
 
@@ -312,14 +338,14 @@ export class PicoArray
312
338
  *
313
339
  * @param {any} value Input list
314
340
  * @param {string} key Child key
315
- * @param {function} cb Node callback
316
- * @param {Array<any>} [cascade] Parent chain
341
+ * @param {Function} cb Node callback
342
+ * @param {any[]} [cascade] Parent chain
317
343
  * @returns {any} Mapped tree
318
344
  */
319
- static recursive(value, key, cb, cascade = [])
345
+ static recursive(value : any, key : string, cb : Function, cascade : any[] = []) : any
320
346
  {
321
347
  // NIE WIEDER ANFASSEN !!!
322
- let fn = (cas) => (val) => {
348
+ let fn = (cas : any) => (val : any) => {
323
349
  return this.recursive(val, key, cb, cas);
324
350
  };
325
351
 
@@ -350,6 +376,29 @@ export class PicoArray
350
376
  return value;
351
377
  }
352
378
 
379
+ static cascade(value : any, childs : string, key : string, cascade : any[] = [], result : any = {}) : any
380
+ {
381
+ if ( value == null ) {
382
+ return result;
383
+ }
384
+
385
+ if ( Mix.isObj(value) ) {
386
+ return this.cascade(value[key], childs, key);
387
+ }
388
+
389
+ const fn = (val : any) => {
390
+ return this.cascade(...[
391
+ val[childs], childs, key, result[val[key]], result
392
+ ]);
393
+ };
394
+
395
+ this.each(value, (val : any) => {
396
+ (result[val[key]] = [...cascade, val[key]], fn(val));
397
+ });
398
+
399
+ return result;
400
+ }
401
+
353
402
  /**
354
403
  * Get matching indexes by filter
355
404
  *
@@ -357,16 +406,16 @@ export class PicoArray
357
406
  *
358
407
  * @param {any} value Input list
359
408
  * @param {any} [filter] Filter spec
360
- * @returns {Array<string>} Matching keys
409
+ * @returns {Array<any>} Matching keys
361
410
  */
362
- static filterIndex(value, filter = null)
411
+ static filterIndex(value : any, filter : any = null) : Array<any>
363
412
  {
364
413
  if ( value == null ) {
365
414
  return [];
366
415
  }
367
416
 
368
417
  if ( filter == null ) {
369
- filter = (val) => !Mix.isEmpty(val);
418
+ filter = (val : any) => !Mix.isEmpty(val);
370
419
  }
371
420
 
372
421
  return Mix.keys(value).filter((key) => {
@@ -392,7 +441,7 @@ export class PicoArray
392
441
  * @param {any} [filter] Filter spec
393
442
  * @returns {any} Mutated list
394
443
  */
395
- static filterRemove(value, filter = null)
444
+ static filterRemove(value : any, filter : any = null) : any
396
445
  {
397
446
  if ( value == null ) {
398
447
  return value;
@@ -416,14 +465,14 @@ export class PicoArray
416
465
  * @param {any} [filter] Filter spec
417
466
  * @returns {Array<any>} Filtered values
418
467
  */
419
- static filter(value, filter = null)
468
+ static filter(value : any, filter : any = null) : Array<any>
420
469
  {
421
470
  if ( value == null ) {
422
471
  return [];
423
472
  }
424
473
 
425
474
  if ( filter == null ) {
426
- filter = (val) => !Mix.isEmpty(val);
475
+ filter = (val : any) => !Mix.isEmpty(val);
427
476
  }
428
477
 
429
478
  return Mix.vals(value).filter((val, key) => {
@@ -445,22 +494,22 @@ export class PicoArray
445
494
  *
446
495
  * @example Arr.findIndex([1,2], 2) // => 1
447
496
  *
448
- * @param {Array<any>} value Input array
497
+ * @param {any} value Input array
449
498
  * @param {any} [filter] Filter spec
450
499
  * @param {number} [fallback] Fallback index
451
500
  * @returns {number} Found index
452
501
  */
453
- static findIndex(value, filter = null, fallback = - 1)
502
+ static findIndex(value : any, filter : any = null, fallback : number = -1) : number
454
503
  {
455
504
  if ( value == null ) {
456
505
  return fallback;
457
506
  }
458
507
 
459
508
  if ( filter == null ) {
460
- filter = (val) => !Mix.isEmpty(val);
509
+ filter = (val : any) => !Mix.isEmpty(val);
461
510
  }
462
511
 
463
- for ( let i = 0; i < value.length; i ++ ) {
512
+ for ( let i = 0; i < value.length; i++ ) {
464
513
 
465
514
  if ( Mix.isFunc(filter) ) {
466
515
  if ( filter.call({}, value[i], i) ) {
@@ -485,16 +534,16 @@ export class PicoArray
485
534
  *
486
535
  * @example Arr.find([1,2], 2) // => 2
487
536
  *
488
- * @param {Array<any>} value Input array
537
+ * @param {any} value Input array
489
538
  * @param {any} [filter] Filter spec
490
539
  * @param {any} [fallback] Fallback value
491
540
  * @returns {any} Found value
492
541
  */
493
- static find(value, filter = null, fallback = null)
542
+ static find(value : any, filter : any = null, fallback : any = null) : any
494
543
  {
495
544
  let index = this.findIndex(value, filter);
496
545
 
497
- if ( index === - 1 ) {
546
+ if ( index === -1 ) {
498
547
  return fallback;
499
548
  }
500
549
 
@@ -510,7 +559,7 @@ export class PicoArray
510
559
  * @param {any} [key] Key or compare fn
511
560
  * @returns {Array<any>} Sorted list
512
561
  */
513
- static sort(value, key = null)
562
+ static sort(value : any, key : any = null) : Array<any>
514
563
  {
515
564
  if ( Mix.isFunc(key) ) {
516
565
  return this.sortFunc(value, key);
@@ -529,10 +578,10 @@ export class PicoArray
529
578
  * @example Arr.sortFunc([2,1], (a,b)=>a-b) // => [1,2]
530
579
  *
531
580
  * @param {any} value Input list
532
- * @param {function} cb Compare callback
581
+ * @param {Function} cb Compare callback
533
582
  * @returns {Array<any>} Sorted list
534
583
  */
535
- static sortFunc(value, cb)
584
+ static sortFunc(value : any, cb : Function) : Array<any>
536
585
  {
537
586
  let keys = Mix.keys(value).sort((a, b) => {
538
587
  return cb.call({}, value[a], value[b]);
@@ -556,9 +605,9 @@ export class PicoArray
556
605
  * @param {any} key Key path
557
606
  * @returns {Array<any>} Sorted list
558
607
  */
559
- static sortDeep(value, key)
608
+ static sortDeep(value : any, key : any) : Array<any>
560
609
  {
561
- let fn = (val) => {
610
+ let fn = (val : any) => {
562
611
  return Obj.get(val, key);
563
612
  }
564
613
 
@@ -583,7 +632,7 @@ export class PicoArray
583
632
  * @param {any} value Input list
584
633
  * @returns {Array<any>} Sorted list
585
634
  */
586
- static sortPrim(value)
635
+ static sortPrim(value : any) : Array<any>
587
636
  {
588
637
  let keys = Mix.keys(value).sort((a, b) => {
589
638
  return Mix.compare(a, b);
@@ -603,11 +652,11 @@ export class PicoArray
603
652
  *
604
653
  * @example Arr.merge([1],[2]) // => [1,2]
605
654
  *
606
- * @param {Array<any>} value Base array
607
- * @param {...any} args Arrays to add
655
+ * @param {any[]} value Base array
656
+ * @param {[...any[]]} args Arrays to add
608
657
  * @returns {Array<any>} Merged array
609
658
  */
610
- static merge(value, ...args)
659
+ static merge(value : any[], ...args : [...any[]]) : Array<any>
611
660
  {
612
661
  return value.concat(...args);
613
662
  }
@@ -617,11 +666,11 @@ export class PicoArray
617
666
  *
618
667
  * @example Arr.prepend([2], 1) // => [1,2]
619
668
  *
620
- * @param {Array<any>} value Target array
621
- * @param {...any} args Items to add
669
+ * @param {any[]} value Target array
670
+ * @param {[...any[]]} args Items to add
622
671
  * @returns {Array<any>} Mutated array
623
672
  */
624
- static prepend(value, ...args)
673
+ static prepend(value : any[], ...args : [...any[]]) : Array<any>
625
674
  {
626
675
  return (value.unshift(...args), value);
627
676
  }
@@ -631,11 +680,11 @@ export class PicoArray
631
680
  *
632
681
  * @example Arr.append([1], 2) // => [1,2]
633
682
  *
634
- * @param {Array<any>} value Target array
635
- * @param {...any} args Items to add
683
+ * @param {any[]} value Target array
684
+ * @param {[...any[]]} args Items to add
636
685
  * @returns {Array<any>} Mutated array
637
686
  */
638
- static append(value, ...args)
687
+ static append(value : any[], ...args : [...any[]]) : Array<any>
639
688
  {
640
689
  return (value.push(...args), value);
641
690
  }
@@ -645,18 +694,18 @@ export class PicoArray
645
694
  *
646
695
  * @example Arr.add([1], 2) // => [1,2]
647
696
  *
648
- * @param {Array<any>} value Target array
697
+ * @param {any[]} value Target array
649
698
  * @param {any} target Item to add
650
699
  * @param {any} [finder] Finder value
651
700
  * @returns {Array<any>} Mutated array
652
701
  */
653
- static add(value, target, finder = null)
702
+ static add(value : any[], target : any, finder : any = null) : Array<any>
654
703
  {
655
704
  if ( finder == null ) {
656
705
  finder = target;
657
706
  }
658
707
 
659
- if ( this.findIndex(value, finder) !== - 1 ) {
708
+ if ( this.findIndex(value, finder) !== -1 ) {
660
709
  return value;
661
710
  }
662
711
 
@@ -668,12 +717,12 @@ export class PicoArray
668
717
  *
669
718
  * @example Arr.replace([1], 2) // => [1,2]
670
719
  *
671
- * @param {Array<any>} value Target array
720
+ * @param {any[]} value Target array
672
721
  * @param {any} target Item to add
673
722
  * @param {any} [finder] Finder value
674
723
  * @returns {Array<any>} Mutated array
675
724
  */
676
- static replace(value, target, finder = null)
725
+ static replace(value : any[], target : any, finder : any = null) : Array<any>
677
726
  {
678
727
  if ( finder == null ) {
679
728
  finder = target;
@@ -681,7 +730,7 @@ export class PicoArray
681
730
 
682
731
  let index = this.findIndex(value, finder);
683
732
 
684
- if ( index !== - 1 ) {
733
+ if ( index !== -1 ) {
685
734
  this.splice(value, index, 1);
686
735
  }
687
736
 
@@ -693,12 +742,12 @@ export class PicoArray
693
742
  *
694
743
  * @example Arr.remove([1,2], 1) // => [2]
695
744
  *
696
- * @param {Array<any>} value Target array
745
+ * @param {any[]} value Target array
697
746
  * @param {any} target Item to remove
698
747
  * @param {any} [finder] Finder value
699
748
  * @returns {Array<any>} Mutated array
700
749
  */
701
- static remove(value, target, finder = null)
750
+ static remove(value : any[], target : any, finder : any = null) : Array<any>
702
751
  {
703
752
  if ( finder == null ) {
704
753
  finder = target;
@@ -706,7 +755,7 @@ export class PicoArray
706
755
 
707
756
  let index = this.findIndex(value, finder);
708
757
 
709
- if ( index === - 1 ) {
758
+ if ( index === -1 ) {
710
759
  return value;
711
760
  }
712
761
 
@@ -719,12 +768,12 @@ export class PicoArray
719
768
  * @example Arr.toggle([1], 1) // => []
720
769
  * @example Arr.toggle([], 1) // => [1]
721
770
  *
722
- * @param {Array<any>} value Target array
771
+ * @param {any[]} value Target array
723
772
  * @param {any} target Item to toggle
724
773
  * @param {any} [finder] Finder value
725
774
  * @returns {Array<any>} Mutated array
726
775
  */
727
- static toggle(value, target, finder = null)
776
+ static toggle(value : any[], target : any, finder : any = null) : Array<any>
728
777
  {
729
778
  if ( finder == null ) {
730
779
  finder = target;
@@ -732,7 +781,7 @@ export class PicoArray
732
781
 
733
782
  let index = this.findIndex(value, finder);
734
783
 
735
- if ( index === - 1 ) {
784
+ if ( index === -1 ) {
736
785
  return (value.push(target), value);
737
786
  }
738
787
 
@@ -744,12 +793,12 @@ export class PicoArray
744
793
  *
745
794
  * @example Arr.insert([1,3], 1, 2) // => [1,2,3]
746
795
  *
747
- * @param {Array<any>} value Target array
796
+ * @param {any[]} value Target array
748
797
  * @param {number} index Insert index
749
798
  * @param {any} target Item to insert
750
799
  * @returns {Array<any>} Mutated array
751
800
  */
752
- static insert(value, index, target)
801
+ static insert(value : any[], index : number, target : any) : Array<any>
753
802
  {
754
803
  return (this.splice(value, index, 0, target), value);
755
804
  }
@@ -759,14 +808,14 @@ export class PicoArray
759
808
  *
760
809
  * @example Arr.slice([1,2,3], 1, 2) // => [2,3]
761
810
  *
762
- * @param {Array<any>} value Source array
763
- * @param {number} index Start index
811
+ * @param {any[]} value Source array
812
+ * @param {any} index Start index
764
813
  * @param {number} [length] Slice length
765
814
  * @returns {Array<any>} Sliced array
766
815
  */
767
- static slice(value, index, length = 1)
816
+ static slice(value : any[], index : any, length : number = 1) : Array<any>
768
817
  {
769
- return value.slice(parseInt(index), length);
818
+ return value.slice(Mix.num(index), length);
770
819
  }
771
820
 
772
821
  /**
@@ -774,15 +823,15 @@ export class PicoArray
774
823
  *
775
824
  * @example Arr.splice([1,2], 0, 1) // => [1]
776
825
  *
777
- * @param {Array<any>} value Target array
778
- * @param {number} index Start index
826
+ * @param {any[]} value Target array
827
+ * @param {any} index Start index
779
828
  * @param {number} [length] Remove count
780
- * @param {...any} args Items to add
781
- * @returns {any} Splice result
829
+ * @param {[...any]} args Items to add
830
+ * @returns {Array<any>} Splice result
782
831
  */
783
- static splice(value, index, length = 1, ...args)
832
+ static splice(value : any[], index : any, length : number = 1, ...args : [...any]) : Array<any>
784
833
  {
785
- return value.splice(parseInt(index), length, ...args);
834
+ return value.splice(Mix.num(index), length, ...args);
786
835
  }
787
836
 
788
837
  /**
@@ -790,14 +839,14 @@ export class PicoArray
790
839
  *
791
840
  * @example Arr.splices([1,2,3],[0,2]) // => [2]
792
841
  *
793
- * @param {Array<any>} value Target array
794
- * @param {Array<number>} indexies Index list
842
+ * @param {any[]} value Target array
843
+ * @param {any[]} indexies Index list
795
844
  * @param {number} [length] Remove count
796
845
  * @returns {Array<any>} Mutated array
797
846
  */
798
- static splices(value, indexies, length = 1)
847
+ static splices(value : any[], indexies : any[], length : number = 1) : Array<any>
799
848
  {
800
- this.each(indexies, (index) => {
849
+ this.each(indexies, (index : number) => {
801
850
  this.splice(value, index, length);
802
851
  });
803
852
 
@@ -812,7 +861,7 @@ export class PicoArray
812
861
  * @param {any} value Value to clone
813
862
  * @returns {any} Cloned value
814
863
  */
815
- static clone(value)
864
+ static clone(value : any) : any
816
865
  {
817
866
  if ( Mix.isPrim(value) ) {
818
867
  return value;
@@ -828,7 +877,7 @@ export class PicoArray
828
877
 
829
878
  let result = new Array(value.length);
830
879
 
831
- for ( let i = 0; i < value.length; i ++ ) {
880
+ for ( let i = 0; i < value.length; i++ ) {
832
881
  result[i] = this.clone(value[i]);
833
882
  }
834
883
 
@@ -840,45 +889,55 @@ export class PicoArray
840
889
  *
841
890
  * @example Arr.diff([1,2],[2]) // => [1]
842
891
  *
843
- * @param {...Array<any>} args Arrays to diff
892
+ * @param {[...any[]]} args Arrays to diff
844
893
  * @returns {Array<any>} Difference list
845
894
  */
846
- static diff(...args)
895
+ static diff(...args : [...any[]]) : Array<any>
847
896
  {
848
897
  return args.reduce((a, c) => {
849
- return a.filter(i => !c.includes(i))
898
+ return a.filter((i : any) => !c.includes(i))
850
899
  });
851
900
  }
852
901
 
902
+ /**
903
+ * @see PicoArray.diff
904
+ */
905
+ static diffrence = PicoArray.diff;
906
+
853
907
  /**
854
908
  * Get intersecting items
855
909
  *
856
910
  * @example Arr.isect([1,2],[2,3]) // => [2]
857
911
  *
858
- * @param {...Array<any>} args Arrays to intersect
912
+ * @param {[...any[]]} args Arrays to intersect
859
913
  * @returns {Array<any>} Intersection list
860
914
  */
861
- static isect(...args)
915
+ static isect(...args : [...any[]]) : Array<any>
862
916
  {
863
917
  return args.reduce((a, c) => {
864
- return a.filter(i => c.includes(i))
918
+ return a.filter((i : any) => c.includes(i))
865
919
  });
866
920
  }
867
921
 
922
+ /**
923
+ * @see PicoArray.diff
924
+ */
925
+ static intersect = PicoArray.isect;
926
+
868
927
  /**
869
928
  * Extract property values from list
870
929
  *
871
930
  * @example Arr.extract([{id:1}], "id") // => [1]
872
931
  *
873
- * @param {Array<any>} value Input list
932
+ * @param {any[]} value Input list
874
933
  * @param {any} key Key path
875
934
  * @returns {Array<any>} Extracted list
876
935
  */
877
- static extract(value, key)
936
+ static extract(value : any, key : any) : Array<any>
878
937
  {
879
938
  let result = new Array(value.length);
880
939
 
881
- for ( let i = 0; i < value.length; i ++ ) {
940
+ for ( let i = 0; i < value.length; i++ ) {
882
941
  result[i] = Obj.get(value[i], key);
883
942
  }
884
943
 
@@ -891,12 +950,13 @@ export class PicoArray
891
950
  * @example Arr.reduce([1,2], (a,c)=>a+c, 0) // => 3
892
951
  *
893
952
  * @param {any} value Input list
894
- * @param {function} callback Reducer callback
953
+ * @param {Function} callback Reducer callback
895
954
  * @param {any} accumulator Start value
896
955
  * @returns {any} Reduced value
897
956
  */
898
- static reduce(value, callback, accumulator)
957
+ static reduce(value : any, callback : Function, accumulator : any) : any
899
958
  {
959
+ // @ts-ignore
900
960
  return Mix.vals(value).reduce(callback, accumulator);
901
961
  }
902
962
 
@@ -905,11 +965,11 @@ export class PicoArray
905
965
  *
906
966
  * @example Arr.chunk([1,2,3], 2) // => [[1,2],[3]]
907
967
  *
908
- * @param {Array<any>} value Source array
968
+ * @param {any[]} value Source array
909
969
  * @param {number} [chunk] Chunk size
910
- * @returns {Array<Array<any>>} Chunked list
970
+ * @returns {Array<any[]>} Chunked list
911
971
  */
912
- static chunk(value, chunk = 10)
972
+ static chunk(value : any[], chunk : number = 10) : Array<any[]>
913
973
  {
914
974
  let res = [];
915
975
 
@@ -930,7 +990,7 @@ export class PicoArray
930
990
  * @param {any} search Search spec
931
991
  * @returns {boolean} True if includes
932
992
  */
933
- static includes(value, search)
993
+ static includes(value : any, search : any) : boolean
934
994
  {
935
995
  if ( Mix.isObj(search) ) {
936
996
  return Obj.includes(value, search);
@@ -948,7 +1008,7 @@ export class PicoArray
948
1008
  return true;
949
1009
  }
950
1010
 
951
- for ( let i = 0; result === false && i < length; i ++ ) {
1011
+ for ( let i = 0; result === false && i < length; i++ ) {
952
1012
  result ||= this.has(value, search[i]);
953
1013
  }
954
1014
 
@@ -964,12 +1024,12 @@ export class PicoArray
964
1024
  * @param {any} val Required values
965
1025
  * @returns {boolean} True if contains
966
1026
  */
967
- static contains(arr, val)
1027
+ static contains(arr : any, val : any) : boolean
968
1028
  {
969
1029
  let result = true;
970
1030
 
971
1031
  for ( let key of Mix.vals(val) ) {
972
- result &&= Mix.vals(arr).indexOf(key) !== - 1;
1032
+ result &&= Mix.vals(arr).indexOf(key) !== -1;
973
1033
  }
974
1034
 
975
1035
  return result;
@@ -984,7 +1044,7 @@ export class PicoArray
984
1044
  * @param {any} search Search spec
985
1045
  * @returns {boolean} True if matches
986
1046
  */
987
- static matches(value, search)
1047
+ static matches(value : any, search : any) : boolean
988
1048
  {
989
1049
  if ( Mix.isObj(search) ) {
990
1050
  return Obj.matches(value, search);
@@ -1004,7 +1064,7 @@ export class PicoArray
1004
1064
  return false;
1005
1065
  }
1006
1066
 
1007
- for ( let i = 0; result === true && i < length; i ++ ) {
1067
+ for ( let i = 0; result === true && i < length; i++ ) {
1008
1068
  result &&= this.has(value, search[i]);
1009
1069
  }
1010
1070
 
@@ -1013,60 +1073,35 @@ export class PicoArray
1013
1073
 
1014
1074
  }
1015
1075
 
1016
- /**
1017
- * @see PicoArray.unset
1018
- */
1019
- PicoArray.removeIndex = function (...args) {
1076
+ // @ts-ignore
1077
+ PicoArray.removeIndex = function (...args : Parameters<typeof PicoArray.splice>) {
1020
1078
  console.warn('Arr.removeIndex() is deprecated, use Arr.unset() instead.');
1021
1079
  return this.unset(...args);
1022
1080
  };
1023
1081
 
1024
- /**
1025
- * @see PicoArray.sortPrim
1026
- */
1027
- PicoArray.sortString = function (...args) {
1082
+ // @ts-ignore
1083
+ PicoArray.sortString = function (...args : Parameters<typeof PicoArray.sortPrim>) {
1028
1084
  console.warn('Arr.sortString() is deprecated, use Arr.sortPrim() instead.');
1029
1085
  return this.sortPrim(...args);
1030
1086
  };
1031
1087
 
1032
- /**
1033
- * @see PicoArray.append
1034
- */
1035
- PicoArray.push = function (...args) {
1088
+ // @ts-ignore
1089
+ PicoArray.push = function (...args : Parameters<typeof PicoArray.append>) {
1036
1090
  console.warn('Arr.push() is deprecated, use Arr.append() instead.');
1037
1091
  return this.append(...args);
1038
1092
  };
1039
1093
 
1040
- /**
1041
- * @see PicoArray.merge
1042
- */
1043
- PicoArray.concat = function (...args) {
1094
+ // @ts-ignore
1095
+ PicoArray.concat = function (...args : Parameters<typeof PicoArray.merge>) {
1044
1096
  console.warn('Arr.concat() is deprecated, use Arr.merge() instead.');
1045
1097
  return this.merge(...args);
1046
1098
  };
1047
1099
 
1048
- /**
1049
- * @see PicoArray.matches
1050
- */
1051
- PicoArray.equal = function (...args) {
1100
+ // @ts-ignore
1101
+ PicoArray.equal = function (...args : Parameters<typeof PicoArray.matches>) {
1052
1102
  console.warn('Arr.equal() is deprecated, use Arr.matches() instead.');
1053
1103
  return this.matches(...args);
1054
1104
  };
1055
1105
 
1056
- /**
1057
- * @see PicoArray.diff
1058
- */
1059
- PicoArray.diffrence = function (...args) {
1060
- console.warn('Arr.diffrence() is deprecated, use Arr.diff() instead.');
1061
- return this.diff(...args);
1062
- };
1063
-
1064
- /**
1065
- * @see PicoArray.isect
1066
- */
1067
- PicoArray.intersect = function (...args) {
1068
- console.warn('Arr.intersect() is deprecated, use Arr.isect() instead.');
1069
- return this.isect(...args);
1070
- };
1071
1106
 
1072
1107
  export default PicoArray;