cafe-utility 10.2.0 → 10.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.
Files changed (3) hide show
  1. package/index.d.ts +6 -0
  2. package/index.js +13 -1
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -300,6 +300,11 @@ export declare class Maybe<T> {
300
300
  bind<K>(fn: (value: T) => K): Maybe<Awaited<K>>;
301
301
  valueOf(): Promise<T | null>;
302
302
  }
303
+ declare type Playbook<T> = {
304
+ ttl: number;
305
+ data: T;
306
+ }[];
307
+ declare function tickPlaybook<T>(playbook: Playbook<T>): T | null;
303
308
  declare type Point = {
304
309
  x: number;
305
310
  y: number;
@@ -362,6 +367,7 @@ export declare const Arrays: {
362
367
  group: typeof group;
363
368
  createOscillator: typeof createOscillator;
364
369
  organiseWithLimits: typeof organiseWithLimits;
370
+ tickPlaybook: typeof tickPlaybook;
365
371
  };
366
372
  export declare const System: {
367
373
  sleepMillis: typeof sleepMillis;
package/index.js CHANGED
@@ -2044,6 +2044,17 @@ class Maybe {
2044
2044
  }
2045
2045
 
2046
2046
  exports.Maybe = Maybe
2047
+ function tickPlaybook(playbook) {
2048
+ if (playbook.length === 0) {
2049
+ return null
2050
+ }
2051
+ const item = playbook[0]
2052
+ if (--item.ttl <= 0) {
2053
+ playbook.shift()
2054
+ }
2055
+ return item.data
2056
+ }
2057
+
2047
2058
  function addPoint(a, b) {
2048
2059
  return {
2049
2060
  x: a.x + b.x,
@@ -2370,7 +2381,8 @@ exports.Arrays = {
2370
2381
  atRolling,
2371
2382
  group,
2372
2383
  createOscillator,
2373
- organiseWithLimits
2384
+ organiseWithLimits,
2385
+ tickPlaybook
2374
2386
  }
2375
2387
 
2376
2388
  exports.System = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "10.2.0",
3
+ "version": "10.3.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {