lenix 1.8.5 → 1.8.7
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/client/control.ts +5 -2
- package/nui/fetch.ts +0 -1
- package/package.json +1 -1
- package/shared/repeat.ts +23 -21
package/client/control.ts
CHANGED
|
@@ -124,9 +124,12 @@ const on = ({
|
|
|
124
124
|
}) => {
|
|
125
125
|
asserts(CONTROLS[key], `Could not find key<${key}>`)
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
const bind = {
|
|
128
128
|
event, key, onEvent: cb, type
|
|
129
|
-
}
|
|
129
|
+
}
|
|
130
|
+
binds.add(bind)
|
|
131
|
+
|
|
132
|
+
return () => binds.delete(bind)
|
|
130
133
|
}
|
|
131
134
|
const disable = ({
|
|
132
135
|
key,
|
package/nui/fetch.ts
CHANGED
package/package.json
CHANGED
package/shared/repeat.ts
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
/* */
|
|
2
|
-
export function repeat<T>(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
until: () => T,
|
|
7
|
-
equal: C,
|
|
2
|
+
export function repeat<T>(check: () => T): Promise<T>
|
|
3
|
+
export function repeat<T, C extends T>(
|
|
4
|
+
check: () => T,
|
|
5
|
+
untilOrEqual: C | ((checked: T) => checked is C),
|
|
8
6
|
each?: number,
|
|
9
7
|
): Promise<C>
|
|
10
|
-
export function repeat
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
each?: number
|
|
8
|
+
export function repeat<T>(
|
|
9
|
+
check: () => T,
|
|
10
|
+
untilOrEqual?: T | ((checked: T) => boolean),
|
|
11
|
+
each?: number,
|
|
14
12
|
): Promise<T> {
|
|
13
|
+
const hasCondition = arguments.length > 1
|
|
14
|
+
const predicate = typeof untilOrEqual === 'function'
|
|
15
|
+
? untilOrEqual as (checked: T) => boolean
|
|
16
|
+
: undefined
|
|
17
|
+
|
|
15
18
|
return new Promise(resolve => {
|
|
16
19
|
const interval = setInterval(() => {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
if (equal === undefined) {
|
|
20
|
-
if (result === undefined || result === null) return
|
|
21
|
-
resolve(result)
|
|
22
|
-
clearInterval(interval)
|
|
23
|
-
return
|
|
24
|
-
}
|
|
20
|
+
const checked = check()
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+
const met = predicate
|
|
23
|
+
? predicate(checked)
|
|
24
|
+
: hasCondition
|
|
25
|
+
? checked === untilOrEqual
|
|
26
|
+
: checked !== undefined && checked !== null
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
if (!met) return
|
|
29
|
+
|
|
29
30
|
clearInterval(interval)
|
|
31
|
+
resolve(checked)
|
|
30
32
|
}, each)
|
|
31
33
|
})
|
|
32
|
-
}
|
|
34
|
+
}
|