@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/types/utils/Array.d.ts
CHANGED
|
@@ -134,6 +134,7 @@ export class PicoArray {
|
|
|
134
134
|
* @returns {any} Mapped array
|
|
135
135
|
*/
|
|
136
136
|
static each(value: any, cb: Function, retval?: any): any;
|
|
137
|
+
static eachObj(value: any, cb: any, retval?: any): any;
|
|
137
138
|
/**
|
|
138
139
|
* Map values in place (mutates)
|
|
139
140
|
*
|
|
@@ -156,6 +157,7 @@ export class PicoArray {
|
|
|
156
157
|
* @returns {any} Mapped tree
|
|
157
158
|
*/
|
|
158
159
|
static recursive(value: any, key: string, cb: Function, cascade?: Array<any>): any;
|
|
160
|
+
static recursiveObj(value: any, key: any, cb: any, cascade?: any[]): any;
|
|
159
161
|
/**
|
|
160
162
|
* Get matching indexes by filter
|
|
161
163
|
*
|
|
@@ -166,6 +168,7 @@ export class PicoArray {
|
|
|
166
168
|
* @returns {Array<string>} Matching keys
|
|
167
169
|
*/
|
|
168
170
|
static filterIndex(value: any, filter?: any): Array<string>;
|
|
171
|
+
static filterRemove(value: any, filter?: any): any;
|
|
169
172
|
/**
|
|
170
173
|
* Filter values by filter
|
|
171
174
|
*
|
|
@@ -455,26 +458,26 @@ export namespace PicoArray {
|
|
|
455
458
|
/**
|
|
456
459
|
* @see PicoArray.sortPrim
|
|
457
460
|
*/
|
|
458
|
-
function sortString(...args: any[]): any;
|
|
461
|
+
function sortString(...args: any[]): any[];
|
|
459
462
|
/**
|
|
460
463
|
* @see PicoArray.append
|
|
461
464
|
*/
|
|
462
|
-
function push(...args: any[]): any;
|
|
465
|
+
function push(...args: any[]): any[];
|
|
463
466
|
/**
|
|
464
467
|
* @see PicoArray.merge
|
|
465
468
|
*/
|
|
466
|
-
function concat(...args: any[]): any;
|
|
469
|
+
function concat(...args: any[]): any[];
|
|
467
470
|
/**
|
|
468
471
|
* @see PicoArray.matches
|
|
469
472
|
*/
|
|
470
|
-
function equal(...args: any[]):
|
|
473
|
+
function equal(...args: any[]): boolean;
|
|
471
474
|
/**
|
|
472
475
|
* @see PicoArray.diff
|
|
473
476
|
*/
|
|
474
|
-
function diffrence(...args: any[]): any;
|
|
477
|
+
function diffrence(...args: any[]): any[];
|
|
475
478
|
/**
|
|
476
479
|
* @see PicoArray.isect
|
|
477
480
|
*/
|
|
478
|
-
function intersect(...args: any[]): any;
|
|
481
|
+
function intersect(...args: any[]): any[];
|
|
479
482
|
}
|
|
480
483
|
export default PicoArray;
|
package/types/utils/Event.d.ts
CHANGED
package/types/utils/Locale.d.ts
CHANGED
package/types/utils/Mixed.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export class PicoMixed {
|
|
|
66
66
|
/**
|
|
67
67
|
* @see PicoMixed.isPrim
|
|
68
68
|
*/
|
|
69
|
-
static isPrimitive: typeof
|
|
69
|
+
static isPrimitive: typeof Mix.isPrim;
|
|
70
70
|
/**
|
|
71
71
|
* Check if the value is a string
|
|
72
72
|
*
|
|
@@ -80,7 +80,7 @@ export class PicoMixed {
|
|
|
80
80
|
/**
|
|
81
81
|
* @see PicoMixed.isStr
|
|
82
82
|
*/
|
|
83
|
-
static isString: typeof
|
|
83
|
+
static isString: typeof Mix.isStr;
|
|
84
84
|
/**
|
|
85
85
|
* Check if the value is a number
|
|
86
86
|
*
|
|
@@ -95,7 +95,7 @@ export class PicoMixed {
|
|
|
95
95
|
/**
|
|
96
96
|
* @see PicoMixed.isNum
|
|
97
97
|
*/
|
|
98
|
-
static isNumber: typeof
|
|
98
|
+
static isNumber: typeof Mix.isNum;
|
|
99
99
|
/**
|
|
100
100
|
* Check if the value is an integer
|
|
101
101
|
*
|
|
@@ -111,7 +111,7 @@ export class PicoMixed {
|
|
|
111
111
|
/**
|
|
112
112
|
* @see PicoMixed.isInt
|
|
113
113
|
*/
|
|
114
|
-
static isInteger: typeof
|
|
114
|
+
static isInteger: typeof Mix.isInt;
|
|
115
115
|
/**
|
|
116
116
|
* Check if the value is a boolean
|
|
117
117
|
*
|
|
@@ -127,7 +127,7 @@ export class PicoMixed {
|
|
|
127
127
|
/**
|
|
128
128
|
* @see PicoMixed.isBool
|
|
129
129
|
*/
|
|
130
|
-
static isBoolean: typeof
|
|
130
|
+
static isBoolean: typeof Mix.isBool;
|
|
131
131
|
/**
|
|
132
132
|
* Check if the value is a function
|
|
133
133
|
*
|
|
@@ -143,7 +143,7 @@ export class PicoMixed {
|
|
|
143
143
|
/**
|
|
144
144
|
* @see PicoMixed.isFunc
|
|
145
145
|
*/
|
|
146
|
-
static isFunction: typeof
|
|
146
|
+
static isFunction: typeof Mix.isFunc;
|
|
147
147
|
/**
|
|
148
148
|
* Check if the value is object
|
|
149
149
|
*
|
|
@@ -160,7 +160,7 @@ export class PicoMixed {
|
|
|
160
160
|
/**
|
|
161
161
|
* @see PicoMixed.isRef
|
|
162
162
|
*/
|
|
163
|
-
static isReference: typeof
|
|
163
|
+
static isReference: typeof Mix.isRef;
|
|
164
164
|
/**
|
|
165
165
|
* Check if the value is plain object
|
|
166
166
|
*
|
|
@@ -174,7 +174,7 @@ export class PicoMixed {
|
|
|
174
174
|
/**
|
|
175
175
|
* @see PicoMixed.isObj
|
|
176
176
|
*/
|
|
177
|
-
static isObject: typeof
|
|
177
|
+
static isObject: typeof Mix.isObj;
|
|
178
178
|
/**
|
|
179
179
|
* Check if the value is array object
|
|
180
180
|
*
|
|
@@ -188,7 +188,7 @@ export class PicoMixed {
|
|
|
188
188
|
/**
|
|
189
189
|
* @see PicoMixed.isArr
|
|
190
190
|
*/
|
|
191
|
-
static isArray: typeof
|
|
191
|
+
static isArray: typeof Mix.isArr;
|
|
192
192
|
/**
|
|
193
193
|
* Check if the value is iterable object
|
|
194
194
|
*
|
|
@@ -202,7 +202,7 @@ export class PicoMixed {
|
|
|
202
202
|
/**
|
|
203
203
|
* @see PicoMixed.isIter
|
|
204
204
|
*/
|
|
205
|
-
static isIterable: typeof
|
|
205
|
+
static isIterable: typeof Mix.isIter;
|
|
206
206
|
/**
|
|
207
207
|
* Check if the value is iso date
|
|
208
208
|
*
|
|
@@ -349,7 +349,7 @@ export class PicoMixed {
|
|
|
349
349
|
/**
|
|
350
350
|
* @see PicoMixed.length
|
|
351
351
|
*/
|
|
352
|
-
static length: typeof
|
|
352
|
+
static length: typeof Mix.len;
|
|
353
353
|
/**
|
|
354
354
|
* Compare two objects (used for natural array sort)
|
|
355
355
|
*
|
|
@@ -380,7 +380,7 @@ export class PicoMixed {
|
|
|
380
380
|
/**
|
|
381
381
|
* @see PicoMixed.arr
|
|
382
382
|
*/
|
|
383
|
-
static array: typeof
|
|
383
|
+
static array: typeof Mix.arr;
|
|
384
384
|
/**
|
|
385
385
|
* Convert value to string
|
|
386
386
|
*
|
|
@@ -397,7 +397,7 @@ export class PicoMixed {
|
|
|
397
397
|
/**
|
|
398
398
|
* @see PicoMixed.str
|
|
399
399
|
*/
|
|
400
|
-
static string: typeof
|
|
400
|
+
static string: typeof Mix.str;
|
|
401
401
|
/**
|
|
402
402
|
* Convert value to number
|
|
403
403
|
*
|
|
@@ -414,7 +414,7 @@ export class PicoMixed {
|
|
|
414
414
|
/**
|
|
415
415
|
* @see PicoMixed.num
|
|
416
416
|
*/
|
|
417
|
-
static number: typeof
|
|
417
|
+
static number: typeof Mix.num;
|
|
418
418
|
/**
|
|
419
419
|
* Convert value to integer
|
|
420
420
|
*
|
|
@@ -431,7 +431,7 @@ export class PicoMixed {
|
|
|
431
431
|
/**
|
|
432
432
|
* @see PicoMixed.int
|
|
433
433
|
*/
|
|
434
|
-
static integer: typeof
|
|
434
|
+
static integer: typeof Mix.int;
|
|
435
435
|
/**
|
|
436
436
|
* Convert value to boolean
|
|
437
437
|
*
|
|
@@ -450,14 +450,14 @@ export class PicoMixed {
|
|
|
450
450
|
/**
|
|
451
451
|
* @see PicoMixed.bool
|
|
452
452
|
*/
|
|
453
|
-
static boolean: typeof
|
|
453
|
+
static boolean: typeof Mix.bool;
|
|
454
454
|
}
|
|
455
455
|
export namespace PicoMixed {
|
|
456
456
|
function global(...args: any[]): any;
|
|
457
457
|
function isPlain(...args: any[]): boolean;
|
|
458
458
|
function float(...args: any[]): any;
|
|
459
459
|
function delay(...args: any[]): Function;
|
|
460
|
-
function async(...args: any[]):
|
|
460
|
+
function async(...args: any[]): Function;
|
|
461
461
|
function debounce(...args: any[]): Function;
|
|
462
462
|
function throttle(...args: any[]): Function;
|
|
463
463
|
function framerate(...args: any[]): Function;
|
|
@@ -466,4 +466,5 @@ export namespace PicoMixed {
|
|
|
466
466
|
function convertBool(...args: any[]): any;
|
|
467
467
|
function convertBoolean(...args: any[]): any;
|
|
468
468
|
}
|
|
469
|
-
export default
|
|
469
|
+
export default Mix;
|
|
470
|
+
import { Mix } from "../index.esm.js";
|
package/types/utils/Number.d.ts
CHANGED
package/types/utils/Object.d.ts
CHANGED
|
@@ -229,6 +229,8 @@ export class PicoObject {
|
|
|
229
229
|
* @returns {boolean} True if matches
|
|
230
230
|
*/
|
|
231
231
|
static matches(value: any, search: any): boolean;
|
|
232
|
+
static sort(obj: any, key: any): any[];
|
|
233
|
+
static sortString(obj: any, key: any): any[];
|
|
232
234
|
}
|
|
233
235
|
export namespace PicoObject {
|
|
234
236
|
/**
|
|
@@ -243,13 +245,5 @@ export namespace PicoObject {
|
|
|
243
245
|
* @see PicoArray.findIndex
|
|
244
246
|
*/
|
|
245
247
|
function findIndex(...args: any[]): number;
|
|
246
|
-
/**
|
|
247
|
-
* @see PicoArray.sort
|
|
248
|
-
*/
|
|
249
|
-
function sort(...args: any[]): any[];
|
|
250
|
-
/**
|
|
251
|
-
* @see PicoArray.sortDeep
|
|
252
|
-
*/
|
|
253
|
-
function sortString(...args: any[]): any[];
|
|
254
248
|
}
|
|
255
249
|
export default PicoObject;
|
package/types/utils/Runner.d.ts
CHANGED
|
@@ -1,87 +1,73 @@
|
|
|
1
1
|
export class PicoRunner {
|
|
2
|
-
static $idler:
|
|
3
|
-
|
|
4
|
-
debounce: {};
|
|
5
|
-
throttle: {};
|
|
6
|
-
};
|
|
7
|
-
static $timer: {
|
|
8
|
-
date: number;
|
|
9
|
-
func: any;
|
|
10
|
-
};
|
|
2
|
+
static $idler: any;
|
|
3
|
+
static $timer: number;
|
|
11
4
|
static $buffer: any[];
|
|
12
5
|
/**
|
|
13
|
-
*
|
|
6
|
+
* Clear timer or call function
|
|
14
7
|
*
|
|
15
|
-
* @example Run.
|
|
8
|
+
* @example Run.clear(timer)
|
|
16
9
|
*
|
|
17
|
-
* @param {
|
|
18
|
-
* @
|
|
19
|
-
* @param {string|null} [index] Timer id
|
|
20
|
-
* @returns {string} Timer id
|
|
10
|
+
* @param {any} timer Timer ID, array of IDs, or function
|
|
11
|
+
* @returns {typeof PicoRunner} Static class
|
|
21
12
|
*/
|
|
22
|
-
static
|
|
13
|
+
static clear(timer: any): typeof PicoRunner;
|
|
23
14
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* @example Run.interval(() => {}, 250) // => "i-..."
|
|
15
|
+
* Request idle callback with fallback
|
|
27
16
|
*
|
|
28
|
-
* @param {function}
|
|
29
|
-
* @
|
|
30
|
-
* @param {string|null} [index] Timer id
|
|
31
|
-
* @returns {string} Timer id
|
|
17
|
+
* @param {function} cb Callback function
|
|
18
|
+
* @returns {typeof PicoRunner} Static class
|
|
32
19
|
*/
|
|
33
|
-
static
|
|
20
|
+
static tryin(cb: Function): typeof PicoRunner;
|
|
34
21
|
/**
|
|
35
|
-
*
|
|
22
|
+
* Wait for condition to be true
|
|
36
23
|
*
|
|
37
|
-
* @example Run.
|
|
38
|
-
* @example Run.clear(["t-a","i-b"]) // => Run
|
|
24
|
+
* @example Run.wait(() => window.foo, 10, 100)
|
|
39
25
|
*
|
|
40
|
-
* @param {
|
|
41
|
-
* @param {
|
|
42
|
-
* @
|
|
26
|
+
* @param {function} fn Condition function
|
|
27
|
+
* @param {number} [intval] Interval ms
|
|
28
|
+
* @param {number} [limit] Max iterations
|
|
29
|
+
* @returns {function} Clear function
|
|
43
30
|
*/
|
|
44
|
-
static
|
|
31
|
+
static wait(fn: Function, intval?: number, limit?: number): Function;
|
|
45
32
|
/**
|
|
46
|
-
*
|
|
33
|
+
* Run function in next animation frame
|
|
47
34
|
*
|
|
48
|
-
* @example Run.
|
|
35
|
+
* @example Run.frame(cb)
|
|
49
36
|
*
|
|
50
|
-
* @param {function} fn
|
|
51
|
-
* @param {
|
|
52
|
-
* @
|
|
53
|
-
* @returns {void} No return value
|
|
37
|
+
* @param {function} fn Callback function
|
|
38
|
+
* @param {any} [...args] Callback arguments
|
|
39
|
+
* @returns {function} Noop clear function
|
|
54
40
|
*/
|
|
55
|
-
static
|
|
41
|
+
static frame(fn: Function, ...args: any[]): Function;
|
|
56
42
|
/**
|
|
57
|
-
* Run
|
|
43
|
+
* Run function when browser is idle
|
|
58
44
|
*
|
|
59
|
-
* @example Run.
|
|
45
|
+
* @example Run.idle(cb)
|
|
60
46
|
*
|
|
61
|
-
* @param {function} fn Callback
|
|
62
|
-
* @param {
|
|
63
|
-
* @returns {
|
|
47
|
+
* @param {function} fn Callback function
|
|
48
|
+
* @param {any} [...args] Callback arguments
|
|
49
|
+
* @returns {function} Noop clear function
|
|
64
50
|
*/
|
|
65
|
-
static
|
|
51
|
+
static idle(fn: Function, ...args: any[]): Function;
|
|
66
52
|
/**
|
|
67
|
-
* Run
|
|
53
|
+
* Run function asynchronously
|
|
68
54
|
*
|
|
69
|
-
* @example Run.async(
|
|
55
|
+
* @example Run.async(cb)
|
|
70
56
|
*
|
|
71
|
-
* @param {function} fn Callback
|
|
72
|
-
* @param {
|
|
73
|
-
* @returns {
|
|
57
|
+
* @param {function} fn Callback function
|
|
58
|
+
* @param {any} [...args] Callback arguments
|
|
59
|
+
* @returns {function} Noop clear function
|
|
74
60
|
*/
|
|
75
|
-
static async(fn: Function, ...args: any[]):
|
|
61
|
+
static async(fn: Function, ...args: any[]): Function;
|
|
76
62
|
/**
|
|
77
|
-
* Run
|
|
63
|
+
* Run function after delay
|
|
78
64
|
*
|
|
79
|
-
* @example
|
|
65
|
+
* @example Run.delay(cb, 100)
|
|
80
66
|
*
|
|
81
|
-
* @param {function} fn Callback
|
|
67
|
+
* @param {function} fn Callback function
|
|
82
68
|
* @param {number} [delay] Delay ms
|
|
83
|
-
* @param {
|
|
84
|
-
* @returns {function}
|
|
69
|
+
* @param {any} [...args] Callback arguments
|
|
70
|
+
* @returns {function} Clear function
|
|
85
71
|
*/
|
|
86
72
|
static delay(fn: Function, delay?: number, ...args: any[]): Function;
|
|
87
73
|
/**
|
|
@@ -91,10 +77,9 @@ export class PicoRunner {
|
|
|
91
77
|
*
|
|
92
78
|
* @param {function} cb Callback to run
|
|
93
79
|
* @param {number} [timeout] Wait ms
|
|
94
|
-
* @param {string|null} [index] Debounce id
|
|
95
80
|
* @returns {function} Debounced fn
|
|
96
81
|
*/
|
|
97
|
-
static debounce(cb: Function, timeout?: number
|
|
82
|
+
static debounce(cb: Function, timeout?: number): Function;
|
|
98
83
|
/**
|
|
99
84
|
* Create throttled callback
|
|
100
85
|
*
|
|
@@ -102,10 +87,9 @@ export class PicoRunner {
|
|
|
102
87
|
*
|
|
103
88
|
* @param {function} cb Callback to run
|
|
104
89
|
* @param {number} [timeout] Wait ms
|
|
105
|
-
* @param {string|null} [index] Throttle id
|
|
106
90
|
* @returns {function} Throttled fn
|
|
107
91
|
*/
|
|
108
|
-
static throttle(cb: Function, timeout?: number
|
|
92
|
+
static throttle(cb: Function, timeout?: number): Function;
|
|
109
93
|
/**
|
|
110
94
|
* Create framerate-limited callback
|
|
111
95
|
*
|
package/types/utils/String.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ export class PicoString {
|
|
|
74
74
|
/**
|
|
75
75
|
* @see PicoString.uc
|
|
76
76
|
*/
|
|
77
|
-
static upper: typeof
|
|
77
|
+
static upper: typeof Str.uc;
|
|
78
78
|
/**
|
|
79
79
|
* Uppercase first character
|
|
80
80
|
*
|
|
@@ -96,7 +96,7 @@ export class PicoString {
|
|
|
96
96
|
/**
|
|
97
97
|
* @see PicoString.lc
|
|
98
98
|
*/
|
|
99
|
-
static lower: typeof
|
|
99
|
+
static lower: typeof Str.lc;
|
|
100
100
|
/**
|
|
101
101
|
* Lowercase first character
|
|
102
102
|
*
|
|
@@ -118,7 +118,7 @@ export class PicoString {
|
|
|
118
118
|
/**
|
|
119
119
|
* @see PicoString.cc
|
|
120
120
|
*/
|
|
121
|
-
static camelcase: typeof
|
|
121
|
+
static camelcase: typeof Str.cc;
|
|
122
122
|
/**
|
|
123
123
|
* Convert to kebab-case
|
|
124
124
|
*
|
|
@@ -131,7 +131,7 @@ export class PicoString {
|
|
|
131
131
|
/**
|
|
132
132
|
* @see PicoString.kc
|
|
133
133
|
*/
|
|
134
|
-
static kebabcase: typeof
|
|
134
|
+
static kebabcase: typeof Str.kc;
|
|
135
135
|
/**
|
|
136
136
|
* Convert to snake_case
|
|
137
137
|
*
|
|
@@ -144,7 +144,7 @@ export class PicoString {
|
|
|
144
144
|
/**
|
|
145
145
|
* @see PicoString.sc
|
|
146
146
|
*/
|
|
147
|
-
static snakecase: typeof
|
|
147
|
+
static snakecase: typeof Str.sc;
|
|
148
148
|
/**
|
|
149
149
|
* Convert to PascalCase
|
|
150
150
|
*
|
|
@@ -157,7 +157,7 @@ export class PicoString {
|
|
|
157
157
|
/**
|
|
158
158
|
* @see PicoString.pc
|
|
159
159
|
*/
|
|
160
|
-
static pascalcase: typeof
|
|
160
|
+
static pascalcase: typeof Str.pc;
|
|
161
161
|
/**
|
|
162
162
|
* Check if string contains value
|
|
163
163
|
*
|
|
@@ -327,4 +327,5 @@ export namespace PicoString {
|
|
|
327
327
|
function real(): void;
|
|
328
328
|
function array(): void;
|
|
329
329
|
}
|
|
330
|
-
export default
|
|
330
|
+
export default Str;
|
|
331
|
+
import { Str } from "../index.esm.js";
|