@thi.ng/fibers 1.0.4 → 1.0.6

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**: 2024-05-08T18:24:31Z
3
+ - **Last updated**: 2024-06-29T09:28:36Z
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.
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 192 standalone projects, maintained as part
10
+ > This is one of 189 standalone projects, maintained as part
11
11
  > of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
12
12
  > and anti-framework.
13
13
  >
@@ -423,15 +423,16 @@ Several projects in this repo's
423
423
  [/examples](https://github.com/thi-ng/umbrella/tree/develop/examples)
424
424
  directory are using this package:
425
425
 
426
- | Screenshot | Description | Live demo | Source |
427
- |:----------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------|:-----------------------------------------------------|:----------------------------------------------------------------------------------|
428
- | <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) |
429
- | <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) |
430
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/ifs-fractal.jpg" width="240"/> | Barnsley fern IFS fractal renderer | [Demo](https://demo.thi.ng/umbrella/ifs-fractal/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/ifs-fractal) |
431
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/mastodon-feed.jpg" width="240"/> | Mastodon API feed reader with support for different media types, fullscreen media modal, HTML rewriting | [Demo](https://demo.thi.ng/umbrella/mastodon-feed/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/mastodon-feed) |
432
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/poly-subdiv.jpg" width="240"/> | Animated, iterative polygon subdivisions & visualization | [Demo](https://demo.thi.ng/umbrella/poly-subdiv/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/poly-subdiv) |
433
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/related-images.jpg" width="240"/> | Responsive image gallery with tag-based Jaccard similarity ranking | [Demo](https://demo.thi.ng/umbrella/related-images/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/related-images) |
434
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/render-audio.png" width="240"/> | Generative audio synth offline renderer and WAV file export | [Demo](https://demo.thi.ng/umbrella/render-audio/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/render-audio) |
426
+ | Screenshot | Description | Live demo | Source |
427
+ |:-------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------|:--------------------------------------------------------|:-------------------------------------------------------------------------------------|
428
+ | <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) |
429
+ | <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) |
430
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/geom-unique-edges.png" width="240"/> | Iterating the unique edges of a tessellation | [Demo](https://demo.thi.ng/umbrella/geom-unique-edges/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/geom-unique-edges) |
431
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/ifs-fractal.jpg" width="240"/> | Barnsley fern IFS fractal renderer | [Demo](https://demo.thi.ng/umbrella/ifs-fractal/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/ifs-fractal) |
432
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/mastodon-feed.jpg" width="240"/> | Mastodon API feed reader with support for different media types, fullscreen media modal, HTML rewriting | [Demo](https://demo.thi.ng/umbrella/mastodon-feed/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/mastodon-feed) |
433
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/poly-subdiv.jpg" width="240"/> | Animated, iterative polygon subdivisions & visualization | [Demo](https://demo.thi.ng/umbrella/poly-subdiv/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/poly-subdiv) |
434
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/related-images.jpg" width="240"/> | Responsive image gallery with tag-based Jaccard similarity ranking | [Demo](https://demo.thi.ng/umbrella/related-images/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/related-images) |
435
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/render-audio.png" width="240"/> | Generative audio synth offline renderer and WAV file export | [Demo](https://demo.thi.ng/umbrella/render-audio/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/render-audio) |
435
436
 
436
437
  ## API
437
438
 
package/csp.d.ts CHANGED
@@ -9,7 +9,7 @@ import { Fiber } from "./fiber.js";
9
9
  declare const STATE_OPEN = 0;
10
10
  declare const STATE_CLOSING = 1;
11
11
  declare const STATE_CLOSED = 2;
12
- type CSPState = typeof STATE_OPEN | typeof STATE_CLOSING | typeof STATE_CLOSED;
12
+ export type CSPState = typeof STATE_OPEN | typeof STATE_CLOSING | typeof STATE_CLOSED;
13
13
  /**
14
14
  * Fiber-based CSP channel implementation, supporting any
15
15
  * [IReadWriteBuffer](https://docs.thi.ng/umbrella/buffers/interfaces/IReadWriteBuffer.html)
package/fiber.d.ts CHANGED
@@ -79,8 +79,8 @@ export declare class Fiber<T = any> implements IDeref<Maybe<T>>, IID<string>, IN
79
79
  * {@link Fiber.childForID}.
80
80
  *
81
81
  * @example
82
- * ```ts
83
- * import { fiber } from "@thi.ng/fibers";
82
+ * ```ts tangle:../export/fork.ts
83
+ * import { fiber, wait } from "@thi.ng/fibers";
84
84
  *
85
85
  * fiber(function* (ctx) {
86
86
  * console.log("main start")
@@ -205,7 +205,7 @@ export declare class Fiber<T = any> implements IDeref<Maybe<T>>, IID<string>, IN
205
205
  * `handler` must only manage a single execution step, not multiple.
206
206
  *
207
207
  * @example
208
- * ```ts
208
+ * ```ts tangle:../export/run-with.ts
209
209
  * import { fiber } from "@thi.ng/fibers";
210
210
  *
211
211
  * // start with custom higher frequency handler
package/fiber.js CHANGED
@@ -141,8 +141,8 @@ let Fiber = class {
141
141
  * {@link Fiber.childForID}.
142
142
  *
143
143
  * @example
144
- * ```ts
145
- * import { fiber } from "@thi.ng/fibers";
144
+ * ```ts tangle:../export/fork.ts
145
+ * import { fiber, wait } from "@thi.ng/fibers";
146
146
  *
147
147
  * fiber(function* (ctx) {
148
148
  * console.log("main start")
@@ -365,7 +365,7 @@ let Fiber = class {
365
365
  * `handler` must only manage a single execution step, not multiple.
366
366
  *
367
367
  * @example
368
- * ```ts
368
+ * ```ts tangle:../export/run-with.ts
369
369
  * import { fiber } from "@thi.ng/fibers";
370
370
  *
371
371
  * // start with custom higher frequency handler
package/ops.d.ts CHANGED
@@ -95,14 +95,14 @@ export declare const timeSlice: (body: MaybeFiber, maxTime: number, opts?: Parti
95
95
  * given `consume` function in order to process these values further.
96
96
  *
97
97
  * @example
98
- * ```ts
98
+ * ```ts tangle:../export/timeslice-iterable.ts
99
99
  * import { timeSliceIterable } from "@thi.ng/fibers";
100
- * import { range } from "@this.ng/transducers";
100
+ * import { range } from "@thi.ng/transducers";
101
101
  *
102
102
  * // consume & batch process iterable in 16ms time slices
103
103
  * timeSliceIterable(
104
104
  * range(1_000_000),
105
- * (chunk) => console.log(chunk),
105
+ * (chunk) => console.log("items:", chunk.length),
106
106
  * 16
107
107
  * ).run();
108
108
  * ```
@@ -181,15 +181,15 @@ export declare class Shuffle extends Fiber {
181
181
  * [`SYSTEM`](https://docs.thi.ng/umbrella/random/variables/SYSTEM.html).
182
182
  *
183
183
  * @example
184
- * ```ts
184
+ * ```ts tangle:../export/shuffle.ts
185
185
  * import { shuffle } from "@thi.ng/fibers";
186
186
  * import { repeatedly } from "@thi.ng/transducers";
187
187
  *
188
- * // create & run fiber with 4 children, executing in random order
188
+ * // create & run fiber with 16 children, executing in random order
189
189
  * shuffle(
190
190
  * repeatedly(
191
- * (id) => function*() { while(true) { console.log(`worker #{id}`); yield; } },
192
- * 4
191
+ * (id) => function*() { while(true) { console.log(`worker #${id}`); yield; } },
192
+ * 16
193
193
  * )
194
194
  * ).run()
195
195
  *
@@ -224,8 +224,8 @@ export declare const shuffle: (fibers: Iterable<MaybeFiber>, opts?: Partial<Fibe
224
224
  * `catch` handler indicating the error has been dealt with.
225
225
  *
226
226
  * @example
227
- * ```ts
228
- * import { asPromise } from "@thi.ng/fibers";
227
+ * ```ts tangle:../export/as-promise.ts
228
+ * import { asPromise, wait } from "@thi.ng/fibers";
229
229
  *
230
230
  * (async () => {
231
231
  * // create & spawn task/fiber
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/fibers",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Process hierarchies & operators for cooperative multitasking",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -10,7 +10,7 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/thi-ng/umbrella.git"
12
12
  },
13
- "homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/fibers#readme",
13
+ "homepage": "https://thi.ng/fibers",
14
14
  "funding": [
15
15
  {
16
16
  "type": "github",
@@ -36,21 +36,21 @@
36
36
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@thi.ng/api": "^8.11.2",
40
- "@thi.ng/arrays": "^2.9.6",
41
- "@thi.ng/bench": "^3.5.6",
42
- "@thi.ng/buffers": "^0.1.3",
43
- "@thi.ng/checks": "^3.6.4",
44
- "@thi.ng/errors": "^2.5.7",
45
- "@thi.ng/idgen": "^2.2.41",
46
- "@thi.ng/logger": "^3.0.12",
47
- "@thi.ng/random": "^3.8.0"
39
+ "@thi.ng/api": "^8.11.4",
40
+ "@thi.ng/arrays": "^2.9.8",
41
+ "@thi.ng/bench": "^3.5.8",
42
+ "@thi.ng/buffers": "^0.1.5",
43
+ "@thi.ng/checks": "^3.6.6",
44
+ "@thi.ng/errors": "^2.5.9",
45
+ "@thi.ng/idgen": "^2.2.43",
46
+ "@thi.ng/logger": "^3.0.14",
47
+ "@thi.ng/random": "^3.8.2"
48
48
  },
49
49
  "devDependencies": {
50
- "@microsoft/api-extractor": "^7.43.2",
51
- "esbuild": "^0.21.1",
50
+ "@microsoft/api-extractor": "^7.47.0",
51
+ "esbuild": "^0.21.5",
52
52
  "typedoc": "^0.25.13",
53
- "typescript": "^5.4.5"
53
+ "typescript": "^5.5.2"
54
54
  },
55
55
  "keywords": [
56
56
  "blocking",
@@ -113,5 +113,5 @@
113
113
  "status": "alpha",
114
114
  "year": 2023
115
115
  },
116
- "gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
116
+ "gitHead": "7b950c112fba0b2e7c450765b15624c3382f1354\n"
117
117
  }