@kizmann/pico-js 2.0.4 → 2.0.6
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/utils/Array.js +126 -48
- package/src/utils/Cookie.js +1 -1
- package/src/utils/Mixed.js +2 -2
- package/src/utils/Object.js +67 -19
- package/src/utils/Route.js +4 -2
- package/src/utils/Runner.js +111 -132
- package/types/dom/DomEvent.d.ts +10 -1
- package/types/utils/Array.d.ts +27 -6
- package/types/utils/Mixed.d.ts +1 -2
- package/types/utils/Object.d.ts +2 -8
- package/types/utils/Runner.d.ts +45 -61
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
|
*
|
|
@@ -123,10 +107,10 @@ export class PicoRunner {
|
|
|
123
107
|
*
|
|
124
108
|
* @param {function} cb Callback to run
|
|
125
109
|
* @param {string} key Buffer key
|
|
126
|
-
* @param {number} [
|
|
110
|
+
* @param {number} [priority] Sort priority
|
|
127
111
|
* @returns {function} Buffered handler
|
|
128
112
|
*/
|
|
129
|
-
static framebuffer(cb: Function, key: string,
|
|
113
|
+
static framebuffer(cb: Function, key: string, priority?: number): Function;
|
|
130
114
|
/**
|
|
131
115
|
* Flush buffered frame events
|
|
132
116
|
*
|