@thi.ng/fibers 0.2.3 → 0.3.1

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-08-12T13:14:08Z
3
+ - **Last updated**: 2023-08-22T14:39:27Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,14 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [0.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/fibers@0.3.0) (2023-08-14)
13
+
14
+ #### 🚀 Features
15
+
16
+ - update .run() default handlers ([6137e7a](https://github.com/thi-ng/umbrella/commit/6137e7a))
17
+ - use `setImmediate()` as default for non-browser env
18
+ - update tests
19
+
12
20
  ## [0.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/fibers@0.2.0) (2023-08-10)
13
21
 
14
22
  #### 🚀 Features
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
9
9
 
10
10
  This project is part of the
11
- [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
11
+ [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo and anti-framework.
12
12
 
13
13
  - [About](#about)
14
14
  - [Basic usage](#basic-usage)
@@ -376,7 +376,7 @@ For Node.js REPL:
376
376
  const fibers = await import("@thi.ng/fibers");
377
377
  ```
378
378
 
379
- Package sizes (brotli'd, pre-treeshake): ESM: 2.25 KB
379
+ Package sizes (brotli'd, pre-treeshake): ESM: 2.27 KB
380
380
 
381
381
  ## Dependencies
382
382
 
@@ -397,9 +397,10 @@ directory are using this package.
397
397
 
398
398
  A selection:
399
399
 
400
- | Screenshot | Description | Live demo | Source |
401
- |:--------------------------------------------------------------------------------------------------------------------|:--------------------------------------------|:---------------------------------------------------|:--------------------------------------------------------------------------------|
402
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/fiber-basics.png" width="240"/> | Fiber-based cooperative multitasking basics | [Demo](https://demo.thi.ng/umbrella/fiber-basics/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/fiber-basics) |
400
+ | Screenshot | Description | Live demo | Source |
401
+ |:----------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------|:-----------------------------------------------------|:----------------------------------------------------------------------------------|
402
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/ascii-raymarch.jpg" width="240"/> | ASCII art raymarching with thi.ng/shader-ast & thi.ng/text-canvas | [Demo](https://demo.thi.ng/umbrella/ascii-raymarch/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/ascii-raymarch) |
403
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/fiber-basics.png" width="240"/> | Fiber-based cooperative multitasking basics | [Demo](https://demo.thi.ng/umbrella/fiber-basics/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/fiber-basics) |
403
404
 
404
405
  ## API
405
406
 
package/fiber.d.ts CHANGED
@@ -163,13 +163,19 @@ export declare class Fiber<T = any> implements IDeref<T | undefined>, IID<string
163
163
  removeListener(id: FiberEventType, fn: Listener<FiberEventType>, scope?: any): boolean;
164
164
  notify(event: $Event<FiberEventType>): boolean;
165
165
  /**
166
- * Calls {@link Fiber.runWith} using default loop handlers
167
- * (`requestAnimationFrame()` in browsers, `setTimeout(fn, 16)` otherwise).
166
+ * Calls {@link Fiber.runWith} using default loop handlers.
167
+ *
168
+ * @remarks
169
+ * Current default handlers:
170
+ *
171
+ * - `requestAnimationFrame()` in browsers
172
+ * - `setImmediate()` in NodeJs
173
+ * - `setTimeout(fn, 1)` otherwise
168
174
  */
169
175
  run(): this;
170
176
  /**
171
177
  * Starts fiber execution using the provided higher-order loop/interval
172
- * `handler` (e.g. see {@link Fiber.start}).
178
+ * `handler` (e.g. see {@link Fiber.run}).
173
179
  *
174
180
  * @remarks
175
181
  * That given `handler` is used to repeatedly schedule the next execution of
package/fiber.js CHANGED
@@ -299,17 +299,25 @@ export let Fiber = Fiber_1 = class Fiber {
299
299
  // @ts-ignore mixin
300
300
  notify(event) { }
301
301
  /**
302
- * Calls {@link Fiber.runWith} using default loop handlers
303
- * (`requestAnimationFrame()` in browsers, `setTimeout(fn, 16)` otherwise).
302
+ * Calls {@link Fiber.runWith} using default loop handlers.
303
+ *
304
+ * @remarks
305
+ * Current default handlers:
306
+ *
307
+ * - `requestAnimationFrame()` in browsers
308
+ * - `setImmediate()` in NodeJs
309
+ * - `setTimeout(fn, 1)` otherwise
304
310
  */
305
311
  run() {
306
312
  return this.runWith(typeof requestAnimationFrame === "function"
307
313
  ? requestAnimationFrame
308
- : (fn) => setTimeout(fn, 16));
314
+ : typeof setImmediate === "function"
315
+ ? setImmediate
316
+ : (fn) => setTimeout(fn, 1));
309
317
  }
310
318
  /**
311
319
  * Starts fiber execution using the provided higher-order loop/interval
312
- * `handler` (e.g. see {@link Fiber.start}).
320
+ * `handler` (e.g. see {@link Fiber.run}).
313
321
  *
314
322
  * @remarks
315
323
  * That given `handler` is used to repeatedly schedule the next execution of
package/ops.d.ts CHANGED
@@ -107,10 +107,9 @@ export declare function untilState<T>(state: T, pred: Predicate<T>): Generator<u
107
107
  * Returns a fiber which "blocks" until the given `promise` resolves or rejects.
108
108
  * In the latter case, the fiber will throw the received error.
109
109
  *
110
- * @remove
111
- * If the erroring fiber was added directly to a {@link FiberPool}, the error
112
- * will be logged and the fiber removed. See {@link FiberPool.update} for
113
- * details.
110
+ * @remarks
111
+ * If the fiber was added to a parent {@link Fiber}, the error will be logged
112
+ * and the fiber removed from the parent. See {@link Fiber.next} for details.
114
113
  *
115
114
  * @param promise
116
115
  */
package/ops.js CHANGED
@@ -156,10 +156,9 @@ export function* untilState(state, pred) {
156
156
  * Returns a fiber which "blocks" until the given `promise` resolves or rejects.
157
157
  * In the latter case, the fiber will throw the received error.
158
158
  *
159
- * @remove
160
- * If the erroring fiber was added directly to a {@link FiberPool}, the error
161
- * will be logged and the fiber removed. See {@link FiberPool.update} for
162
- * details.
159
+ * @remarks
160
+ * If the fiber was added to a parent {@link Fiber}, the error will be logged
161
+ * and the fiber removed from the parent. See {@link Fiber.next} for details.
163
162
  *
164
163
  * @param promise
165
164
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/fibers",
3
- "version": "0.2.3",
3
+ "version": "0.3.1",
4
4
  "description": "Process hierarchies & operators for cooperative multitasking",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -34,18 +34,18 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.9.3",
38
- "@thi.ng/arrays": "^2.5.19",
39
- "@thi.ng/bench": "^3.4.4",
40
- "@thi.ng/checks": "^3.4.3",
41
- "@thi.ng/errors": "^2.3.3",
42
- "@thi.ng/idgen": "^2.2.4",
43
- "@thi.ng/logger": "^1.4.19",
44
- "@thi.ng/random": "^3.6.1"
37
+ "@thi.ng/api": "^8.9.4",
38
+ "@thi.ng/arrays": "^2.5.20",
39
+ "@thi.ng/bench": "^3.4.5",
40
+ "@thi.ng/checks": "^3.4.4",
41
+ "@thi.ng/errors": "^2.3.4",
42
+ "@thi.ng/idgen": "^2.2.5",
43
+ "@thi.ng/logger": "^1.4.20",
44
+ "@thi.ng/random": "^3.6.2"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@microsoft/api-extractor": "^7.36.4",
48
- "@thi.ng/testament": "^0.3.21",
48
+ "@thi.ng/testament": "^0.3.22",
49
49
  "rimraf": "^5.0.1",
50
50
  "tools": "^0.0.1",
51
51
  "typedoc": "^0.24.8",
@@ -108,5 +108,5 @@
108
108
  "status": "alpha",
109
109
  "year": 2023
110
110
  },
111
- "gitHead": "4154283d772824d4b57d4b7ab97be22a6e1ffdd7\n"
111
+ "gitHead": "74cfe3fb8de5bfcbfc1109e67604541cbd7b77aa\n"
112
112
  }