@kizmann/pico-js 2.0.7 → 2.0.8
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 +1 -1
- package/src/dom/DomEvent.js +25 -1
- package/src/dom/DomFinder.js +19 -15
- package/src/dom/DomRectangle.js +5 -1
- package/src/utils/Array.js +49 -0
- package/src/utils/Mixed.js +35 -4
- package/src/utils/Runner.js +33 -39
- package/types/dom/DomEvent.d.ts +1 -0
- package/types/dom/DomFinder.d.ts +5 -5
- package/types/dom/DomRectangle.d.ts +6 -1
- package/types/utils/Array.d.ts +3 -0
- package/types/utils/Mixed.d.ts +1 -0
- package/types/utils/Runner.d.ts +7 -17
package/package.json
CHANGED
package/src/dom/DomEvent.js
CHANGED
|
@@ -158,7 +158,7 @@ export class PicoDomEventInstance
|
|
|
158
158
|
*/
|
|
159
159
|
optoff(options = {})
|
|
160
160
|
{
|
|
161
|
-
Run.
|
|
161
|
+
Run.async(() => {
|
|
162
162
|
Arr.filterRemove(Dom.$events, { options });
|
|
163
163
|
});
|
|
164
164
|
|
|
@@ -240,6 +240,30 @@ export class PicoDomEventInstance
|
|
|
240
240
|
return this;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
+
pointerdown(button = 1)
|
|
244
|
+
{
|
|
245
|
+
const rect = this.rect();
|
|
246
|
+
|
|
247
|
+
const [x, y] = [
|
|
248
|
+
rect.left + rect.width / 2,
|
|
249
|
+
rect.top + rect.height / 2,
|
|
250
|
+
];
|
|
251
|
+
|
|
252
|
+
const event = new PointerEvent('pointerdown', {
|
|
253
|
+
view: window,
|
|
254
|
+
bubbles: true,
|
|
255
|
+
cancelable: true,
|
|
256
|
+
buttons: 1,
|
|
257
|
+
clientX: x, clientY: y
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
this.each((el) => {
|
|
261
|
+
el.dispatchEvent(event);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
return this;
|
|
265
|
+
}
|
|
266
|
+
|
|
243
267
|
}
|
|
244
268
|
|
|
245
269
|
/**
|
package/src/dom/DomFinder.js
CHANGED
|
@@ -28,20 +28,25 @@ export class PicoDomFinderStatic
|
|
|
28
28
|
*
|
|
29
29
|
* @example Dom.getNodePoint(100, 100)
|
|
30
30
|
*
|
|
31
|
-
* @param {
|
|
32
|
-
* @param {number} posy Y position
|
|
31
|
+
* @param {object} event Event data
|
|
33
32
|
* @returns {Array<Element>} Nodes at point
|
|
34
33
|
*/
|
|
35
|
-
static getNodePoint(
|
|
34
|
+
static getNodePoint(event)
|
|
36
35
|
{
|
|
37
|
-
|
|
36
|
+
if ( event.touches?.[0] ) {
|
|
37
|
+
// event = event.touches[0];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let [el, src] = [
|
|
41
|
+
null, [event.clientX, event.clientY]
|
|
42
|
+
];
|
|
38
43
|
|
|
39
44
|
if ( Dom.doc().elementsFromPoint != null ) {
|
|
40
|
-
el = document.elementsFromPoint(
|
|
45
|
+
el = document.elementsFromPoint(src[0], src[1]);
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
if ( Dom.doc().msElementsFromPoint != null ) {
|
|
44
|
-
el = document.msElementsFromPoint(
|
|
49
|
+
el = document.msElementsFromPoint(src[0], src[1]);
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
return el;
|
|
@@ -64,10 +69,10 @@ export class PicoDomFinderStatic
|
|
|
64
69
|
target = event.target;
|
|
65
70
|
}
|
|
66
71
|
|
|
67
|
-
let { type
|
|
72
|
+
let { type } = event;
|
|
68
73
|
|
|
69
74
|
if ( /^(drag[a-z]*|drop$)/.test(type) ) {
|
|
70
|
-
target = Dom.getNodePoint(
|
|
75
|
+
target = Dom.getNodePoint(event);
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
if ( Mix.isArr(target) ) {
|
|
@@ -389,12 +394,10 @@ export class PicoDomFinderInstance
|
|
|
389
394
|
* @param {number} [filter] Node type
|
|
390
395
|
* @returns {PicoDom} Child instance
|
|
391
396
|
*/
|
|
392
|
-
child(selector, filter = 1)
|
|
397
|
+
child(selector = null, filter = 1)
|
|
393
398
|
{
|
|
394
|
-
for ( let el of this.
|
|
395
|
-
|
|
396
|
-
return Dom.find(el);
|
|
397
|
-
}
|
|
399
|
+
for ( let el of this.childs(selector, filter) ) {
|
|
400
|
+
return Dom.find(el);
|
|
398
401
|
}
|
|
399
402
|
|
|
400
403
|
return Dom.find(null);
|
|
@@ -506,16 +509,17 @@ export class PicoDomFinderInstance
|
|
|
506
509
|
* @example Dom.find("div").is(".active") // => true
|
|
507
510
|
*
|
|
508
511
|
* @param {any} selector Test selector
|
|
512
|
+
* @param {boolean} [empty] Test selector
|
|
509
513
|
* @returns {boolean} True if matches
|
|
510
514
|
*/
|
|
511
|
-
is(selector)
|
|
515
|
+
is(selector, empty = false)
|
|
512
516
|
{
|
|
513
517
|
if ( this.el === selector ) {
|
|
514
518
|
return true;
|
|
515
519
|
}
|
|
516
520
|
|
|
517
521
|
if ( this.el == null ) {
|
|
518
|
-
return
|
|
522
|
+
return empty;
|
|
519
523
|
}
|
|
520
524
|
|
|
521
525
|
for ( let el of this.parent().find(selector).get() ) {
|
package/src/dom/DomRectangle.js
CHANGED
|
@@ -30,8 +30,12 @@ export class PicoDomRectangleStatic
|
|
|
30
30
|
*/
|
|
31
31
|
export class PicoDomRectangleInstance
|
|
32
32
|
{
|
|
33
|
-
rect(fallback = {})
|
|
33
|
+
rect(fallback = { left: 0, top: 0, width: 0, height: 0 })
|
|
34
34
|
{
|
|
35
|
+
if ( ! this.el.getBoundingClientRect ) {
|
|
36
|
+
return fallback;
|
|
37
|
+
}
|
|
38
|
+
|
|
35
39
|
const rect = this.el.getBoundingClientRect();
|
|
36
40
|
|
|
37
41
|
if ( rect == null ) {
|
package/src/utils/Array.js
CHANGED
|
@@ -70,6 +70,32 @@ export class PicoArray
|
|
|
70
70
|
return this.splice(target, index, 1);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
static prev(target, index, fallback = 0)
|
|
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, index, fallback = 0)
|
|
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
|
*
|
|
@@ -350,6 +376,29 @@ export class PicoArray
|
|
|
350
376
|
return value;
|
|
351
377
|
}
|
|
352
378
|
|
|
379
|
+
static cascade(value, childs, key, cascade = [], result = {})
|
|
380
|
+
{
|
|
381
|
+
if ( value == null ) {
|
|
382
|
+
return result;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if ( Mix.isObj(value) ) {
|
|
386
|
+
return this.cascade(value[key], key, cb);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const fn = (val) => {
|
|
390
|
+
return this.cascade(...[
|
|
391
|
+
val[childs], childs, key, result[val[key]], result
|
|
392
|
+
]);
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
this.each(value, (val) => {
|
|
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
|
*
|
package/src/utils/Mixed.js
CHANGED
|
@@ -528,7 +528,7 @@ export class PicoMixed
|
|
|
528
528
|
let result = {};
|
|
529
529
|
|
|
530
530
|
for ( const key of Object.getOwnPropertyNames(value) ) {
|
|
531
|
-
if ( exclude.length && !
|
|
531
|
+
if ( exclude.length && !Arr.has(exclude, key) ) {
|
|
532
532
|
result[key] = value[key];
|
|
533
533
|
}
|
|
534
534
|
}
|
|
@@ -536,6 +536,38 @@ export class PicoMixed
|
|
|
536
536
|
return result;
|
|
537
537
|
}
|
|
538
538
|
|
|
539
|
+
static extend(target, value, exclude = ['constructor'])
|
|
540
|
+
{
|
|
541
|
+
if ( value == null ) {
|
|
542
|
+
return {};
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
let proto = Object.getPrototypeOf(value);
|
|
546
|
+
|
|
547
|
+
for ( const key of Object.getOwnPropertyNames(value) ) {
|
|
548
|
+
|
|
549
|
+
if ( !exclude.length || Arr.has(exclude, key) ) {
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
let desc = Object.getOwnPropertyDescriptor(proto, key);
|
|
554
|
+
|
|
555
|
+
if ( !desc ) {
|
|
556
|
+
desc = Object.getOwnPropertyDescriptor(value, key);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
if ( !desc && (!desc.get && !desc.set) ) {
|
|
560
|
+
target[key] = value[key];
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
if ( desc && (desc.get || desc.set) ) {
|
|
564
|
+
Object.defineProperty(target, key, desc);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
return target;
|
|
569
|
+
}
|
|
570
|
+
|
|
539
571
|
/**
|
|
540
572
|
* Get static class props
|
|
541
573
|
*
|
|
@@ -631,7 +663,7 @@ export class PicoMixed
|
|
|
631
663
|
return value.length;
|
|
632
664
|
}
|
|
633
665
|
|
|
634
|
-
if ( !
|
|
666
|
+
if ( !this.isRef(value) ) {
|
|
635
667
|
return this.string(value).length;
|
|
636
668
|
}
|
|
637
669
|
|
|
@@ -691,7 +723,7 @@ export class PicoMixed
|
|
|
691
723
|
return value;
|
|
692
724
|
}
|
|
693
725
|
|
|
694
|
-
if ( !
|
|
726
|
+
if ( !this.isStr(value) ) {
|
|
695
727
|
return [value];
|
|
696
728
|
}
|
|
697
729
|
|
|
@@ -891,5 +923,4 @@ PicoMixed.convertBoolean = function (...args) {
|
|
|
891
923
|
};
|
|
892
924
|
|
|
893
925
|
|
|
894
|
-
|
|
895
926
|
export default PicoMixed;
|
package/src/utils/Runner.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Arr,
|
|
1
|
+
import { Arr, Mix, Obj } from "../index.esm.js";
|
|
2
2
|
|
|
3
3
|
export class PicoRunner
|
|
4
4
|
{
|
|
@@ -8,6 +8,15 @@ export class PicoRunner
|
|
|
8
8
|
|
|
9
9
|
static $buffer = [];
|
|
10
10
|
|
|
11
|
+
static interval(fn, intval = 0)
|
|
12
|
+
{
|
|
13
|
+
const idle = setInterval(() => {
|
|
14
|
+
fn();
|
|
15
|
+
}, intval);
|
|
16
|
+
|
|
17
|
+
return () => clearInterval(idle);
|
|
18
|
+
}
|
|
19
|
+
|
|
11
20
|
/**
|
|
12
21
|
* Clear timer or call function
|
|
13
22
|
*
|
|
@@ -41,7 +50,7 @@ export class PicoRunner
|
|
|
41
50
|
static tryin(cb)
|
|
42
51
|
{
|
|
43
52
|
try {
|
|
44
|
-
|
|
53
|
+
cb();
|
|
45
54
|
} catch (e) {
|
|
46
55
|
//
|
|
47
56
|
}
|
|
@@ -80,34 +89,16 @@ export class PicoRunner
|
|
|
80
89
|
* @example Run.frame(cb)
|
|
81
90
|
*
|
|
82
91
|
* @param {function} fn Callback function
|
|
83
|
-
* @param {any} [
|
|
84
|
-
* @returns {function} Noop clear function
|
|
85
|
-
*/
|
|
86
|
-
static frame(fn, ...args)
|
|
87
|
-
{
|
|
88
|
-
requestAnimationFrame(() => {
|
|
89
|
-
fn(...args)
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
return () => null;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Run function when browser is idle
|
|
97
|
-
*
|
|
98
|
-
* @example Run.idle(cb)
|
|
99
|
-
*
|
|
100
|
-
* @param {function} fn Callback function
|
|
101
|
-
* @param {any} [...args] Callback arguments
|
|
92
|
+
* @param {any} [options] Callback options
|
|
102
93
|
* @returns {function} Noop clear function
|
|
103
94
|
*/
|
|
104
|
-
static
|
|
95
|
+
static frame(fn, options = {})
|
|
105
96
|
{
|
|
106
|
-
|
|
107
|
-
fn(
|
|
97
|
+
const frame = requestAnimationFrame(() => {
|
|
98
|
+
fn();
|
|
108
99
|
});
|
|
109
100
|
|
|
110
|
-
return () =>
|
|
101
|
+
return () => cancelAnimationFrame(frame);
|
|
111
102
|
}
|
|
112
103
|
|
|
113
104
|
/**
|
|
@@ -116,16 +107,15 @@ export class PicoRunner
|
|
|
116
107
|
* @example Run.async(cb)
|
|
117
108
|
*
|
|
118
109
|
* @param {function} fn Callback function
|
|
119
|
-
* @param {any} [...args] Callback arguments
|
|
120
110
|
* @returns {function} Noop clear function
|
|
121
111
|
*/
|
|
122
|
-
static async(fn
|
|
112
|
+
static async(fn)
|
|
123
113
|
{
|
|
124
|
-
setTimeout(() => {
|
|
125
|
-
fn(
|
|
114
|
+
const idle = setTimeout(() => {
|
|
115
|
+
fn()
|
|
126
116
|
});
|
|
127
117
|
|
|
128
|
-
return () =>
|
|
118
|
+
return () => clearTimeout(idle);
|
|
129
119
|
}
|
|
130
120
|
|
|
131
121
|
/**
|
|
@@ -135,13 +125,12 @@ export class PicoRunner
|
|
|
135
125
|
*
|
|
136
126
|
* @param {function} fn Callback function
|
|
137
127
|
* @param {number} [delay] Delay ms
|
|
138
|
-
* @param {any} [...args] Callback arguments
|
|
139
128
|
* @returns {function} Clear function
|
|
140
129
|
*/
|
|
141
|
-
static delay(fn, delay = 0
|
|
130
|
+
static delay(fn, delay = 0)
|
|
142
131
|
{
|
|
143
132
|
let idler = setTimeout(() => {
|
|
144
|
-
fn(
|
|
133
|
+
fn();
|
|
145
134
|
}, delay);
|
|
146
135
|
|
|
147
136
|
return () => clearTimeout(idler);
|
|
@@ -210,20 +199,25 @@ export class PicoRunner
|
|
|
210
199
|
*
|
|
211
200
|
* @param {function} cb Callback to run
|
|
212
201
|
* @param {number} [fps] Max frames per sec
|
|
202
|
+
* @param {boolean} [finish] Finish last frame
|
|
213
203
|
* @returns {function} Rate-limited fn
|
|
214
204
|
*/
|
|
215
|
-
static framerate(cb, fps = 30)
|
|
205
|
+
static framerate(cb, fps = 30, finish = true)
|
|
216
206
|
{
|
|
217
|
-
let last = 0;
|
|
207
|
+
let timer, last = 0, hertz = 1000 / fps;
|
|
218
208
|
|
|
219
|
-
|
|
209
|
+
const fn = (...args) => {
|
|
220
210
|
|
|
221
|
-
|
|
222
|
-
|
|
211
|
+
clearTimeout(timer);
|
|
212
|
+
|
|
213
|
+
if ( Date.now() - last <= hertz ) {
|
|
214
|
+
return finish && (timer = setTimeout(fn, hertz + 1));
|
|
223
215
|
}
|
|
224
216
|
|
|
225
|
-
(this.frame(cb
|
|
217
|
+
(this.frame(() => cb(...args)), last = Date.now());
|
|
226
218
|
};
|
|
219
|
+
|
|
220
|
+
return fn;
|
|
227
221
|
}
|
|
228
222
|
|
|
229
223
|
/**
|
package/types/dom/DomEvent.d.ts
CHANGED
package/types/dom/DomFinder.d.ts
CHANGED
|
@@ -17,11 +17,10 @@ export class PicoDomFinderStatic {
|
|
|
17
17
|
*
|
|
18
18
|
* @example Dom.getNodePoint(100, 100)
|
|
19
19
|
*
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {number} posy Y position
|
|
20
|
+
* @param {object} event Event data
|
|
22
21
|
* @returns {Array<Element>} Nodes at point
|
|
23
22
|
*/
|
|
24
|
-
static getNodePoint(
|
|
23
|
+
static getNodePoint(event: object): Array<Element>;
|
|
25
24
|
/**
|
|
26
25
|
* Get target by selector
|
|
27
26
|
*
|
|
@@ -193,7 +192,7 @@ export class PicoDomFinderInstance {
|
|
|
193
192
|
* @param {number} [filter] Node type
|
|
194
193
|
* @returns {PicoDom} Child instance
|
|
195
194
|
*/
|
|
196
|
-
child(selector
|
|
195
|
+
child(selector?: any, filter?: number): PicoDom;
|
|
197
196
|
/**
|
|
198
197
|
* Get child elements
|
|
199
198
|
*
|
|
@@ -246,9 +245,10 @@ export class PicoDomFinderInstance {
|
|
|
246
245
|
* @example Dom.find("div").is(".active") // => true
|
|
247
246
|
*
|
|
248
247
|
* @param {any} selector Test selector
|
|
248
|
+
* @param {boolean} [empty] Test selector
|
|
249
249
|
* @returns {boolean} True if matches
|
|
250
250
|
*/
|
|
251
|
-
is(selector: any): boolean;
|
|
251
|
+
is(selector: any, empty?: boolean): boolean;
|
|
252
252
|
/**
|
|
253
253
|
* Check if contains match
|
|
254
254
|
*
|
|
@@ -17,7 +17,12 @@ export class PicoDomRectangleStatic {
|
|
|
17
17
|
* @extends {PicoDom}
|
|
18
18
|
*/
|
|
19
19
|
export class PicoDomRectangleInstance {
|
|
20
|
-
rect(fallback?: {
|
|
20
|
+
rect(fallback?: {
|
|
21
|
+
left: number;
|
|
22
|
+
top: number;
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
}): any;
|
|
21
26
|
/**
|
|
22
27
|
* Get margin values
|
|
23
28
|
*
|
package/types/utils/Array.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ export class PicoArray {
|
|
|
42
42
|
* @returns {any} Splice result
|
|
43
43
|
*/
|
|
44
44
|
static unset(target: Array<any>, index: number): any;
|
|
45
|
+
static prev(target: any, index: any, fallback?: number): number;
|
|
46
|
+
static next(target: any, index: any, fallback?: number): any;
|
|
45
47
|
/**
|
|
46
48
|
* Create array with callback values
|
|
47
49
|
*
|
|
@@ -167,6 +169,7 @@ export class PicoArray {
|
|
|
167
169
|
* @returns {any} Mapped tree
|
|
168
170
|
*/
|
|
169
171
|
static recursive(value: any, key: string, cb: Function, cascade?: Array<any>): any;
|
|
172
|
+
static cascade(value: any, childs: any, key: any, cascade?: any[], result?: {}): any;
|
|
170
173
|
/**
|
|
171
174
|
* Get matching indexes by filter
|
|
172
175
|
*
|
package/types/utils/Mixed.d.ts
CHANGED
|
@@ -294,6 +294,7 @@ export class PicoMixed {
|
|
|
294
294
|
* @returns {Record<string, any>} Props map
|
|
295
295
|
*/
|
|
296
296
|
static props(value: any, exclude?: Array<any>): Record<string, any>;
|
|
297
|
+
static extend(target: any, value: any, exclude?: string[]): any;
|
|
297
298
|
/**
|
|
298
299
|
* Get static class props
|
|
299
300
|
*
|
package/types/utils/Runner.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export class PicoRunner {
|
|
|
2
2
|
static $idler: any;
|
|
3
3
|
static $timer: number;
|
|
4
4
|
static $buffer: any[];
|
|
5
|
+
static interval(fn: any, intval?: number): () => void;
|
|
5
6
|
/**
|
|
6
7
|
* Clear timer or call function
|
|
7
8
|
*
|
|
@@ -35,30 +36,19 @@ export class PicoRunner {
|
|
|
35
36
|
* @example Run.frame(cb)
|
|
36
37
|
*
|
|
37
38
|
* @param {function} fn Callback function
|
|
38
|
-
* @param {any} [
|
|
39
|
+
* @param {any} [options] Callback options
|
|
39
40
|
* @returns {function} Noop clear function
|
|
40
41
|
*/
|
|
41
|
-
static frame(fn: Function,
|
|
42
|
-
/**
|
|
43
|
-
* Run function when browser is idle
|
|
44
|
-
*
|
|
45
|
-
* @example Run.idle(cb)
|
|
46
|
-
*
|
|
47
|
-
* @param {function} fn Callback function
|
|
48
|
-
* @param {any} [...args] Callback arguments
|
|
49
|
-
* @returns {function} Noop clear function
|
|
50
|
-
*/
|
|
51
|
-
static idle(fn: Function, ...args: any[]): Function;
|
|
42
|
+
static frame(fn: Function, options?: any): Function;
|
|
52
43
|
/**
|
|
53
44
|
* Run function asynchronously
|
|
54
45
|
*
|
|
55
46
|
* @example Run.async(cb)
|
|
56
47
|
*
|
|
57
48
|
* @param {function} fn Callback function
|
|
58
|
-
* @param {any} [...args] Callback arguments
|
|
59
49
|
* @returns {function} Noop clear function
|
|
60
50
|
*/
|
|
61
|
-
static async(fn: Function
|
|
51
|
+
static async(fn: Function): Function;
|
|
62
52
|
/**
|
|
63
53
|
* Run function after delay
|
|
64
54
|
*
|
|
@@ -66,10 +56,9 @@ export class PicoRunner {
|
|
|
66
56
|
*
|
|
67
57
|
* @param {function} fn Callback function
|
|
68
58
|
* @param {number} [delay] Delay ms
|
|
69
|
-
* @param {any} [...args] Callback arguments
|
|
70
59
|
* @returns {function} Clear function
|
|
71
60
|
*/
|
|
72
|
-
static delay(fn: Function, delay?: number
|
|
61
|
+
static delay(fn: Function, delay?: number): Function;
|
|
73
62
|
/**
|
|
74
63
|
* Create debounced callback
|
|
75
64
|
*
|
|
@@ -97,9 +86,10 @@ export class PicoRunner {
|
|
|
97
86
|
*
|
|
98
87
|
* @param {function} cb Callback to run
|
|
99
88
|
* @param {number} [fps] Max frames per sec
|
|
89
|
+
* @param {boolean} [finish] Finish last frame
|
|
100
90
|
* @returns {function} Rate-limited fn
|
|
101
91
|
*/
|
|
102
|
-
static framerate(cb: Function, fps?: number): Function;
|
|
92
|
+
static framerate(cb: Function, fps?: number, finish?: boolean): Function;
|
|
103
93
|
/**
|
|
104
94
|
* Buffer events into single frame
|
|
105
95
|
*
|