@kizmann/pico-js 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pico-js.browser.js +1 -1
- package/dist/pico-js.browser.js.map +1 -1
- package/dist/pico-js.esm.js +1 -1
- package/dist/pico-js.esm.js.map +1 -1
- package/package.json +3 -1
- package/src/dom/DomEvent.js +27 -6
- package/src/dom/DomGlobal.js +7 -7
- package/src/index.esm.js +31 -77
- package/src/now/NowDefault.js +16 -16
- package/src/utils/Array.js +83 -28
- package/src/utils/Cookie.js +1 -1
- package/src/utils/Hash.js +5 -5
- package/src/utils/Mixed.js +3 -3
- package/src/utils/Object.js +67 -19
- package/src/utils/Route.js +4 -2
- package/src/utils/Runner.js +90 -122
- package/types/dom/DomEvent.d.ts +10 -1
- package/types/index.esm.d.ts +17 -56
- package/types/now/NowDefault.d.ts +64 -0
- package/types/utils/Array.d.ts +9 -6
- package/types/utils/Event.d.ts +1 -1
- package/types/utils/Locale.d.ts +1 -1
- package/types/utils/Mixed.d.ts +19 -18
- package/types/utils/Number.d.ts +1 -1
- package/types/utils/Object.d.ts +2 -8
- package/types/utils/Runner.d.ts +43 -59
- package/types/utils/String.d.ts +8 -7
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kizmann/pico-js",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"author": "Eduard Kizmann <kizmann@protonmail.ch>",
|
|
8
8
|
"repository": "https://github.com/vankizmann/pico-js",
|
|
9
9
|
"main": "./src/index.esm.js",
|
|
10
|
+
"unpkg": "./dist/pico-js.browser.js",
|
|
10
11
|
"jsnext:main": "./src/index.esm.js",
|
|
11
12
|
"typings": "./types/index.esm.d.ts",
|
|
12
13
|
"imports": {
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"lodash": "^4.17.23",
|
|
43
44
|
"mini-css-extract-plugin": "^2.0.0",
|
|
44
45
|
"mitata": "^1.0.34",
|
|
46
|
+
"moment": "^2.30.1",
|
|
45
47
|
"postcss": "^8.4.31",
|
|
46
48
|
"postcss-inline-svg": "^5.0.0",
|
|
47
49
|
"postcss-loader": "^5.0.0",
|
package/src/dom/DomEvent.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Arr, Hash, Mix, Obj, Dom } from "../index.esm.js";
|
|
1
|
+
import { Arr, Hash, Mix, Obj, Dom, Run } from "../index.esm.js";
|
|
2
2
|
import { PicoDom } from "../utils/Dom.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -6,7 +6,7 @@ import { PicoDom } from "../utils/Dom.js";
|
|
|
6
6
|
*/
|
|
7
7
|
export class PicoDomEventStatic
|
|
8
8
|
{
|
|
9
|
-
static events = [];
|
|
9
|
+
static $events = [];
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -35,7 +35,7 @@ export class PicoDomEventInstance
|
|
|
35
35
|
options = { id: options };
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
Dom
|
|
38
|
+
Dom.$events = Arr.append(Dom.$events, {
|
|
39
39
|
el, event, cb, selector, pause, options
|
|
40
40
|
});
|
|
41
41
|
|
|
@@ -61,7 +61,7 @@ export class PicoDomEventInstance
|
|
|
61
61
|
options = { id: options };
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
let indexes = Arr.filterIndex(Dom
|
|
64
|
+
let indexes = Arr.filterIndex(Dom.$events, {
|
|
65
65
|
el, event, selector, options
|
|
66
66
|
});
|
|
67
67
|
|
|
@@ -74,10 +74,10 @@ export class PicoDomEventInstance
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
Arr.each(indexes.reverse(), (index) => {
|
|
77
|
-
el.removeEventListener(...args(Dom
|
|
77
|
+
el.removeEventListener(...args(Dom.$events[index]));
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
Arr.splices(Dom
|
|
80
|
+
Arr.splices(Dom.$events, indexes);
|
|
81
81
|
|
|
82
82
|
return this;
|
|
83
83
|
}
|
|
@@ -142,6 +142,27 @@ export class PicoDomEventInstance
|
|
|
142
142
|
return this;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Stop listening to event with specific options
|
|
147
|
+
*
|
|
148
|
+
* @example Dom.find("div").optoff({ id: "my-id" })
|
|
149
|
+
*
|
|
150
|
+
* @param {any} [options] Listener options
|
|
151
|
+
* @returns {PicoDom} Current instance
|
|
152
|
+
*/
|
|
153
|
+
optoff(options = {})
|
|
154
|
+
{
|
|
155
|
+
Run.idle(() => {
|
|
156
|
+
Arr.filterRemove(Dom.$events, { options });
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
this.each((el) => {
|
|
160
|
+
el && el.removeAllListeners();
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
|
|
145
166
|
/**
|
|
146
167
|
* Listen to event once
|
|
147
168
|
*
|
package/src/dom/DomGlobal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Run, Mix, Obj, Dom } from "../index.esm.js";
|
|
1
|
+
import { Run, Mix, Obj, Dom, Hash } from "../index.esm.js";
|
|
2
2
|
import { PicoDom } from "../utils/Dom.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -60,18 +60,18 @@ export class PicoDomGlobalStatic
|
|
|
60
60
|
*/
|
|
61
61
|
static ready(cb, delay = 0, limit = 6000)
|
|
62
62
|
{
|
|
63
|
+
let [id, el, event] = [
|
|
64
|
+
Hash.make(), Dom.find(document), 'DOMContentLoaded'
|
|
65
|
+
];
|
|
66
|
+
|
|
63
67
|
let fn = () => {
|
|
64
|
-
Run.delay(cb, delay);
|
|
68
|
+
(Run.delay(cb, delay), el.off(event, null, { id }));
|
|
65
69
|
};
|
|
66
70
|
|
|
67
|
-
let [el, event] = [
|
|
68
|
-
Dom.find(document), 'DOMContentLoaded'
|
|
69
|
-
];
|
|
70
|
-
|
|
71
71
|
let ready = Dom.isDomReady;
|
|
72
72
|
|
|
73
73
|
if ( ! ready() ) {
|
|
74
|
-
return (el.on(event, fn), this);
|
|
74
|
+
return (el.on(event, fn, { id }), this);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
Run.wait(() => {
|
package/src/index.esm.js
CHANGED
|
@@ -1,13 +1,33 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
import { default as
|
|
3
|
-
import { default as
|
|
4
|
-
import { default as
|
|
5
|
-
import { default as
|
|
6
|
-
import { default as
|
|
7
|
-
import { default as
|
|
8
|
-
import { default as
|
|
9
|
-
import { default as
|
|
10
|
-
import { default as
|
|
1
|
+
import { PicoRunner, default as Run } from "./utils/Runner.js";
|
|
2
|
+
import { PicoString, default as Str } from "./utils/String.js";
|
|
3
|
+
import { PicoNumber, default as Num } from "./utils/Number.js";
|
|
4
|
+
import { PicoArray, default as Arr } from "./utils/Array.js";
|
|
5
|
+
import { PicoObject, default as Obj } from "./utils/Object.js";
|
|
6
|
+
import { PicoMixed, default as Mix } from "./utils/Mixed.js";
|
|
7
|
+
import { PicoHash, default as Hash } from "./utils/Hash.js";
|
|
8
|
+
import { PicoEvent, default as Event } from "./utils/Event.js";
|
|
9
|
+
import { PicoLocale, default as Locale } from "./utils/Locale.js";
|
|
10
|
+
import { PicoCookie, default as Cookie } from "./utils/Cookie.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @type {typeof PicoDom}
|
|
14
|
+
*/
|
|
15
|
+
const Dom = DomBuilder();
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @type {typeof PicoNow}
|
|
19
|
+
*/
|
|
20
|
+
const Now = NowBuilder();
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @type {typeof PicoFormat}
|
|
24
|
+
*/
|
|
25
|
+
const For = ForBuilder();
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
Dom, Now, For, Run, Str, Num, Arr, Obj, Mix, Hash, Event, Locale, Cookie
|
|
29
|
+
}
|
|
30
|
+
|
|
11
31
|
import { PicoDom, default as DomBuilder } from "./utils/Dom.js";
|
|
12
32
|
import { PicoNow, default as NowBuilder } from "./utils/Now.js";
|
|
13
33
|
import { PicoFormat, default as ForBuilder } from "./utils/Format.js";
|
|
@@ -31,72 +51,6 @@ export {
|
|
|
31
51
|
Route, Element
|
|
32
52
|
}
|
|
33
53
|
|
|
34
|
-
/**
|
|
35
|
-
* @type {typeof PicoDom}
|
|
36
|
-
*/
|
|
37
|
-
export const Dom = DomBuilder();
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @type {typeof PicoNow}
|
|
41
|
-
*/
|
|
42
|
-
export const Now = NowBuilder();
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @type {typeof PicoFormat}
|
|
46
|
-
*/
|
|
47
|
-
export const For = ForBuilder();
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @type {typeof PicoRunner}
|
|
51
|
-
*/
|
|
52
|
-
export const Run = PicoRunner;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @type {typeof PicoString}
|
|
56
|
-
*/
|
|
57
|
-
export const Str = PicoString;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @type {typeof PicoNumber}
|
|
61
|
-
*/
|
|
62
|
-
export const Num = PicoNumber;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @type {typeof PicoArray}
|
|
66
|
-
*/
|
|
67
|
-
export const Arr = PicoArray;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @type {typeof PicoObject}
|
|
71
|
-
*/
|
|
72
|
-
export const Obj = PicoObject;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @type {typeof PicoMixed}
|
|
76
|
-
*/
|
|
77
|
-
export const Mix = PicoMixed;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @type {typeof PicoHash}
|
|
81
|
-
*/
|
|
82
|
-
export const Hash = PicoHash;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* @type {typeof PicoEvent}
|
|
86
|
-
*/
|
|
87
|
-
export const Event = PicoEvent;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @type {typeof PicoLocale}
|
|
91
|
-
*/
|
|
92
|
-
export const Locale = PicoLocale;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* @type {typeof PicoCookie}
|
|
96
|
-
*/
|
|
97
|
-
export const Cookie = PicoCookie;
|
|
98
|
-
|
|
99
|
-
|
|
100
54
|
/**
|
|
101
55
|
* @type {typeof PicoMixed}
|
|
102
56
|
*/
|
|
@@ -112,5 +66,5 @@ export const Any = new Proxy({}, {
|
|
|
112
66
|
*/
|
|
113
67
|
export const UUID = function () {
|
|
114
68
|
console.warn('UUID() is deprecated, use Hash.make() instead.');
|
|
115
|
-
return
|
|
69
|
+
return Hash.make();
|
|
116
70
|
};
|
package/src/now/NowDefault.js
CHANGED
|
@@ -396,7 +396,7 @@ export class PicoNowDefaultInstance
|
|
|
396
396
|
/**
|
|
397
397
|
* @see PicoNow.add
|
|
398
398
|
*/
|
|
399
|
-
|
|
399
|
+
PicoNowDefaultInstance.prototype.addSecond = function (value) {
|
|
400
400
|
console.warn('Now.addSecond() is deprecated, use Now.add(value, \'second\') instead.');
|
|
401
401
|
return this.add(value, 'second');
|
|
402
402
|
}
|
|
@@ -404,7 +404,7 @@ PicoNowGridInstance.prototype.addSecond = function (value) {
|
|
|
404
404
|
/**
|
|
405
405
|
* @see PicoNow.sub
|
|
406
406
|
*/
|
|
407
|
-
|
|
407
|
+
PicoNowDefaultInstance.prototype.subSecond = function (value) {
|
|
408
408
|
console.warn('Now.subSecond() is deprecated, use Now.sub(value, \'second\') instead.');
|
|
409
409
|
return this.sub(value, 'second');
|
|
410
410
|
}
|
|
@@ -412,7 +412,7 @@ PicoNowGridInstance.prototype.subSecond = function (value) {
|
|
|
412
412
|
/**
|
|
413
413
|
* @see PicoNow.add
|
|
414
414
|
*/
|
|
415
|
-
|
|
415
|
+
PicoNowDefaultInstance.prototype.addMinute = function (value) {
|
|
416
416
|
console.warn('Now.addMinute() is deprecated, use Now.add(value, \'minute\') instead.');
|
|
417
417
|
return this.add(value, 'minute');
|
|
418
418
|
}
|
|
@@ -420,7 +420,7 @@ PicoNowGridInstance.prototype.addMinute = function (value) {
|
|
|
420
420
|
/**
|
|
421
421
|
* @see PicoNow.sub
|
|
422
422
|
*/
|
|
423
|
-
|
|
423
|
+
PicoNowDefaultInstance.prototype.subMinute = function (value) {
|
|
424
424
|
console.warn('Now.subMinute() is deprecated, use Now.sub(value, \'minute\') instead.');
|
|
425
425
|
return this.sub(value, 'minute');
|
|
426
426
|
}
|
|
@@ -428,7 +428,7 @@ PicoNowGridInstance.prototype.subMinute = function (value) {
|
|
|
428
428
|
/**
|
|
429
429
|
* @see PicoNow.add
|
|
430
430
|
*/
|
|
431
|
-
|
|
431
|
+
PicoNowDefaultInstance.prototype.addHour = function (value) {
|
|
432
432
|
console.warn('Now.addHour() is deprecated, use Now.add(value, \'hour\') instead.');
|
|
433
433
|
return this.add(value, 'hour');
|
|
434
434
|
}
|
|
@@ -436,7 +436,7 @@ PicoNowGridInstance.prototype.addHour = function (value) {
|
|
|
436
436
|
/**
|
|
437
437
|
* @see PicoNow.sub
|
|
438
438
|
*/
|
|
439
|
-
|
|
439
|
+
PicoNowDefaultInstance.prototype.subHour = function (value) {
|
|
440
440
|
console.warn('Now.subHour() is deprecated, use Now.sub(value, \'hour\') instead.');
|
|
441
441
|
return this.sub(value, 'hour');
|
|
442
442
|
}
|
|
@@ -444,7 +444,7 @@ PicoNowGridInstance.prototype.subHour = function (value) {
|
|
|
444
444
|
/**
|
|
445
445
|
* @see PicoNow.add
|
|
446
446
|
*/
|
|
447
|
-
|
|
447
|
+
PicoNowDefaultInstance.prototype.addDates = function (value) {
|
|
448
448
|
console.warn('Now.addDates() is deprecated, use Now.add(value, \'date\') instead.');
|
|
449
449
|
return this.add(value, 'date');
|
|
450
450
|
}
|
|
@@ -452,7 +452,7 @@ PicoNowGridInstance.prototype.addDates = function (value) {
|
|
|
452
452
|
/**
|
|
453
453
|
* @see PicoNow.sub
|
|
454
454
|
*/
|
|
455
|
-
|
|
455
|
+
PicoNowDefaultInstance.prototype.subDates = function (value) {
|
|
456
456
|
console.warn('Now.subDates() is deprecated, use Now.sub(value, \'date\') instead.');
|
|
457
457
|
return this.sub(value, 'date');
|
|
458
458
|
}
|
|
@@ -460,7 +460,7 @@ PicoNowGridInstance.prototype.subDates = function (value) {
|
|
|
460
460
|
/**
|
|
461
461
|
* @see PicoNow.add
|
|
462
462
|
*/
|
|
463
|
-
|
|
463
|
+
PicoNowDefaultInstance.prototype.addMonths = function (value) {
|
|
464
464
|
console.warn('Now.addMonths() is deprecated, use Now.add(value, \'month\') instead.');
|
|
465
465
|
return this.add(value, 'month');
|
|
466
466
|
}
|
|
@@ -468,7 +468,7 @@ PicoNowGridInstance.prototype.addMonths = function (value) {
|
|
|
468
468
|
/**
|
|
469
469
|
* @see PicoNow.sub
|
|
470
470
|
*/
|
|
471
|
-
|
|
471
|
+
PicoNowDefaultInstance.prototype.subMonths = function (value) {
|
|
472
472
|
console.warn('Now.subMonths() is deprecated, use Now.sub(value, \'month\') instead.');
|
|
473
473
|
return this.sub(value, 'month');
|
|
474
474
|
}
|
|
@@ -476,7 +476,7 @@ PicoNowGridInstance.prototype.subMonths = function (value) {
|
|
|
476
476
|
/**
|
|
477
477
|
* @see PicoNow.add
|
|
478
478
|
*/
|
|
479
|
-
|
|
479
|
+
PicoNowDefaultInstance.prototype.addYears = function (value) {
|
|
480
480
|
console.warn('Now.addYears() is deprecated, use Now.add(value, \'year\') instead.');
|
|
481
481
|
return this.add(value, 'year');
|
|
482
482
|
}
|
|
@@ -484,7 +484,7 @@ PicoNowGridInstance.prototype.addYears = function (value) {
|
|
|
484
484
|
/**
|
|
485
485
|
* @see PicoNow.sub
|
|
486
486
|
*/
|
|
487
|
-
|
|
487
|
+
PicoNowDefaultInstance.prototype.subYears = function (value) {
|
|
488
488
|
console.warn('Now.subYears() is deprecated, use Now.sub(value, \'year\') instead.');
|
|
489
489
|
return this.sub(value, 'year');
|
|
490
490
|
}
|
|
@@ -492,7 +492,7 @@ PicoNowGridInstance.prototype.subYears = function (value) {
|
|
|
492
492
|
/**
|
|
493
493
|
* @see PicoNow.add
|
|
494
494
|
*/
|
|
495
|
-
|
|
495
|
+
PicoNowDefaultInstance.prototype.addDecades = function (value) {
|
|
496
496
|
console.warn('Now.addDecades() is deprecated, use Now.grid(10 * value, \'year\') instead.');
|
|
497
497
|
return this.add(10 * value, 'year');
|
|
498
498
|
}
|
|
@@ -500,7 +500,7 @@ PicoNowGridInstance.prototype.addDecades = function (value) {
|
|
|
500
500
|
/**
|
|
501
501
|
* @see PicoNow.sub
|
|
502
502
|
*/
|
|
503
|
-
|
|
503
|
+
PicoNowDefaultInstance.prototype.subDecades = function (value) {
|
|
504
504
|
console.warn('Now.subDecades() is deprecated, use Now.grid(10 * value, \'year\') instead.');
|
|
505
505
|
return this.sub(10 * value, 'year');
|
|
506
506
|
}
|
|
@@ -508,7 +508,7 @@ PicoNowGridInstance.prototype.subDecades = function (value) {
|
|
|
508
508
|
/**
|
|
509
509
|
* @see PicoNow.day
|
|
510
510
|
*/
|
|
511
|
-
|
|
511
|
+
PicoNowDefaultInstance.prototype.humanDay = function () {
|
|
512
512
|
console.warn('Now.humanDay() is deprecated, use Now.day() instead.');
|
|
513
513
|
return this.day();
|
|
514
514
|
}
|
|
@@ -516,7 +516,7 @@ PicoNowGridInstance.prototype.humanDay = function () {
|
|
|
516
516
|
/**
|
|
517
517
|
* @see PicoNow.month
|
|
518
518
|
*/
|
|
519
|
-
|
|
519
|
+
PicoNowDefaultInstance.prototype.humanMonth = function () {
|
|
520
520
|
console.warn('Now.humanMonth() is deprecated, use Now.month() instead.');
|
|
521
521
|
return this.month();
|
|
522
522
|
}
|
package/src/utils/Array.js
CHANGED
|
@@ -231,25 +231,38 @@ export class PicoArray
|
|
|
231
231
|
*/
|
|
232
232
|
static each(value, cb, retval = null)
|
|
233
233
|
{
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
if ( Mix.isObj(value) ) {
|
|
235
|
+
return this.eachObj(value, cb, retval);
|
|
236
|
+
}
|
|
237
237
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
238
|
+
if ( value == null ) {
|
|
239
|
+
value = [];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
let result = new Array(value.length);
|
|
243
|
+
|
|
244
|
+
for (let i = 0; i < value.length; i++) {
|
|
245
|
+
result[i] = cb(value[i], i);
|
|
246
|
+
}
|
|
241
247
|
|
|
242
|
-
|
|
248
|
+
return retval != null ? retval : result;
|
|
249
|
+
}
|
|
243
250
|
|
|
244
|
-
|
|
245
|
-
|
|
251
|
+
static eachObj(value, cb, retval = null)
|
|
252
|
+
{
|
|
253
|
+
if ( Mix.isArr(value) ) {
|
|
254
|
+
return this.each(value, cb, retval);
|
|
246
255
|
}
|
|
247
256
|
|
|
248
|
-
if (
|
|
249
|
-
|
|
257
|
+
if ( value == null ) {
|
|
258
|
+
value = {};
|
|
250
259
|
}
|
|
251
260
|
|
|
252
|
-
|
|
261
|
+
let result = Mix.keys(value).map((key) => {
|
|
262
|
+
return cb(value[key], key);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
return retval != null ? retval : result;
|
|
253
266
|
}
|
|
254
267
|
|
|
255
268
|
/**
|
|
@@ -295,15 +308,30 @@ export class PicoArray
|
|
|
295
308
|
return value;
|
|
296
309
|
}
|
|
297
310
|
|
|
298
|
-
|
|
311
|
+
if ( Mix.isObj(value) ) {
|
|
312
|
+
return this.recursiveObj(value, key, cb, cascade);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return this.each(value, (item) => {
|
|
299
316
|
return (this.recursive(item[key], key, cb, [
|
|
300
317
|
...cascade, value
|
|
301
|
-
]), cb(item, cascade));
|
|
318
|
+
]), cb(item, this.clone(cascade)));
|
|
302
319
|
});
|
|
303
320
|
|
|
304
321
|
// [{childs: [{ childs: [] } ] }, { childs: [] } ] }]
|
|
305
322
|
}
|
|
306
323
|
|
|
324
|
+
static recursiveObj(value, key, cb, cascade = [])
|
|
325
|
+
{
|
|
326
|
+
if ( value == null ) {
|
|
327
|
+
return value;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return this.recursive(value[key], key, cb, [
|
|
331
|
+
...cascade, value
|
|
332
|
+
]), cb(item, this.clone(cascade))
|
|
333
|
+
}
|
|
334
|
+
|
|
307
335
|
/**
|
|
308
336
|
* Get matching indexes by filter
|
|
309
337
|
*
|
|
@@ -315,6 +343,10 @@ export class PicoArray
|
|
|
315
343
|
*/
|
|
316
344
|
static filterIndex(value, filter = null)
|
|
317
345
|
{
|
|
346
|
+
if ( value == null ) {
|
|
347
|
+
return [];
|
|
348
|
+
}
|
|
349
|
+
|
|
318
350
|
if ( filter == null ) {
|
|
319
351
|
filter = (val) => !Mix.isEmpty(val);
|
|
320
352
|
}
|
|
@@ -333,6 +365,21 @@ export class PicoArray
|
|
|
333
365
|
});
|
|
334
366
|
}
|
|
335
367
|
|
|
368
|
+
static filterRemove(value, filter = null)
|
|
369
|
+
{
|
|
370
|
+
if ( value == null ) {
|
|
371
|
+
return value;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
let indexes = this.filterIndex(value, filter);
|
|
375
|
+
|
|
376
|
+
if ( indexes.length === 0 ) {
|
|
377
|
+
return value;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
return this.splices(value, indexes);
|
|
381
|
+
}
|
|
382
|
+
|
|
336
383
|
/**
|
|
337
384
|
* Filter values by filter
|
|
338
385
|
*
|
|
@@ -344,6 +391,10 @@ export class PicoArray
|
|
|
344
391
|
*/
|
|
345
392
|
static filter(value, filter = null)
|
|
346
393
|
{
|
|
394
|
+
if ( value == null ) {
|
|
395
|
+
return [];
|
|
396
|
+
}
|
|
397
|
+
|
|
347
398
|
if ( filter == null ) {
|
|
348
399
|
filter = (val) => !Mix.isEmpty(val);
|
|
349
400
|
}
|
|
@@ -374,6 +425,10 @@ export class PicoArray
|
|
|
374
425
|
*/
|
|
375
426
|
static findIndex(value, filter = null, fallback = - 1)
|
|
376
427
|
{
|
|
428
|
+
if ( value == null ) {
|
|
429
|
+
return fallback;
|
|
430
|
+
}
|
|
431
|
+
|
|
377
432
|
if ( filter == null ) {
|
|
378
433
|
filter = (val) => !Mix.isEmpty(val);
|
|
379
434
|
}
|
|
@@ -930,57 +985,57 @@ export class PicoArray
|
|
|
930
985
|
/**
|
|
931
986
|
* @see PicoArray.unset
|
|
932
987
|
*/
|
|
933
|
-
PicoArray.removeIndex = (...args)
|
|
988
|
+
PicoArray.removeIndex = function (...args) {
|
|
934
989
|
console.warn('Arr.removeIndex() is deprecated, use Arr.unset() instead.');
|
|
935
|
-
return
|
|
990
|
+
return this.unset(...args);
|
|
936
991
|
};
|
|
937
992
|
|
|
938
993
|
/**
|
|
939
994
|
* @see PicoArray.sortPrim
|
|
940
995
|
*/
|
|
941
|
-
PicoArray.sortString = (...args)
|
|
996
|
+
PicoArray.sortString = function (...args) {
|
|
942
997
|
console.warn('Arr.sortString() is deprecated, use Arr.sortPrim() instead.');
|
|
943
|
-
return
|
|
998
|
+
return this.sortPrim(...args);
|
|
944
999
|
};
|
|
945
1000
|
|
|
946
1001
|
/**
|
|
947
1002
|
* @see PicoArray.append
|
|
948
1003
|
*/
|
|
949
|
-
PicoArray.push = (...args)
|
|
1004
|
+
PicoArray.push = function (...args) {
|
|
950
1005
|
console.warn('Arr.push() is deprecated, use Arr.append() instead.');
|
|
951
|
-
return
|
|
1006
|
+
return this.append(...args);
|
|
952
1007
|
};
|
|
953
1008
|
|
|
954
1009
|
/**
|
|
955
1010
|
* @see PicoArray.merge
|
|
956
1011
|
*/
|
|
957
|
-
PicoArray.concat = (...args)
|
|
1012
|
+
PicoArray.concat = function (...args) {
|
|
958
1013
|
console.warn('Arr.concat() is deprecated, use Arr.merge() instead.');
|
|
959
|
-
return
|
|
1014
|
+
return this.merge(...args);
|
|
960
1015
|
};
|
|
961
1016
|
|
|
962
1017
|
/**
|
|
963
1018
|
* @see PicoArray.matches
|
|
964
1019
|
*/
|
|
965
|
-
PicoArray.equal = (...args)
|
|
1020
|
+
PicoArray.equal = function (...args) {
|
|
966
1021
|
console.warn('Arr.equal() is deprecated, use Arr.matches() instead.');
|
|
967
|
-
return
|
|
1022
|
+
return this.matches(...args);
|
|
968
1023
|
};
|
|
969
1024
|
|
|
970
1025
|
/**
|
|
971
1026
|
* @see PicoArray.diff
|
|
972
1027
|
*/
|
|
973
|
-
PicoArray.diffrence = (...args)
|
|
1028
|
+
PicoArray.diffrence = function (...args) {
|
|
974
1029
|
console.warn('Arr.diffrence() is deprecated, use Arr.diff() instead.');
|
|
975
|
-
return
|
|
1030
|
+
return this.diff(...args);
|
|
976
1031
|
};
|
|
977
1032
|
|
|
978
1033
|
/**
|
|
979
1034
|
* @see PicoArray.isect
|
|
980
1035
|
*/
|
|
981
|
-
PicoArray.intersect = (...args)
|
|
1036
|
+
PicoArray.intersect = function (...args) {
|
|
982
1037
|
console.warn('Arr.intersect() is deprecated, use Arr.isect() instead.');
|
|
983
|
-
return
|
|
1038
|
+
return this.isect(...args);
|
|
984
1039
|
};
|
|
985
1040
|
|
|
986
1041
|
export default PicoArray;
|
package/src/utils/Cookie.js
CHANGED
package/src/utils/Hash.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Str
|
|
1
|
+
import { Str } from "../index.esm.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @var {Array<string>} RADIX_NUMBER Radix from 0 to 9
|
|
@@ -96,7 +96,7 @@ export class PicoHash
|
|
|
96
96
|
let hash = '';
|
|
97
97
|
|
|
98
98
|
for ( let i = 0; i < length; i ++ ) {
|
|
99
|
-
hash +=
|
|
99
|
+
hash += this.radix(radix);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
for ( const k of Object.keys(map) ) {
|
|
@@ -121,9 +121,9 @@ export class PicoHash
|
|
|
121
121
|
// Use only selected chars from the radix store
|
|
122
122
|
for ( let i = 0; i < 31; i ++ ) {
|
|
123
123
|
if ( i === 15 ) {
|
|
124
|
-
hash +=
|
|
124
|
+
hash += this.radix(RADIX_UP19.length, RADIX_UP19);
|
|
125
125
|
} else {
|
|
126
|
-
hash +=
|
|
126
|
+
hash += this.radix(RADIX_UUID.length, RADIX_UUID);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
|
|
@@ -153,7 +153,7 @@ export class PicoHash
|
|
|
153
153
|
let hash = '';
|
|
154
154
|
|
|
155
155
|
for ( let i = 0; i < length; i ++ ) {
|
|
156
|
-
hash +=
|
|
156
|
+
hash += this.radix(radix.length, radix);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
return hash;
|
package/src/utils/Mixed.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { go, Arr, Mix, Run, Now, Locale, Str, Obj } from "../index.esm.js";
|
|
2
2
|
|
|
3
3
|
export const MIX_REGEX = {
|
|
4
4
|
'iso': /^\d{4}-\d{2}-\d{2}[T\s]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/,
|
|
@@ -279,7 +279,7 @@ export class PicoMixed
|
|
|
279
279
|
return false;
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
return
|
|
282
|
+
return typeof value === 'object' && value.constructor === Object;
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
/**
|
|
@@ -302,7 +302,7 @@ export class PicoMixed
|
|
|
302
302
|
return false;
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
return
|
|
305
|
+
return typeof value === 'object' && value.constructor === Array;
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
/**
|