@kizmann/pico-js 2.0.8 → 2.0.10

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} +74 -78
  9. package/src/dom/{DomFinder.js → DomFinder.ts} +89 -129
  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} +67 -88
  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} +146 -160
  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} +22 -22
  39. package/src/utils/{Mixed.js → Mixed.ts} +70 -58
  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} +65 -47
  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} +131 -101
  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 -25
  52. package/types/dom/DomFinder.d.ts +35 -58
  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 -40
  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 -104
  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 +10 -10
  81. package/types/utils/Mixed.d.ts +18 -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 +41 -24
  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,29 +61,29 @@ 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, index, fallback = 0)
73
+ static prev(target : any, index : number) : number
74
74
  {
75
75
  if ( Mix.isEmpty(target) || !Mix.isArr(target) ) {
76
76
  return 0;
77
77
  }
78
78
 
79
79
  if ( index - 1 < 0 ) {
80
- return target.length-1;
80
+ return target.length - 1;
81
81
  }
82
82
 
83
83
  return index - 1;
84
84
  }
85
85
 
86
- static next(target, index, fallback = 0)
86
+ static next(target : any, index : number) : number
87
87
  {
88
88
  if ( Mix.isEmpty(target) || !Mix.isArr(target) ) {
89
89
  return 0;
@@ -106,7 +106,7 @@ export class PicoArray
106
106
  * @param {any} [cb] Value or mapper
107
107
  * @returns {Array<any>} Generated array
108
108
  */
109
- static make(length, cb = null)
109
+ static make(length : number, cb : any = null) : Array<any>
110
110
  {
111
111
  let result = new Array(length);
112
112
 
@@ -114,7 +114,7 @@ export class PicoArray
114
114
  cb = (i) => i;
115
115
  }
116
116
 
117
- for ( let i = 0; i < length; i ++ ) {
117
+ for ( let i = 0; i < length; i++ ) {
118
118
  result[i] = typeof cb === 'function' ? cb(i) : cb;
119
119
  }
120
120
 
@@ -131,10 +131,10 @@ export class PicoArray
131
131
  * @param {any} search Search value
132
132
  * @returns {boolean} True if found
133
133
  */
134
- static has(value, search)
134
+ static has(value : any, search : any) : boolean
135
135
  {
136
136
  if ( !Mix.isPrim(search) ) {
137
- return this.findIndex(value, search) !== - 1;
137
+ return this.findIndex(value, search) !== -1;
138
138
  }
139
139
 
140
140
  if ( !Mix.isRef(value) ) {
@@ -145,11 +145,11 @@ export class PicoArray
145
145
  value = Mix.vals(value);
146
146
  }
147
147
 
148
- let index = value.findIndex((val) => {
148
+ let index = value.findIndex((val : any) => {
149
149
  return val == search;
150
150
  });
151
151
 
152
- return index !== - 1;
152
+ return index !== -1;
153
153
  }
154
154
 
155
155
  /**
@@ -157,10 +157,10 @@ export class PicoArray
157
157
  *
158
158
  * @example Arr.unique(["a","a"]) // => ["a"]
159
159
  *
160
- * @param {Array<any>} value Input list
160
+ * @param {any[]} value Input list
161
161
  * @returns {Array<any>} Unique list
162
162
  */
163
- static unique(value)
163
+ static unique(value : any[]) : Array<any>
164
164
  {
165
165
  let buffer = {};
166
166
 
@@ -176,15 +176,15 @@ export class PicoArray
176
176
  *
177
177
  * @example Arr.lengths([1],[2]) // => true
178
178
  *
179
- * @param {Array<any>} value Base array
180
- * @param {...Array<any>} args Other arrays
179
+ * @param {any[]} value Base array
180
+ * @param {[...any[]]} args Other arrays
181
181
  * @returns {boolean} True if equal
182
182
  */
183
- static lengths(value, ...args)
183
+ static lengths(value : any[], ...args : [...any[]]) : boolean
184
184
  {
185
185
  let length = value.length;
186
186
 
187
- for ( let i = 0; i < args.length; i ++ ) {
187
+ for ( let i = 0; i < args.length; i++ ) {
188
188
  if ( args[i].length !== length ) {
189
189
  return false;
190
190
  }
@@ -198,11 +198,11 @@ export class PicoArray
198
198
  *
199
199
  * @example Arr.first([1,2]) // => 1
200
200
  *
201
- * @param {Array<any>} value Input array
201
+ * @param {any} value Input array
202
202
  * @param {any} [fallback] Fallback value
203
203
  * @returns {any} First item
204
204
  */
205
- static first(value, fallback = null)
205
+ static first(value : any, fallback : any = null) : any
206
206
  {
207
207
  return this.get(value, 0, fallback);
208
208
  }
@@ -212,11 +212,11 @@ export class PicoArray
212
212
  *
213
213
  * @example Arr.second([1,2]) // => 2
214
214
  *
215
- * @param {Array<any>} value Input array
215
+ * @param {any} value Input array
216
216
  * @param {any} [fallback] Fallback value
217
217
  * @returns {any} Second item
218
218
  */
219
- static second(value, fallback = null)
219
+ static second(value : any, fallback : any = null) : any
220
220
  {
221
221
  return this.get(value, 2, fallback);
222
222
  }
@@ -226,11 +226,11 @@ export class PicoArray
226
226
  *
227
227
  * @example Arr.third([1,2,3]) // => 3
228
228
  *
229
- * @param {Array<any>} value Input array
229
+ * @param {any} value Input array
230
230
  * @param {any} [fallback] Fallback value
231
231
  * @returns {any} Third item
232
232
  */
233
- static third(value, fallback = null)
233
+ static third(value : any, fallback : any = null) : any
234
234
  {
235
235
  return this.get(value, 2, fallback);
236
236
  }
@@ -240,11 +240,11 @@ export class PicoArray
240
240
  *
241
241
  * @example Arr.last([1,2]) // => 2
242
242
  *
243
- * @param {Array<any>} value Input array
243
+ * @param {any} value Input array
244
244
  * @param {any} [fallback] Fallback value
245
245
  * @returns {any} Last item
246
246
  */
247
- static last(value, fallback = null)
247
+ static last(value : any, fallback : any = null) : any
248
248
  {
249
249
  return this.get(value, value.length - 1, fallback);
250
250
  }
@@ -255,11 +255,11 @@ export class PicoArray
255
255
  * @example Arr.each([1], v => v+1) // => [2]
256
256
  *
257
257
  * @param {any} value Input list
258
- * @param {function} cb Map callback
258
+ * @param {Function} cb Map callback
259
259
  * @param {any} [retval] Forced return
260
260
  * @returns {any} Mapped array
261
261
  */
262
- static each(value, cb, retval = null)
262
+ static each(value : any, cb : Function, retval : any = null) : any
263
263
  {
264
264
  if ( Mix.isObj(value) ) {
265
265
  return this.eachObj(value, cb, retval);
@@ -271,7 +271,7 @@ export class PicoArray
271
271
 
272
272
  let result = new Array(value.length);
273
273
 
274
- for ( let i = 0; i < value.length; i ++ ) {
274
+ for ( let i = 0; i < value.length; i++ ) {
275
275
  result[i] = cb(value[i], i);
276
276
  }
277
277
 
@@ -284,11 +284,11 @@ export class PicoArray
284
284
  * @example Arr.eachObj({a:1}, (v,k) => v+1) // => [2]
285
285
  *
286
286
  * @param {any} value Input object
287
- * @param {function} cb Iterate callback
287
+ * @param {Function} cb Iterate callback
288
288
  * @param {any} [retval] Return value override
289
289
  * @returns {any} Mapped values or retval
290
290
  */
291
- static eachObj(value, cb, retval = null)
291
+ static eachObj(value : any, cb : Function, retval : any = null) : any
292
292
  {
293
293
  if ( Mix.isArr(value) ) {
294
294
  return this.each(value, cb, retval);
@@ -311,16 +311,16 @@ export class PicoArray
311
311
  * @example Arr.map([1], v => v+1) // => [2]
312
312
  *
313
313
  * @param {any} value Input list
314
- * @param {function} cb Map callback
314
+ * @param {Function} cb Map callback
315
315
  * @returns {any} Mutated input
316
316
  */
317
- static map(value, cb)
317
+ static map(value : any, cb : Function) : any
318
318
  {
319
319
  let [isArr, keys] = [
320
320
  Mix.isArr(value), Mix.keys(value)
321
321
  ];
322
322
 
323
- let fn = (key) => {
323
+ let fn = (key : any) => {
324
324
  return isArr ? parseInt(key) : key;
325
325
  };
326
326
 
@@ -338,14 +338,14 @@ export class PicoArray
338
338
  *
339
339
  * @param {any} value Input list
340
340
  * @param {string} key Child key
341
- * @param {function} cb Node callback
342
- * @param {Array<any>} [cascade] Parent chain
341
+ * @param {Function} cb Node callback
342
+ * @param {any[]} [cascade] Parent chain
343
343
  * @returns {any} Mapped tree
344
344
  */
345
- static recursive(value, key, cb, cascade = [])
345
+ static recursive(value : any, key : string, cb : Function, cascade : any[] = []) : any
346
346
  {
347
347
  // NIE WIEDER ANFASSEN !!!
348
- let fn = (cas) => (val) => {
348
+ let fn = (cas : any) => (val : any) => {
349
349
  return this.recursive(val, key, cb, cas);
350
350
  };
351
351
 
@@ -376,24 +376,24 @@ export class PicoArray
376
376
  return value;
377
377
  }
378
378
 
379
- static cascade(value, childs, key, cascade = [], result = {})
379
+ static cascade(value : any, childs : string, key : string, cascade : any[] = [], result : any = {}) : any
380
380
  {
381
381
  if ( value == null ) {
382
382
  return result;
383
383
  }
384
384
 
385
385
  if ( Mix.isObj(value) ) {
386
- return this.cascade(value[key], key, cb);
386
+ return this.cascade(value[key], childs, key);
387
387
  }
388
388
 
389
- const fn = (val) => {
389
+ const fn = (val : any) => {
390
390
  return this.cascade(...[
391
391
  val[childs], childs, key, result[val[key]], result
392
392
  ]);
393
393
  };
394
394
 
395
- this.each(value, (val) => {
396
- (result[val[key]] = [...cascade, val[key] ], fn(val));
395
+ this.each(value, (val : any) => {
396
+ (result[val[key]] = [...cascade, val[key]], fn(val));
397
397
  });
398
398
 
399
399
  return result;
@@ -406,16 +406,16 @@ export class PicoArray
406
406
  *
407
407
  * @param {any} value Input list
408
408
  * @param {any} [filter] Filter spec
409
- * @returns {Array<string>} Matching keys
409
+ * @returns {Array<any>} Matching keys
410
410
  */
411
- static filterIndex(value, filter = null)
411
+ static filterIndex(value : any, filter : any = null) : Array<any>
412
412
  {
413
413
  if ( value == null ) {
414
414
  return [];
415
415
  }
416
416
 
417
417
  if ( filter == null ) {
418
- filter = (val) => !Mix.isEmpty(val);
418
+ filter = (val : any) => !Mix.isEmpty(val);
419
419
  }
420
420
 
421
421
  return Mix.keys(value).filter((key) => {
@@ -441,7 +441,7 @@ export class PicoArray
441
441
  * @param {any} [filter] Filter spec
442
442
  * @returns {any} Mutated list
443
443
  */
444
- static filterRemove(value, filter = null)
444
+ static filterRemove(value : any, filter : any = null) : any
445
445
  {
446
446
  if ( value == null ) {
447
447
  return value;
@@ -465,14 +465,14 @@ export class PicoArray
465
465
  * @param {any} [filter] Filter spec
466
466
  * @returns {Array<any>} Filtered values
467
467
  */
468
- static filter(value, filter = null)
468
+ static filter(value : any, filter : any = null) : Array<any>
469
469
  {
470
470
  if ( value == null ) {
471
471
  return [];
472
472
  }
473
473
 
474
474
  if ( filter == null ) {
475
- filter = (val) => !Mix.isEmpty(val);
475
+ filter = (val : any) => !Mix.isEmpty(val);
476
476
  }
477
477
 
478
478
  return Mix.vals(value).filter((val, key) => {
@@ -494,22 +494,22 @@ export class PicoArray
494
494
  *
495
495
  * @example Arr.findIndex([1,2], 2) // => 1
496
496
  *
497
- * @param {Array<any>} value Input array
497
+ * @param {any} value Input array
498
498
  * @param {any} [filter] Filter spec
499
499
  * @param {number} [fallback] Fallback index
500
500
  * @returns {number} Found index
501
501
  */
502
- static findIndex(value, filter = null, fallback = - 1)
502
+ static findIndex(value : any, filter : any = null, fallback : number = -1) : number
503
503
  {
504
504
  if ( value == null ) {
505
505
  return fallback;
506
506
  }
507
507
 
508
508
  if ( filter == null ) {
509
- filter = (val) => !Mix.isEmpty(val);
509
+ filter = (val : any) => !Mix.isEmpty(val);
510
510
  }
511
511
 
512
- for ( let i = 0; i < value.length; i ++ ) {
512
+ for ( let i = 0; i < value.length; i++ ) {
513
513
 
514
514
  if ( Mix.isFunc(filter) ) {
515
515
  if ( filter.call({}, value[i], i) ) {
@@ -534,16 +534,16 @@ export class PicoArray
534
534
  *
535
535
  * @example Arr.find([1,2], 2) // => 2
536
536
  *
537
- * @param {Array<any>} value Input array
537
+ * @param {any} value Input array
538
538
  * @param {any} [filter] Filter spec
539
539
  * @param {any} [fallback] Fallback value
540
540
  * @returns {any} Found value
541
541
  */
542
- static find(value, filter = null, fallback = null)
542
+ static find(value : any, filter : any = null, fallback : any = null) : any
543
543
  {
544
544
  let index = this.findIndex(value, filter);
545
545
 
546
- if ( index === - 1 ) {
546
+ if ( index === -1 ) {
547
547
  return fallback;
548
548
  }
549
549
 
@@ -559,7 +559,7 @@ export class PicoArray
559
559
  * @param {any} [key] Key or compare fn
560
560
  * @returns {Array<any>} Sorted list
561
561
  */
562
- static sort(value, key = null)
562
+ static sort(value : any, key : any = null) : Array<any>
563
563
  {
564
564
  if ( Mix.isFunc(key) ) {
565
565
  return this.sortFunc(value, key);
@@ -578,10 +578,10 @@ export class PicoArray
578
578
  * @example Arr.sortFunc([2,1], (a,b)=>a-b) // => [1,2]
579
579
  *
580
580
  * @param {any} value Input list
581
- * @param {function} cb Compare callback
581
+ * @param {Function} cb Compare callback
582
582
  * @returns {Array<any>} Sorted list
583
583
  */
584
- static sortFunc(value, cb)
584
+ static sortFunc(value : any, cb : Function) : Array<any>
585
585
  {
586
586
  let keys = Mix.keys(value).sort((a, b) => {
587
587
  return cb.call({}, value[a], value[b]);
@@ -605,9 +605,9 @@ export class PicoArray
605
605
  * @param {any} key Key path
606
606
  * @returns {Array<any>} Sorted list
607
607
  */
608
- static sortDeep(value, key)
608
+ static sortDeep(value : any, key : any) : Array<any>
609
609
  {
610
- let fn = (val) => {
610
+ let fn = (val : any) => {
611
611
  return Obj.get(val, key);
612
612
  }
613
613
 
@@ -632,7 +632,7 @@ export class PicoArray
632
632
  * @param {any} value Input list
633
633
  * @returns {Array<any>} Sorted list
634
634
  */
635
- static sortPrim(value)
635
+ static sortPrim(value : any) : Array<any>
636
636
  {
637
637
  let keys = Mix.keys(value).sort((a, b) => {
638
638
  return Mix.compare(a, b);
@@ -652,11 +652,11 @@ export class PicoArray
652
652
  *
653
653
  * @example Arr.merge([1],[2]) // => [1,2]
654
654
  *
655
- * @param {Array<any>} value Base array
656
- * @param {...any} args Arrays to add
655
+ * @param {any[]} value Base array
656
+ * @param {[...any[]]} args Arrays to add
657
657
  * @returns {Array<any>} Merged array
658
658
  */
659
- static merge(value, ...args)
659
+ static merge(value : any[], ...args : [...any[]]) : Array<any>
660
660
  {
661
661
  return value.concat(...args);
662
662
  }
@@ -666,11 +666,11 @@ export class PicoArray
666
666
  *
667
667
  * @example Arr.prepend([2], 1) // => [1,2]
668
668
  *
669
- * @param {Array<any>} value Target array
670
- * @param {...any} args Items to add
669
+ * @param {any[]} value Target array
670
+ * @param {[...any[]]} args Items to add
671
671
  * @returns {Array<any>} Mutated array
672
672
  */
673
- static prepend(value, ...args)
673
+ static prepend(value : any[], ...args : [...any[]]) : Array<any>
674
674
  {
675
675
  return (value.unshift(...args), value);
676
676
  }
@@ -680,11 +680,11 @@ export class PicoArray
680
680
  *
681
681
  * @example Arr.append([1], 2) // => [1,2]
682
682
  *
683
- * @param {Array<any>} value Target array
684
- * @param {...any} args Items to add
683
+ * @param {any[]} value Target array
684
+ * @param {[...any[]]} args Items to add
685
685
  * @returns {Array<any>} Mutated array
686
686
  */
687
- static append(value, ...args)
687
+ static append(value : any[], ...args : [...any[]]) : Array<any>
688
688
  {
689
689
  return (value.push(...args), value);
690
690
  }
@@ -694,18 +694,18 @@ export class PicoArray
694
694
  *
695
695
  * @example Arr.add([1], 2) // => [1,2]
696
696
  *
697
- * @param {Array<any>} value Target array
697
+ * @param {any[]} value Target array
698
698
  * @param {any} target Item to add
699
699
  * @param {any} [finder] Finder value
700
700
  * @returns {Array<any>} Mutated array
701
701
  */
702
- static add(value, target, finder = null)
702
+ static add(value : any[], target : any, finder : any = null) : Array<any>
703
703
  {
704
704
  if ( finder == null ) {
705
705
  finder = target;
706
706
  }
707
707
 
708
- if ( this.findIndex(value, finder) !== - 1 ) {
708
+ if ( this.findIndex(value, finder) !== -1 ) {
709
709
  return value;
710
710
  }
711
711
 
@@ -717,12 +717,12 @@ export class PicoArray
717
717
  *
718
718
  * @example Arr.replace([1], 2) // => [1,2]
719
719
  *
720
- * @param {Array<any>} value Target array
720
+ * @param {any[]} value Target array
721
721
  * @param {any} target Item to add
722
722
  * @param {any} [finder] Finder value
723
723
  * @returns {Array<any>} Mutated array
724
724
  */
725
- static replace(value, target, finder = null)
725
+ static replace(value : any[], target : any, finder : any = null) : Array<any>
726
726
  {
727
727
  if ( finder == null ) {
728
728
  finder = target;
@@ -730,7 +730,7 @@ export class PicoArray
730
730
 
731
731
  let index = this.findIndex(value, finder);
732
732
 
733
- if ( index !== - 1 ) {
733
+ if ( index !== -1 ) {
734
734
  this.splice(value, index, 1);
735
735
  }
736
736
 
@@ -742,12 +742,12 @@ export class PicoArray
742
742
  *
743
743
  * @example Arr.remove([1,2], 1) // => [2]
744
744
  *
745
- * @param {Array<any>} value Target array
745
+ * @param {any[]} value Target array
746
746
  * @param {any} target Item to remove
747
747
  * @param {any} [finder] Finder value
748
748
  * @returns {Array<any>} Mutated array
749
749
  */
750
- static remove(value, target, finder = null)
750
+ static remove(value : any[], target : any, finder : any = null) : Array<any>
751
751
  {
752
752
  if ( finder == null ) {
753
753
  finder = target;
@@ -755,7 +755,7 @@ export class PicoArray
755
755
 
756
756
  let index = this.findIndex(value, finder);
757
757
 
758
- if ( index === - 1 ) {
758
+ if ( index === -1 ) {
759
759
  return value;
760
760
  }
761
761
 
@@ -768,12 +768,12 @@ export class PicoArray
768
768
  * @example Arr.toggle([1], 1) // => []
769
769
  * @example Arr.toggle([], 1) // => [1]
770
770
  *
771
- * @param {Array<any>} value Target array
771
+ * @param {any[]} value Target array
772
772
  * @param {any} target Item to toggle
773
773
  * @param {any} [finder] Finder value
774
774
  * @returns {Array<any>} Mutated array
775
775
  */
776
- static toggle(value, target, finder = null)
776
+ static toggle(value : any[], target : any, finder : any = null) : Array<any>
777
777
  {
778
778
  if ( finder == null ) {
779
779
  finder = target;
@@ -781,7 +781,7 @@ export class PicoArray
781
781
 
782
782
  let index = this.findIndex(value, finder);
783
783
 
784
- if ( index === - 1 ) {
784
+ if ( index === -1 ) {
785
785
  return (value.push(target), value);
786
786
  }
787
787
 
@@ -793,12 +793,12 @@ export class PicoArray
793
793
  *
794
794
  * @example Arr.insert([1,3], 1, 2) // => [1,2,3]
795
795
  *
796
- * @param {Array<any>} value Target array
796
+ * @param {any[]} value Target array
797
797
  * @param {number} index Insert index
798
798
  * @param {any} target Item to insert
799
799
  * @returns {Array<any>} Mutated array
800
800
  */
801
- static insert(value, index, target)
801
+ static insert(value : any[], index : number, target : any) : Array<any>
802
802
  {
803
803
  return (this.splice(value, index, 0, target), value);
804
804
  }
@@ -808,14 +808,14 @@ export class PicoArray
808
808
  *
809
809
  * @example Arr.slice([1,2,3], 1, 2) // => [2,3]
810
810
  *
811
- * @param {Array<any>} value Source array
812
- * @param {number} index Start index
811
+ * @param {any[]} value Source array
812
+ * @param {any} index Start index
813
813
  * @param {number} [length] Slice length
814
814
  * @returns {Array<any>} Sliced array
815
815
  */
816
- static slice(value, index, length = 1)
816
+ static slice(value : any[], index : any, length : number = 1) : Array<any>
817
817
  {
818
- return value.slice(parseInt(index), length);
818
+ return value.slice(Mix.num(index), length);
819
819
  }
820
820
 
821
821
  /**
@@ -823,15 +823,15 @@ export class PicoArray
823
823
  *
824
824
  * @example Arr.splice([1,2], 0, 1) // => [1]
825
825
  *
826
- * @param {Array<any>} value Target array
827
- * @param {number} index Start index
826
+ * @param {any[]} value Target array
827
+ * @param {any} index Start index
828
828
  * @param {number} [length] Remove count
829
- * @param {...any} args Items to add
830
- * @returns {any} Splice result
829
+ * @param {[...any]} args Items to add
830
+ * @returns {Array<any>} Splice result
831
831
  */
832
- static splice(value, index, length = 1, ...args)
832
+ static splice(value : any[], index : any, length : number = 1, ...args : [...any]) : Array<any>
833
833
  {
834
- return value.splice(parseInt(index), length, ...args);
834
+ return value.splice(Mix.num(index), length, ...args);
835
835
  }
836
836
 
837
837
  /**
@@ -839,14 +839,14 @@ export class PicoArray
839
839
  *
840
840
  * @example Arr.splices([1,2,3],[0,2]) // => [2]
841
841
  *
842
- * @param {Array<any>} value Target array
843
- * @param {Array<number>} indexies Index list
842
+ * @param {any[]} value Target array
843
+ * @param {any[]} indexies Index list
844
844
  * @param {number} [length] Remove count
845
845
  * @returns {Array<any>} Mutated array
846
846
  */
847
- static splices(value, indexies, length = 1)
847
+ static splices(value : any[], indexies : any[], length : number = 1) : Array<any>
848
848
  {
849
- this.each(indexies, (index) => {
849
+ this.each(indexies, (index : number) => {
850
850
  this.splice(value, index, length);
851
851
  });
852
852
 
@@ -861,7 +861,7 @@ export class PicoArray
861
861
  * @param {any} value Value to clone
862
862
  * @returns {any} Cloned value
863
863
  */
864
- static clone(value)
864
+ static clone(value : any) : any
865
865
  {
866
866
  if ( Mix.isPrim(value) ) {
867
867
  return value;
@@ -877,7 +877,7 @@ export class PicoArray
877
877
 
878
878
  let result = new Array(value.length);
879
879
 
880
- for ( let i = 0; i < value.length; i ++ ) {
880
+ for ( let i = 0; i < value.length; i++ ) {
881
881
  result[i] = this.clone(value[i]);
882
882
  }
883
883
 
@@ -889,45 +889,55 @@ export class PicoArray
889
889
  *
890
890
  * @example Arr.diff([1,2],[2]) // => [1]
891
891
  *
892
- * @param {...Array<any>} args Arrays to diff
892
+ * @param {[...any[]]} args Arrays to diff
893
893
  * @returns {Array<any>} Difference list
894
894
  */
895
- static diff(...args)
895
+ static diff(...args : [...any[]]) : Array<any>
896
896
  {
897
897
  return args.reduce((a, c) => {
898
- return a.filter(i => !c.includes(i))
898
+ return a.filter((i : any) => !c.includes(i))
899
899
  });
900
900
  }
901
901
 
902
+ /**
903
+ * @see PicoArray.diff
904
+ */
905
+ static diffrence = PicoArray.diff;
906
+
902
907
  /**
903
908
  * Get intersecting items
904
909
  *
905
910
  * @example Arr.isect([1,2],[2,3]) // => [2]
906
911
  *
907
- * @param {...Array<any>} args Arrays to intersect
912
+ * @param {[...any[]]} args Arrays to intersect
908
913
  * @returns {Array<any>} Intersection list
909
914
  */
910
- static isect(...args)
915
+ static isect(...args : [...any[]]) : Array<any>
911
916
  {
912
917
  return args.reduce((a, c) => {
913
- return a.filter(i => c.includes(i))
918
+ return a.filter((i : any) => c.includes(i))
914
919
  });
915
920
  }
916
921
 
922
+ /**
923
+ * @see PicoArray.diff
924
+ */
925
+ static intersect = PicoArray.isect;
926
+
917
927
  /**
918
928
  * Extract property values from list
919
929
  *
920
930
  * @example Arr.extract([{id:1}], "id") // => [1]
921
931
  *
922
- * @param {Array<any>} value Input list
932
+ * @param {any[]} value Input list
923
933
  * @param {any} key Key path
924
934
  * @returns {Array<any>} Extracted list
925
935
  */
926
- static extract(value, key)
936
+ static extract(value : any, key : any) : Array<any>
927
937
  {
928
938
  let result = new Array(value.length);
929
939
 
930
- for ( let i = 0; i < value.length; i ++ ) {
940
+ for ( let i = 0; i < value.length; i++ ) {
931
941
  result[i] = Obj.get(value[i], key);
932
942
  }
933
943
 
@@ -940,12 +950,13 @@ export class PicoArray
940
950
  * @example Arr.reduce([1,2], (a,c)=>a+c, 0) // => 3
941
951
  *
942
952
  * @param {any} value Input list
943
- * @param {function} callback Reducer callback
953
+ * @param {Function} callback Reducer callback
944
954
  * @param {any} accumulator Start value
945
955
  * @returns {any} Reduced value
946
956
  */
947
- static reduce(value, callback, accumulator)
957
+ static reduce(value : any, callback : Function, accumulator : any) : any
948
958
  {
959
+ // @ts-ignore
949
960
  return Mix.vals(value).reduce(callback, accumulator);
950
961
  }
951
962
 
@@ -954,11 +965,11 @@ export class PicoArray
954
965
  *
955
966
  * @example Arr.chunk([1,2,3], 2) // => [[1,2],[3]]
956
967
  *
957
- * @param {Array<any>} value Source array
968
+ * @param {any[]} value Source array
958
969
  * @param {number} [chunk] Chunk size
959
- * @returns {Array<Array<any>>} Chunked list
970
+ * @returns {Array<any[]>} Chunked list
960
971
  */
961
- static chunk(value, chunk = 10)
972
+ static chunk(value : any[], chunk : number = 10) : Array<any[]>
962
973
  {
963
974
  let res = [];
964
975
 
@@ -979,7 +990,7 @@ export class PicoArray
979
990
  * @param {any} search Search spec
980
991
  * @returns {boolean} True if includes
981
992
  */
982
- static includes(value, search)
993
+ static includes(value : any, search : any) : boolean
983
994
  {
984
995
  if ( Mix.isObj(search) ) {
985
996
  return Obj.includes(value, search);
@@ -997,7 +1008,7 @@ export class PicoArray
997
1008
  return true;
998
1009
  }
999
1010
 
1000
- for ( let i = 0; result === false && i < length; i ++ ) {
1011
+ for ( let i = 0; result === false && i < length; i++ ) {
1001
1012
  result ||= this.has(value, search[i]);
1002
1013
  }
1003
1014
 
@@ -1013,12 +1024,12 @@ export class PicoArray
1013
1024
  * @param {any} val Required values
1014
1025
  * @returns {boolean} True if contains
1015
1026
  */
1016
- static contains(arr, val)
1027
+ static contains(arr : any, val : any) : boolean
1017
1028
  {
1018
1029
  let result = true;
1019
1030
 
1020
1031
  for ( let key of Mix.vals(val) ) {
1021
- result &&= Mix.vals(arr).indexOf(key) !== - 1;
1032
+ result &&= Mix.vals(arr).indexOf(key) !== -1;
1022
1033
  }
1023
1034
 
1024
1035
  return result;
@@ -1033,7 +1044,7 @@ export class PicoArray
1033
1044
  * @param {any} search Search spec
1034
1045
  * @returns {boolean} True if matches
1035
1046
  */
1036
- static matches(value, search)
1047
+ static matches(value : any, search : any) : boolean
1037
1048
  {
1038
1049
  if ( Mix.isObj(search) ) {
1039
1050
  return Obj.matches(value, search);
@@ -1053,7 +1064,7 @@ export class PicoArray
1053
1064
  return false;
1054
1065
  }
1055
1066
 
1056
- for ( let i = 0; result === true && i < length; i ++ ) {
1067
+ for ( let i = 0; result === true && i < length; i++ ) {
1057
1068
  result &&= this.has(value, search[i]);
1058
1069
  }
1059
1070
 
@@ -1062,60 +1073,35 @@ export class PicoArray
1062
1073
 
1063
1074
  }
1064
1075
 
1065
- /**
1066
- * @see PicoArray.unset
1067
- */
1068
- PicoArray.removeIndex = function (...args) {
1076
+ // @ts-ignore
1077
+ PicoArray.removeIndex = function (...args : Parameters<typeof PicoArray.splice>) {
1069
1078
  console.warn('Arr.removeIndex() is deprecated, use Arr.unset() instead.');
1070
1079
  return this.unset(...args);
1071
1080
  };
1072
1081
 
1073
- /**
1074
- * @see PicoArray.sortPrim
1075
- */
1076
- PicoArray.sortString = function (...args) {
1082
+ // @ts-ignore
1083
+ PicoArray.sortString = function (...args : Parameters<typeof PicoArray.sortPrim>) {
1077
1084
  console.warn('Arr.sortString() is deprecated, use Arr.sortPrim() instead.');
1078
1085
  return this.sortPrim(...args);
1079
1086
  };
1080
1087
 
1081
- /**
1082
- * @see PicoArray.append
1083
- */
1084
- PicoArray.push = function (...args) {
1088
+ // @ts-ignore
1089
+ PicoArray.push = function (...args : Parameters<typeof PicoArray.append>) {
1085
1090
  console.warn('Arr.push() is deprecated, use Arr.append() instead.');
1086
1091
  return this.append(...args);
1087
1092
  };
1088
1093
 
1089
- /**
1090
- * @see PicoArray.merge
1091
- */
1092
- PicoArray.concat = function (...args) {
1094
+ // @ts-ignore
1095
+ PicoArray.concat = function (...args : Parameters<typeof PicoArray.merge>) {
1093
1096
  console.warn('Arr.concat() is deprecated, use Arr.merge() instead.');
1094
1097
  return this.merge(...args);
1095
1098
  };
1096
1099
 
1097
- /**
1098
- * @see PicoArray.matches
1099
- */
1100
- PicoArray.equal = function (...args) {
1100
+ // @ts-ignore
1101
+ PicoArray.equal = function (...args : Parameters<typeof PicoArray.matches>) {
1101
1102
  console.warn('Arr.equal() is deprecated, use Arr.matches() instead.');
1102
1103
  return this.matches(...args);
1103
1104
  };
1104
1105
 
1105
- /**
1106
- * @see PicoArray.diff
1107
- */
1108
- PicoArray.diffrence = function (...args) {
1109
- console.warn('Arr.diffrence() is deprecated, use Arr.diff() instead.');
1110
- return this.diff(...args);
1111
- };
1112
-
1113
- /**
1114
- * @see PicoArray.isect
1115
- */
1116
- PicoArray.intersect = function (...args) {
1117
- console.warn('Arr.intersect() is deprecated, use Arr.isect() instead.');
1118
- return this.isect(...args);
1119
- };
1120
1106
 
1121
1107
  export default PicoArray;