cafe-utility 19.2.0 → 19.3.0
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/index.d.ts +2 -0
- package/index.js +5 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -410,6 +410,7 @@ interface Newable<T> extends Function {
|
|
|
410
410
|
declare function findInstance<T, K extends T>(array: T[], type: Newable<K>): Optional<K>;
|
|
411
411
|
declare function filterInstances<T, K extends T>(array: T[], type: Newable<K>): K[];
|
|
412
412
|
declare function interleave<T, K>(arrayA: T[], arrayB: K[]): (T | K)[];
|
|
413
|
+
declare function toggle<T>(array: T[], value: T): T[];
|
|
413
414
|
type Playbook<T> = {
|
|
414
415
|
ttl: number;
|
|
415
416
|
ttlMax?: number;
|
|
@@ -501,6 +502,7 @@ export declare const Arrays: {
|
|
|
501
502
|
findInstance: typeof findInstance;
|
|
502
503
|
filterInstances: typeof filterInstances;
|
|
503
504
|
interleave: typeof interleave;
|
|
505
|
+
toggle: typeof toggle;
|
|
504
506
|
};
|
|
505
507
|
export declare const System: {
|
|
506
508
|
sleepMillis: typeof sleepMillis;
|
package/index.js
CHANGED
|
@@ -1876,6 +1876,9 @@ function interleave(n, t) {
|
|
|
1876
1876
|
for (let o = 0; o < r; o++) n[o] && e.push(n[o]), t[o] && e.push(t[o])
|
|
1877
1877
|
return e
|
|
1878
1878
|
}
|
|
1879
|
+
function toggle(n, t) {
|
|
1880
|
+
return n.includes(t) ? n.filter(e => e !== t) : [...n, t]
|
|
1881
|
+
}
|
|
1879
1882
|
function tickPlaybook(n) {
|
|
1880
1883
|
if (n.length === 0) return null
|
|
1881
1884
|
const t = n[0]
|
|
@@ -2158,7 +2161,8 @@ function raycastCircle(n, t, e) {
|
|
|
2158
2161
|
bringToFrontInPlace,
|
|
2159
2162
|
findInstance,
|
|
2160
2163
|
filterInstances,
|
|
2161
|
-
interleave
|
|
2164
|
+
interleave,
|
|
2165
|
+
toggle
|
|
2162
2166
|
}),
|
|
2163
2167
|
(exports.System = { sleepMillis, forever, scheduleMany, waitFor, expandError }),
|
|
2164
2168
|
(exports.Numbers = {
|