diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..2e1fa2d52e --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +*.md \ No newline at end of file diff --git a/README.md b/README.md index a6a550a02c..ebbc1e0842 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,16 @@ There's a steadily growing number (40+) of standalone examples (different complexities, often combining functionality from several packages) in the [examples](./examples) directory. +## Blog posts + +- [How to UI in 2018](https://medium.com/@thi.ng/how-to-ui-in-2018-ac2ae02acdf3) + +- "Of umbrellas, transducers, reactive streams & mushrooms" (ongoing series): + - [Part 1 - Project & series overview](https://medium.com/@thi.ng/of-umbrellas-transducers-reactive-streams-mushrooms-pt-1-a8717ce3a170) + - [Part 2 - HOFs, Transducers, Reducers](https://medium.com/@thi.ng/of-umbrellas-transducers-reactive-streams-mushrooms-pt-2-9c540beb0023) + - [Part 3 - Convolution, 1D/2D Cellular automata](https://medium.com/@thi.ng/of-umbrellas-transducers-reactive-streams-mushrooms-pt-3-a1c4e621db9b) + - [Part 4 - Disjoint Sets, Graph analysis, Signed Distance Fields](https://medium.com/@thi.ng/of-umbrellas-transducers-reactive-streams-mushrooms-pt-4-62d8e71e5603) + ## Projects ### Fundamentals @@ -95,6 +105,7 @@ packages) in the [examples](./examples) directory. | [`@thi.ng/rstream-gestures`](./packages/rstream-gestures) | [![version](https://img.shields.io/npm/v/@thi.ng/rstream-gestures.svg)](https://www.npmjs.com/package/@thi.ng/rstream-gestures) | [changelog](./packages/rstream-gestures/CHANGELOG.md) | Mouse & touch event stream abstraction | | [`@thi.ng/rstream-graph`](./packages/rstream-graph) | [![version](https://img.shields.io/npm/v/@thi.ng/rstream-graph.svg)](https://www.npmjs.com/package/@thi.ng/rstream-graph) | [changelog](./packages/rstream-graph/CHANGELOG.md) | Declarative dataflow graph construction | | [`@thi.ng/rstream-log`](./packages/rstream-log) | [![version](https://img.shields.io/npm/v/@thi.ng/rstream-log.svg)](https://www.npmjs.com/package/@thi.ng/rstream-log) | [changelog](./packages/rstream-log/CHANGELOG.md) | Hierarchical structured data logging | +| [`@thi.ng/rstream-log-file`](./packages/rstream-log-file) | [![version](https://img.shields.io/npm/v/@thi.ng/rstream-log-file.svg)](https://www.npmjs.com/package/@thi.ng/rstream-log-file) | [changelog](./packages/rstream-log-file/CHANGELOG.md) | Log-file output handler | | [`@thi.ng/rstream-query`](./packages/rstream-query) | [![version](https://img.shields.io/npm/v/@thi.ng/rstream-query.svg)](https://www.npmjs.com/package/@thi.ng/rstream-query) | [changelog](./packages/rstream-query/CHANGELOG.md) | Triple store & query engine | ### Data structures diff --git a/examples/async-effect/package.json b/examples/async-effect/package.json index 76c3a31231..8e2bee38bb 100644 --- a/examples/async-effect/package.json +++ b/examples/async-effect/package.json @@ -11,8 +11,8 @@ "start": "yarn prep && parcel index.html -p 8080 --open -d out" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -26,4 +26,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/bitmap-font/package.json b/examples/bitmap-font/package.json index c532bbe343..4475cd87c2 100644 --- a/examples/bitmap-font/package.json +++ b/examples/bitmap-font/package.json @@ -10,9 +10,9 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", + "parcel-bundler": "^1.12.3", "rimraf": "^2.6.3", - "terser": "^3.14.1", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -30,4 +30,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/canvas-dial/package.json b/examples/canvas-dial/package.json index 46bebe7e0a..feefb98c7c 100644 --- a/examples/canvas-dial/package.json +++ b/examples/canvas-dial/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -33,4 +33,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/canvas-dial/src/dial.ts b/examples/canvas-dial/src/dial.ts index 1e1236e2fb..14fab20cc5 100644 --- a/examples/canvas-dial/src/dial.ts +++ b/examples/canvas-dial/src/dial.ts @@ -4,11 +4,7 @@ import { isString } from "@thi.ng/checks"; import { canvas2D } from "@thi.ng/hdom-components"; import { fitClamped } from "@thi.ng/math"; import { Subscription } from "@thi.ng/rstream"; -import { - GestureEvent, - gestureStream, - GestureType -} from "@thi.ng/rstream-gestures"; +import { GestureEvent, gestureStream, GestureType } from "@thi.ng/rstream-gestures"; import { heading, sub2 } from "@thi.ng/vectors"; /** @@ -68,7 +64,7 @@ export interface DialOpts { /** * Label formatter. No label will be displayed, if missing. */ - label: (x: number) => string; + label: Fn; /** * Label Y offset from `cy` * Default: 0 diff --git a/examples/cellular-automata/package.json b/examples/cellular-automata/package.json index 16e65f0d8a..c4664e7da1 100644 --- a/examples/cellular-automata/package.json +++ b/examples/cellular-automata/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -26,4 +26,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/cellular-automata/src/index.ts b/examples/cellular-automata/src/index.ts index cdf6078870..65513fc610 100644 --- a/examples/cellular-automata/src/index.ts +++ b/examples/cellular-automata/src/index.ts @@ -4,9 +4,8 @@ import { buildKernel2d, comp, convolve2d, - lookup2d, map, - multiplex, + mapIndexed, partition, push, range2d, @@ -83,11 +82,8 @@ export const convolve = ( ) => transduce( comp( - multiplex( - convolve2d({ src, width, height, kernel, wrap }), - map(lookup2d(src, width)) - ), - map(lookup2d(rules, rstride)) + convolve2d({ src, width, height, kernel, wrap }), + mapIndexed((i, x) => rules[x + src[i] * rstride]) ), push(), range2d(width, height) diff --git a/examples/commit-table-ssr/package.json b/examples/commit-table-ssr/package.json index 07fae2ab2e..60bd2fc41b 100644 --- a/examples/commit-table-ssr/package.json +++ b/examples/commit-table-ssr/package.json @@ -12,8 +12,8 @@ "start": "tsc && node build/server/index.js" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -33,4 +33,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/crypto-chart/package.json b/examples/crypto-chart/package.json index 0cacc2d8cc..217d859d76 100644 --- a/examples/crypto-chart/package.json +++ b/examples/crypto-chart/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -30,4 +30,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/dashboard/package.json b/examples/dashboard/package.json index 30bb565e92..847129fbd9 100644 --- a/examples/dashboard/package.json +++ b/examples/dashboard/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -23,4 +23,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/devcards/package.json b/examples/devcards/package.json index 515ed8e2c5..c95b802a97 100644 --- a/examples/devcards/package.json +++ b/examples/devcards/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -25,4 +25,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/devcards/src/index.ts b/examples/devcards/src/index.ts index eb6e38f891..b7b55fd658 100644 --- a/examples/devcards/src/index.ts +++ b/examples/devcards/src/index.ts @@ -1,3 +1,4 @@ +import { Fn } from "@thi.ng/api"; import { IAtom } from "@thi.ng/atom"; import { Atom, Cursor } from "@thi.ng/atom"; import { start } from "@thi.ng/hdom"; @@ -65,8 +66,8 @@ interface SliderOpts { min: number; max: number; step?: number; - label: (val) => any; - onchange?: (e) => void; + label: Fn; + onchange?: EventListener; } /** @@ -129,16 +130,14 @@ function bmi(state: IAtom) { ]; // derived view of bmi value to translate it into english - const bmiClass = state.addView( - "bmi", - (bmi: number) => - bmi > thresh[3][0] - ? thresh[3][1] - : bmi > thresh[2][0] - ? thresh[2][1] - : bmi > thresh[1][0] - ? thresh[1][1] - : thresh[0][1] + const bmiClass = state.addView("bmi", (bmi: number) => + bmi > thresh[3][0] + ? thresh[3][1] + : bmi > thresh[2][0] + ? thresh[2][1] + : bmi > thresh[1][0] + ? thresh[1][1] + : thresh[0][1] ); // another derived view to create SVG visualization diff --git a/examples/geom-knn/package.json b/examples/geom-knn/package.json index ac4ce070a9..c4eafa8bbd 100644 --- a/examples/geom-knn/package.json +++ b/examples/geom-knn/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -30,4 +30,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/geom-tessel/package.json b/examples/geom-tessel/package.json index b6a007b4cd..51a8f5152f 100644 --- a/examples/geom-tessel/package.json +++ b/examples/geom-tessel/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -28,4 +28,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/gesture-analysis/package.json b/examples/gesture-analysis/package.json index d1b13a7fa6..bb4951f6e2 100644 --- a/examples/gesture-analysis/package.json +++ b/examples/gesture-analysis/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -29,4 +29,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/hdom-basics/package.json b/examples/hdom-basics/package.json index 5802e501d6..f324f02c1b 100644 --- a/examples/hdom-basics/package.json +++ b/examples/hdom-basics/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -23,4 +23,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/hdom-benchmark/package.json b/examples/hdom-benchmark/package.json index 5f64b8531a..b8b7657d90 100644 --- a/examples/hdom-benchmark/package.json +++ b/examples/hdom-benchmark/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -27,4 +27,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/hdom-benchmark2/package.json b/examples/hdom-benchmark2/package.json index 4eee0ca969..aa57d1fd59 100644 --- a/examples/hdom-benchmark2/package.json +++ b/examples/hdom-benchmark2/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -28,4 +28,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/hdom-canvas-clock/package.json b/examples/hdom-canvas-clock/package.json index 88d52d89e5..1d58d1d7a2 100644 --- a/examples/hdom-canvas-clock/package.json +++ b/examples/hdom-canvas-clock/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -27,4 +27,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/hdom-canvas-draw/package.json b/examples/hdom-canvas-draw/package.json index 1eba6d4fc4..76fb21e5f3 100644 --- a/examples/hdom-canvas-draw/package.json +++ b/examples/hdom-canvas-draw/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -28,4 +28,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/hdom-canvas-shapes/package.json b/examples/hdom-canvas-shapes/package.json index 46695975ce..6896aaf79a 100644 --- a/examples/hdom-canvas-shapes/package.json +++ b/examples/hdom-canvas-shapes/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open --no-cache" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -30,4 +30,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/hdom-dropdown-fuzzy/package.json b/examples/hdom-dropdown-fuzzy/package.json index a6b31a00c8..c4a3cb0046 100644 --- a/examples/hdom-dropdown-fuzzy/package.json +++ b/examples/hdom-dropdown-fuzzy/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -29,4 +29,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/hdom-dropdown-fuzzy/src/dropdown.ts b/examples/hdom-dropdown-fuzzy/src/dropdown.ts index 7ccd780d6c..ca60e224a7 100644 --- a/examples/hdom-dropdown-fuzzy/src/dropdown.ts +++ b/examples/hdom-dropdown-fuzzy/src/dropdown.ts @@ -1,8 +1,8 @@ -import { IObjectOf } from "@thi.ng/api"; +import { Fn, IObjectOf } from "@thi.ng/api"; import { ReadonlyAtom } from "@thi.ng/atom"; import { isString } from "@thi.ng/checks"; import { appLink } from "@thi.ng/hdom-components"; -import { EventBus, EV_SET_VALUE, EV_TOGGLE_VALUE } from "@thi.ng/interceptors"; +import { EV_SET_VALUE, EV_TOGGLE_VALUE, EventBus } from "@thi.ng/interceptors"; import { getIn, Path } from "@thi.ng/paths"; export interface BaseContext { @@ -14,7 +14,7 @@ export interface DropdownArgs { state: DropdownState; statePath: Path; ontoggle: EventListener; - onchange: (id: any) => EventListener; + onchange: Fn; attribs: IObjectOf; hoverLabel: any; openLabel: any; diff --git a/examples/hdom-dropdown/package.json b/examples/hdom-dropdown/package.json index 3619b30329..397b200f23 100644 --- a/examples/hdom-dropdown/package.json +++ b/examples/hdom-dropdown/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -28,4 +28,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/hdom-dropdown/src/dropdown.ts b/examples/hdom-dropdown/src/dropdown.ts index fe1bc9f411..3e684bc587 100644 --- a/examples/hdom-dropdown/src/dropdown.ts +++ b/examples/hdom-dropdown/src/dropdown.ts @@ -1,4 +1,4 @@ -import { IObjectOf } from "@thi.ng/api"; +import { Fn, IObjectOf } from "@thi.ng/api"; import { ReadonlyAtom } from "@thi.ng/atom"; import { appLink } from "@thi.ng/hdom-components"; import { EV_SET_VALUE, EV_TOGGLE_VALUE, EventBus } from "@thi.ng/interceptors"; @@ -13,7 +13,7 @@ export interface DropdownArgs { state: DropdownState; statePath: Path; ontoggle: EventListener; - onchange: (id: any) => EventListener; + onchange: Fn; attribs: IObjectOf; hoverLabel: any; onmouseover: EventListener; diff --git a/examples/hdom-dyn-context/package.json b/examples/hdom-dyn-context/package.json index dbbba7e2b9..6570d92a68 100644 --- a/examples/hdom-dyn-context/package.json +++ b/examples/hdom-dyn-context/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -24,4 +24,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/hdom-inner-html/package.json b/examples/hdom-inner-html/package.json index c97d776c86..2e2a1bf0ae 100644 --- a/examples/hdom-inner-html/package.json +++ b/examples/hdom-inner-html/package.json @@ -10,9 +10,9 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", + "parcel-bundler": "^1.12.3", "rimraf": "^2.6.3", - "terser": "^3.14.1", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -24,4 +24,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/hdom-skip/package.json b/examples/hdom-skip/package.json index 62e9bd8197..2526248ece 100644 --- a/examples/hdom-skip/package.json +++ b/examples/hdom-skip/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -23,4 +23,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/hdom-theme-adr-0003/package.json b/examples/hdom-theme-adr-0003/package.json index d10a5151fc..ea5677e1ac 100644 --- a/examples/hdom-theme-adr-0003/package.json +++ b/examples/hdom-theme-adr-0003/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -25,4 +25,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/hdom-vscroller/package.json b/examples/hdom-vscroller/package.json index 80795da4a3..0463e8c63a 100644 --- a/examples/hdom-vscroller/package.json +++ b/examples/hdom-vscroller/package.json @@ -10,9 +10,9 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", + "parcel-bundler": "^1.12.3", "rimraf": "^2.6.3", - "terser": "^3.14.1", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -26,4 +26,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/hmr-basics/package.json b/examples/hmr-basics/package.json index 9d4eb6fc54..2f4540de27 100644 --- a/examples/hmr-basics/package.json +++ b/examples/hmr-basics/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -27,4 +27,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/hydrate-basics/package.json b/examples/hydrate-basics/package.json index dc21ad11bc..7f5e7333b9 100644 --- a/examples/hydrate-basics/package.json +++ b/examples/hydrate-basics/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -26,4 +26,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/interceptor-basics/package.json b/examples/interceptor-basics/package.json index b209dae0b3..63c4cc1a8d 100644 --- a/examples/interceptor-basics/package.json +++ b/examples/interceptor-basics/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -26,4 +26,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/interceptor-basics2/package.json b/examples/interceptor-basics2/package.json index da6e654725..0c07ee8742 100644 --- a/examples/interceptor-basics2/package.json +++ b/examples/interceptor-basics2/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -26,4 +26,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/iso-plasma/package.json b/examples/iso-plasma/package.json index 2e20f16dd3..fe8f44f4b5 100644 --- a/examples/iso-plasma/package.json +++ b/examples/iso-plasma/package.json @@ -10,9 +10,9 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", + "parcel-bundler": "^1.12.3", "rimraf": "^2.6.3", - "terser": "^3.14.1", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -31,4 +31,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/json-components/package.json b/examples/json-components/package.json index a8a4a3fd3d..ef83c67d0a 100644 --- a/examples/json-components/package.json +++ b/examples/json-components/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -24,4 +24,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/login-form/package.json b/examples/login-form/package.json index 639a3432ce..8008170ab6 100644 --- a/examples/login-form/package.json +++ b/examples/login-form/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -25,4 +25,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/mandelbrot/package.json b/examples/mandelbrot/package.json index bea1fc5a6f..30fcb0c3d8 100644 --- a/examples/mandelbrot/package.json +++ b/examples/mandelbrot/package.json @@ -11,8 +11,8 @@ "start": "yarn build:worker && parcel index.html -d out -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -33,4 +33,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/markdown/package.json b/examples/markdown/package.json index 9fe5de8778..a59266c27d 100644 --- a/examples/markdown/package.json +++ b/examples/markdown/package.json @@ -11,8 +11,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -28,4 +28,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/router-basics/package.json b/examples/router-basics/package.json index 5e69aefe18..dba78a1b25 100644 --- a/examples/router-basics/package.json +++ b/examples/router-basics/package.json @@ -20,8 +20,8 @@ "@thi.ng/router": "latest" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "browserslist": [ @@ -30,4 +30,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/rstream-dataflow/package.json b/examples/rstream-dataflow/package.json index 98ca3abb35..dbec70d056 100644 --- a/examples/rstream-dataflow/package.json +++ b/examples/rstream-dataflow/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -31,4 +31,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/rstream-grid/package.json b/examples/rstream-grid/package.json index 760a3b0f87..e21b215c23 100644 --- a/examples/rstream-grid/package.json +++ b/examples/rstream-grid/package.json @@ -25,8 +25,8 @@ }, "devDependencies": { "@types/node": "^9.6.2", - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "browserslist": [ @@ -35,4 +35,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/rstream-hdom/package.json b/examples/rstream-hdom/package.json index 931e769ad6..e19b6cf8c7 100644 --- a/examples/rstream-hdom/package.json +++ b/examples/rstream-hdom/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -26,4 +26,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/svg-barchart/package.json b/examples/svg-barchart/package.json index 961f66b2d1..281995bb3c 100644 --- a/examples/svg-barchart/package.json +++ b/examples/svg-barchart/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -24,4 +24,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/svg-particles/package.json b/examples/svg-particles/package.json index a61e7116ae..44a1a75a8c 100644 --- a/examples/svg-particles/package.json +++ b/examples/svg-particles/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -25,4 +25,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/svg-waveform/package.json b/examples/svg-waveform/package.json index f8add8cb71..e3dd6ebdf3 100644 --- a/examples/svg-waveform/package.json +++ b/examples/svg-waveform/package.json @@ -21,8 +21,8 @@ }, "devDependencies": { "@types/node": "^9.6.2", - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "browserslist": [ @@ -31,4 +31,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/talk-slides/package.json b/examples/talk-slides/package.json index eea34b055b..745c63d9f9 100644 --- a/examples/talk-slides/package.json +++ b/examples/talk-slides/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -28,4 +28,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/todo-list/package.json b/examples/todo-list/package.json index f9982ad6d3..ad06bd9935 100644 --- a/examples/todo-list/package.json +++ b/examples/todo-list/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -27,4 +27,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/transducers-hdom/package.json b/examples/transducers-hdom/package.json index 922591d1db..af1caf89e2 100644 --- a/examples/transducers-hdom/package.json +++ b/examples/transducers-hdom/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -25,4 +25,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/triple-query/package.json b/examples/triple-query/package.json index 8913b5c0b8..859f18b3f2 100644 --- a/examples/triple-query/package.json +++ b/examples/triple-query/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -31,4 +31,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/webgl/package.json b/examples/webgl/package.json index b77b59b4ad..88af4c918c 100644 --- a/examples/webgl/package.json +++ b/examples/webgl/package.json @@ -10,8 +10,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -25,4 +25,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/examples/wolfram/.gitignore b/examples/wolfram/.gitignore new file mode 100644 index 0000000000..0c5abcab62 --- /dev/null +++ b/examples/wolfram/.gitignore @@ -0,0 +1,5 @@ +.cache +out +node_modules +yarn.lock +*.js diff --git a/examples/wolfram/README.md b/examples/wolfram/README.md new file mode 100644 index 0000000000..9a345a30b4 --- /dev/null +++ b/examples/wolfram/README.md @@ -0,0 +1,13 @@ +# wolfram + +[Live demo](http://demo.thi.ng/umbrella/wolfram/) + +Please refer to the [example build instructions](https://github.com/thi-ng/umbrella/wiki/Example-build-instructions) on the wiki. + +## Authors + +- Karsten Schmidt + +## License + +© 2018 Karsten Schmidt // Apache Software License 2.0 diff --git a/examples/wolfram/index.html b/examples/wolfram/index.html new file mode 100644 index 0000000000..d972fd0273 --- /dev/null +++ b/examples/wolfram/index.html @@ -0,0 +1,16 @@ + + + + + + + wolfram + + + + +
+ + + diff --git a/examples/wolfram/package.json b/examples/wolfram/package.json new file mode 100644 index 0000000000..0a9ba20c68 --- /dev/null +++ b/examples/wolfram/package.json @@ -0,0 +1,32 @@ +{ + "name": "wolfram", + "version": "0.0.1", + "repository": "https://github.com/thi-ng/umbrella", + "author": "Karsten Schmidt ", + "license": "Apache-2.0", + "scripts": { + "clean": "rm -rf .cache build out", + "build": "yarn clean && parcel build index.html -d out --public-url ./ --no-source-maps --no-cache --detailed-report --experimental-scope-hoisting", + "start": "parcel index.html -p 8080 --open" + }, + "devDependencies": { + "parcel-bundler": "^1.12.3", + "rimraf": "^2.6.3", + "terser": "^3.17.0", + "typescript": "^3.2.2" + }, + "dependencies": { + "@thi.ng/api": "latest", + "@thi.ng/hdom-components": "latest", + "@thi.ng/rstream": "latest", + "@thi.ng/transducers": "latest", + "@thi.ng/transducers-binary": "latest", + "@thi.ng/transducers-hdom": "latest" + }, + "browserslist": [ + "last 3 Chrome versions" + ], + "browser": { + "process": false + } +} diff --git a/examples/wolfram/src/download.ts b/examples/wolfram/src/download.ts new file mode 100644 index 0000000000..1097e53bbf --- /dev/null +++ b/examples/wolfram/src/download.ts @@ -0,0 +1,29 @@ +/** + * Helper function to trigger download of given `src` string as local + * file with filename `name` and mime `type`. Wraps `src` as blob and + * creates an object URL for download. By default, the URL auto-expires + * after 10 seconds to free up memory. + * + * @param name + * @param src + * @param type + * @param expire + */ +export function download( + name: string, + src: string, + type = "image/svg", + expire = 10000 +) { + const blob = new Blob([src], { type }); + const uri = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.download = name; + a.href = uri; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + if (uri.indexOf("blob:") === 0) { + setTimeout(() => URL.revokeObjectURL(uri), expire); + } +} diff --git a/examples/wolfram/src/index.ts b/examples/wolfram/src/index.ts new file mode 100644 index 0000000000..c52a0baa6a --- /dev/null +++ b/examples/wolfram/src/index.ts @@ -0,0 +1,171 @@ +import { dropdown } from "@thi.ng/hdom-components"; +import { + fromIterable, + fromRAF, + metaStream, + sidechainToggle, + stream, + sync +} from "@thi.ng/rstream"; +import { + buildKernel1d, + comp, + convolve1d, + filter, + flatten, + iterator1, + lookup1d, + map, + range, + range2d, + reducer, + scan, + slidingWindow, + str, + transduce, + zip +} from "@thi.ng/transducers"; +import { bits, randomBits } from "@thi.ng/transducers-binary"; +import { updateDOM } from "@thi.ng/transducers-hdom"; +import { download } from "./download"; + +const WIDTH = 160; +const HEIGHT = 32; + +const resetCA = () => [...randomBits(0.25, WIDTH)]; + +const evolveCA = (src, { kernel, rule, reset }) => + reset + ? resetCA() + : [ + ...iterator1( + comp( + convolve1d({ + src, + kernel, + width: src.length, + wrap: true + }), + map(lookup1d(rule)) + ), + range(src.length) + ) + ]; + +const triggerReset = () => + wolfram.add(fromIterable([true, false], 16), "reset"); + +const triggerOBJExport = () => objExport.next(1); + +const setRule = (e) => { + rule.next(parseInt(e.target.value)); + triggerReset(); +}; + +const setKernel = (e) => kernel.next(parseInt(e.target.value)); + +const app = ({ id, ksize, sim }) => [ + "div.sans-serif.ma3", + [ + "div", + "Rule:", + [ + "input.w4.h2.mh3.pa2", + { + type: "number", + value: id, + oninput: setRule + } + ], + "Kernel:", + [ + dropdown, + { class: "h2 pa2 mh3", onchange: setKernel }, + [[3, "3"], [5, "5"]], + ksize + ], + [ + "button.mr3.pa2", + { + onclick: triggerReset + }, + "Reset" + ], + [ + "button.mr3.pa2", + { + onclick: triggerOBJExport + }, + "Export OBJ" + ], + [ + "a.link.blue", + { + href: + "https://en.wikipedia.org/wiki/Elementary_cellular_automaton#Random_initial_state" + }, + "Wikipedia" + ] + ], + ["pre.f7.code", sim] +]; + +const rule = stream(); +const kernel = stream(); +const objExport = metaStream(() => fromIterable([true, false], 17)); + +const wolfram = sync({ + src: { + rule: rule.transform(map((x) => [...bits(32, false, [x])])), + kernel: kernel.transform( + map((x) => buildKernel1d([1, 2, 4, 8, 16], x)) + ), + _: fromRAF() + }, + xform: scan(reducer(resetCA, evolveCA)) +}); + +const main = sync({ + src: { + id: rule, + ksize: kernel, + sim: wolfram.transform( + map((gen) => gen.map((x) => " █"[x]).join("")), + slidingWindow(HEIGHT), + map((win: string[]) => win.join("\n")) + ) + } +}).transform(map(app), updateDOM()); + +// Wavefront OBJ 3D pointcloud export +// attached as second subscription to wolfram stream +// uses `objExport` metastream as toggle switch to produce OBJ file +// and trigger download +wolfram + // always collect new generations + // history length same as WIDTH to export square area + .transform(slidingWindow(WIDTH)) + // sidechainToggle is only letting new values through if enabled by + // objExport stream + .subscribe(sidechainToggle(objExport, false)) + // actual OBJ conversion & export + .transform( + map((grid) => + transduce( + comp(filter((t) => !!t[1]), map(([[x, y]]) => `v ${x} ${y} 0`)), + str("\n"), + zip(range2d(WIDTH, WIDTH), flatten(grid)) + ) + ), + map((obj: string) => + download(`ca-${rule.deref()}.obj`, obj, "text/plain") + ) + ); + +rule.next(105); +kernel.next(3); + +if (process.env.NODE_ENV !== "production") { + const hot = (module).hot; + hot && hot.dispose(() => main.done()); +} diff --git a/examples/wolfram/tsconfig.json b/examples/wolfram/tsconfig.json new file mode 100644 index 0000000000..bbf112cc18 --- /dev/null +++ b/examples/wolfram/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": ".", + "target": "es6", + "sourceMap": true + }, + "include": [ + "./src/**/*.ts" + ] +} diff --git a/examples/xml-converter/package.json b/examples/xml-converter/package.json index cd4947d7e2..f1535ff66f 100644 --- a/examples/xml-converter/package.json +++ b/examples/xml-converter/package.json @@ -11,8 +11,8 @@ "start": "parcel index.html -p 8080 --open" }, "devDependencies": { - "parcel-bundler": "^1.11.0", - "terser": "^3.14.1", + "parcel-bundler": "^1.12.3", + "terser": "^3.17.0", "typescript": "^3.2.2" }, "dependencies": { @@ -32,4 +32,4 @@ "browser": { "process": false } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 1dc905d799..24877765aa 100644 --- a/package.json +++ b/package.json @@ -5,21 +5,21 @@ ], "devDependencies": { "benchmark": "^2.1.4", + "file-loader": "^3.0.1", "gzip-size": "^5.0.0", "lerna": "^3.8.5", "mocha": "^5.2.0", "nyc": "^13.1.0", - "parcel-bundler": "^1.11.0", + "parcel-bundler": "^1.12.3", "rimraf": "^2.6.3", - "rollup": "^1.1.0", - "rollup-plugin-cleanup": "^3.1.0", - "terser": "^3.14.1", - "tslint": "^5.12.0", + "rollup": "^1.7.4", + "rollup-plugin-cleanup": "^3.1.1", + "terser": "^3.17.0", + "ts-loader": "^5.3.3", + "tslint": "^5.14.0", "typescript": "^3.2.2", "webpack": "^4.28.1", - "webpack-cli": "^3.2.1", - "ts-loader": "^5.3.3", - "file-loader": "^3.0.1" + "webpack-cli": "^3.2.1" }, "scripts": { "bootstrap": "lerna bootstrap", @@ -33,4 +33,4 @@ "test": "yarn build && yarn test:only", "test:only": "lerna run test" } -} \ No newline at end of file +} diff --git a/packages/adjacency/CHANGELOG.md b/packages/adjacency/CHANGELOG.md index 1262495d70..95e72ab3ae 100644 --- a/packages/adjacency/CHANGELOG.md +++ b/packages/adjacency/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/adjacency@0.1.2...@thi.ng/adjacency@0.1.3) (2019-03-01) +## [0.1.9](https://github.com/thi-ng/umbrella/compare/@thi.ng/adjacency@0.1.8...@thi.ng/adjacency@0.1.9) (2019-03-28) **Note:** Version bump only for package @thi.ng/adjacency @@ -11,19 +11,14 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/adjacency@0.1.1...@thi.ng/adjacency@0.1.2) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/adjacency - +## [0.1.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/adjacency@0.1.6...@thi.ng/adjacency@0.1.7) (2019-03-18) -## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/adjacency@0.1.0...@thi.ng/adjacency@0.1.1) (2019-02-18) - -**Note:** Version bump only for package @thi.ng/adjacency - +### Performance Improvements +* **adjacency:** update subsets() to use canonical() ([0918c5b](https://github.com/thi-ng/umbrella/commit/0918c5b)) diff --git a/packages/adjacency/package.json b/packages/adjacency/package.json index 2e90bdc5e7..2e74d8893c 100644 --- a/packages/adjacency/package.json +++ b/packages/adjacency/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/adjacency", - "version": "0.1.3", + "version": "0.1.9", "description": "Sparse & bitwise adjacency matrices for directed / undirected graphs", "module": "./index.js", "main": "./lib/index.js", @@ -24,7 +24,7 @@ "pub": "yarn build && yarn publish --access public" }, "devDependencies": { - "@thi.ng/vectors": "^2.3.2", + "@thi.ng/vectors": "^2.5.0", "@types/mocha": "^5.2.5", "@types/node": "^10.12.15", "mocha": "^5.2.0", @@ -33,12 +33,12 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/binary": "^1.0.3", - "@thi.ng/bitfield": "^0.1.1", - "@thi.ng/checks": "^2.1.1", - "@thi.ng/dcons": "^2.0.7", - "@thi.ng/sparse": "^0.1.3" + "@thi.ng/api": "^6.0.0", + "@thi.ng/binary": "^1.0.4", + "@thi.ng/bitfield": "^0.1.3", + "@thi.ng/checks": "^2.1.4", + "@thi.ng/dcons": "^2.0.13", + "@thi.ng/sparse": "^0.1.9" }, "keywords": [ "adjacency", diff --git a/packages/adjacency/src/disjoint-set.ts b/packages/adjacency/src/disjoint-set.ts index ac4679c152..bc5f1e4a50 100644 --- a/packages/adjacency/src/disjoint-set.ts +++ b/packages/adjacency/src/disjoint-set.ts @@ -85,10 +85,7 @@ export class DisjointSet { const sets: Map = new Map(); const roots = this.roots; for (let i = roots.length; --i >= 0; ) { - let id = i; - while (id !== roots[id]) { - id = roots[roots[id]]; - } + const id = this.canonical(i); const s = sets.get(id); if (s) { s.push(i); diff --git a/packages/api/CHANGELOG.md b/packages/api/CHANGELOG.md index f70232035b..876089b648 100644 --- a/packages/api/CHANGELOG.md +++ b/packages/api/CHANGELOG.md @@ -3,27 +3,36 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [5.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@5.0.2...@thi.ng/api@5.0.3) (2019-03-01) +# [6.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@5.1.0...@thi.ng/api@6.0.0) (2019-03-28) -**Note:** Version bump only for package @thi.ng/api +### Features +* **api:** add new types, update existing ([560eb90](https://github.com/thi-ng/umbrella/commit/560eb90)) +### BREAKING CHANGES -## [5.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@5.0.1...@thi.ng/api@5.0.2) (2019-02-05) +* **api:** split up, remove & update various interfaces -**Note:** Version bump only for package @thi.ng/api +- split IAssociative => IAssoc, IAssocIn +- update IDissoc, add IDissocIn +- split IGet => IGet, IGetIn +- update IInto generics & return type +- update ISet, remove IImmutableSet +- update IStack, remove IImmutableStack -## [5.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@5.0.0...@thi.ng/api@5.0.1) (2019-01-21) +# [5.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@5.0.3...@thi.ng/api@5.1.0) (2019-03-10) -**Note:** Version bump only for package @thi.ng/api +### Features +* **api:** add additional Fn arities ([33c7dfe](https://github.com/thi-ng/umbrella/commit/33c7dfe)) +* **api:** add more Fn type aliases, update existing ([3707e61](https://github.com/thi-ng/umbrella/commit/3707e61)) diff --git a/packages/api/package.json b/packages/api/package.json index 8b39950a0f..c013621f87 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/api", - "version": "5.0.3", + "version": "6.0.0", "description": "Common, generic types & interfaces for thi.ng projects", "module": "./index.js", "main": "./lib/index.js", @@ -32,7 +32,7 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/errors": "^1.0.3" + "@thi.ng/errors": "^1.0.4" }, "keywords": [ "compare", diff --git a/packages/api/src/api.ts b/packages/api/src/api.ts index 4de4c170cd..461af9c9ae 100644 --- a/packages/api/src/api.ts +++ b/packages/api/src/api.ts @@ -4,17 +4,22 @@ export const EVENT_ALL = "*"; export const EVENT_ENABLE = "enable"; export const EVENT_DISABLE = "disable"; +/** + * Internal use only. **Do NOT use in user land code!** + */ export const SEMAPHORE = Symbol(); /** - * Generic 2-element comparator function type alias. Must follow this - * contract and return: - * - * - negative if `a < b` - * - zero if `a == b` - * - positive if `a > b` + * No-effect placeholder function. + */ +export const NO_OP = () => {}; + +export type ArrayLikeIterable = ArrayLike & Iterable; + +/** + * A no-arg function, returning T. */ -export type Comparator = (a: T, b: T) => number; +export type Fn0 = () => T; /** * A single arg function from A => B. @@ -32,17 +37,246 @@ export type Fn2 = (a: A, b: B) => C; export type Fn3 = (a: A, b: B, c: C) => D; /** - * A vararg arg function to type T. + * A 4-arg function from A,B,C,D => E. + */ +export type Fn4 = (a: A, b: B, c: C, d: D) => E; + +/** + * A 5-arg function from A,B,C,D,E => F. + */ +export type Fn5 = (a: A, b: B, c: C, d: D, e: E) => F; + +/** + * A 6-arg function from A,B,C,D,E,F => G. + */ +export type Fn6 = ( + a: A, + b: B, + c: C, + d: D, + e: E, + f: F +) => G; + +/** + * A 7-arg function from A,B,C,D,E,F,G => H. + */ +export type Fn7 = ( + a: A, + b: B, + c: C, + d: D, + e: E, + f: F, + g: G +) => H; + +/** + * A 8-arg function from A,B,C,D,E,F,G,H => I. + */ +export type Fn8 = ( + a: A, + b: B, + c: C, + d: D, + e: E, + f: F, + g: G, + h: H +) => I; + +/** + * A 9-arg function from A,B,C,D,E,F,G,H,I => J. + */ +export type Fn9 = ( + a: A, + b: B, + c: C, + d: D, + e: E, + f: F, + g: G, + h: H, + i: I +) => J; + +/** + * A 10-arg function from A,B,C,D,E,F,G,H,I,J => K. + */ +export type Fn10 = ( + a: A, + b: B, + c: C, + d: D, + e: E, + f: F, + g: G, + h: H, + i: I, + j: J +) => K; + +export type FnO = (a: A, ...xs: any[]) => B; + +export type FnO2 = (a: A, b: B, ...xs: any[]) => C; + +export type FnO3 = (a: A, b: B, c: C, ...xs: any[]) => D; + +export type FnO4 = (a: A, b: B, c: C, d: D, ...xs: any[]) => E; + +export type FnO5 = ( + a: A, + b: B, + c: C, + d: D, + e: E, + ...xs: any[] +) => F; + +export type FnO6 = ( + a: A, + b: B, + c: C, + d: D, + e: E, + f: F, + ...xs: any[] +) => G; + +export type FnO7 = ( + a: A, + b: B, + c: C, + d: D, + e: E, + f: F, + g: G, + ...xs: any[] +) => H; + +export type FnO8 = ( + a: A, + b: B, + c: C, + d: D, + e: E, + f: F, + g: G, + h: H, + ...xs: any[] +) => I; + +export type FnO9 = ( + a: A, + b: B, + c: C, + d: D, + e: E, + f: F, + g: G, + h: H, + i: I, + ...xs: any[] +) => J; + +export type FnO10 = ( + a: A, + b: B, + c: C, + d: D, + e: E, + f: F, + g: G, + h: H, + i: I, + j: J, + ...xs: any[] +) => K; + +/** + * An untyped vararg arg function to type T. */ export type FnAny = (...xs: any[]) => T; +/** + * A typed vararg arg function from A => B. + */ +export type FnAnyT = (...xs: A[]) => B; + +/* + * Utilities for extracting key types of nested objects. + */ +export type Keys = keyof T; +export type Keys1> = Keys; +export type Keys2, B extends Keys1> = Keys1; +export type Keys3< + T, + A extends Keys, + B extends Keys1, + C extends Keys2 +> = Keys2; +export type Keys4< + T, + A extends Keys, + B extends Keys1, + C extends Keys2, + D extends Keys3 +> = Keys3; +export type Keys5< + T, + A extends Keys, + B extends Keys1, + C extends Keys2, + D extends Keys3, + E extends Keys4 +> = Keys4; + +/* + * Utilities for extracting value types from nested objects. + */ +export type Val1> = T[A]; +export type Val2, B extends Keys1> = Val1[B]; +export type Val3< + T, + A extends Keys, + B extends Keys1, + C extends Keys2 +> = Val2[C]; +export type Val4< + T, + A extends Keys, + B extends Keys1, + C extends Keys2, + D extends Keys3 +> = Val3[D]; +export type Val5< + T, + A extends Keys, + B extends Keys1, + C extends Keys2, + D extends Keys3, + E extends Keys4 +> = Val4[E]; + +/** + * Generic 2-element comparator function type alias. Must follow this + * contract and return: + * + * - negative if `a < b` + * - zero if `a == b` + * - positive if `a > b` + */ +export type Comparator = Fn2; + /** * Event listener. */ -export type Listener = (e: Event) => void; +export type Listener = Fn; export type NumericArray = number[] | TypedArray; +export type Primitive = number | string | boolean | symbol; + /** * Lookup path for nested data structures. */ @@ -56,22 +290,26 @@ export type Pair = [K, V]; /** * Predicate function mapping given value to true/false. */ -export type Predicate = (a: T) => boolean; +export type Predicate = Fn; /** * Predicate function mapping given args to true/false. */ -export type Predicate2 = (a: T, b: T) => boolean; +export type Predicate2 = Fn2; /** * Higher order `Predicate` builder. Possibly stateful. */ -export type StatefulPredicate = () => Predicate; +export type StatefulPredicate = Fn0>; /** * Higher order `Predicate2` builder. Possibly stateful. */ -export type StatefulPredicate2 = () => Predicate2; +export type StatefulPredicate2 = Fn0>; + +export type Tuple = [T, ...T[]] & { length: N }; + +export type IterableTuple = Tuple & Iterable; export type TypedArray = | Float32Array @@ -92,13 +330,21 @@ export type Watch = (id: string, oldState: T, newState: T) => void; /** * @param K key type * @param V value type - * @param T implementation type + * @param T return type */ -export interface IAssociative { +export interface IAssoc { assoc(key: K, val: V): T; + update(key: K, f: Fn): T; +} + +/** + * @param K key type + * @param V value type + * @param T return type + */ +export interface IAssocIn { assocIn(key: K[], val: V): T; - update(key: K, f: (v: V) => V): T; - updateIn(key: K[], f: (v: V) => V): T; + updateIn(key: K[], f: Fn): T; } /** @@ -181,20 +427,31 @@ export interface IDeref { } /** - * Extension of `IAssociative` for types supporting key removals. + * Extension of `IAssoc` for types supporting key removals. * * @param K key type * @param V value type - * @param T imlementation type + * @param T return type */ -export interface IDissoc extends IAssociative { +export interface IDissoc extends IAssoc { dissoc(key: K): T; } +/** + * Extension of `IAssocIn` for types supporting key removals. + * + * @param K key type + * @param V value type + * @param T return type + */ +export interface IDissocIn extends IAssocIn { + dissocIn(key: K[]): T; +} + export interface IEmpty { /** - * Returns an empty collection of same type (and possibly same - * config). + * Returns an empty/blank instance of same type (with possibly same + * config, if any). */ empty(): T; } @@ -251,21 +508,18 @@ export interface Event extends IID { } /** - * Interface to provide event emitter functionality. Also see `@INotify` - * decorator mixin + * @param K key type + * @param V value type */ -export interface INotify { - addListener(id: string, fn: Listener, scope?: any): boolean; - removeListener(id: string, fn: Listener, scope?: any): boolean; - notify(event: Event): void; +export interface IGet { + get(key: K, notfound?: V): V; } /** * @param K key type * @param V value type */ -export interface IGet { - get(key: K, notfound?: V): V; +export interface IGetIn { getIn(key: K[], notfound?: V): V; } @@ -300,8 +554,8 @@ export interface IIndexed { * Interface for collection types supporting addition of multiple * values. */ -export interface IInto { - into(coll: Iterable): this; +export interface IInto { + into(coll: Iterable): T; } /** @@ -327,6 +581,16 @@ export interface IMeta { withMeta(meta: any): T; } +/** + * Interface to provide event emitter functionality. Also see `@INotify` + * decorator mixin + */ +export interface INotify { + addListener(id: string, fn: Listener, scope?: any): boolean; + removeListener(id: string, fn: Listener, scope?: any): boolean; + notify(event: Event): void; +} + /** * Generic plain object with all key values of given type. */ @@ -342,42 +606,20 @@ export interface IRelease { } /** - * Generic interface for MUTABLE set collection types. - * - * @param T value type - */ -export interface ISet extends IInto { - /** - * Conjoins/adds value `x` to set and returns true if `x` has been - * added. - * - * @param x - */ - conj(x: T): boolean; - /** - * Disjoins/removes value `x` from set and returns true if `x` has - * been removed. - * - * @param x - */ - disj(x: T): boolean; -} - -/** - * Generic interface for IMMUTABLE set collection types. + * Generic interface for set collection types. * * @param V value type - * @param T implementation type + * @param T return type */ -export interface IImmutableSet extends IInto { +export interface ISet extends IInto { /** - * Conjoins/adds value `x` to set and returns updated set. + * Conjoins/adds value `x` to set. * * @param x */ conj(x: V): T; /** - * Disjoins/removes value `x` from set and returns updated set. + * Disjoins/removes value `x` from set. * * @param x */ @@ -385,41 +627,23 @@ export interface IImmutableSet extends IInto { } /** - * Generic interface for MUTABLE sequential collections implementing - * stack functionality. - * - * @param V value type - * @param T return/container type - */ -export interface IStack { - /** - * Returns top-of-stack item. - */ - peek(): V; - /** - * Removes top-of-stack item and returns it. - */ - pop(): V; - push(x: V): T; -} - -/** - * Generic interface for IMMUTABLE sequential collections implementing + * Generic interface for collections implementing * stack functionality. * * @param V value type - * @param T return/container type + * @param P return type for pop() + * @param Q return type for push() */ -export interface IImmutableStack { +export interface IStack { /** * Returns top-of-stack item. */ peek(): V; /** - * Returns collection w/ top-of-stack item removed. + * Removes top-of-stack item and returns type P. */ - pop(): T; - push(x: V): T; + pop(): P; + push(x: V): Q; } export interface IToHiccup { diff --git a/packages/api/src/assert.ts b/packages/api/src/assert.ts index 7e2ddf117e..5e18eebbaf 100644 --- a/packages/api/src/assert.ts +++ b/packages/api/src/assert.ts @@ -1,3 +1,5 @@ +import { NO_OP } from "./api"; + /** * Takes a `test` result or predicate function without args and throws * error with given `msg` if test failed (i.e. is falsy). The function @@ -13,4 +15,4 @@ export const assert = throw new Error(msg); } } - : () => {}; + : NO_OP; diff --git a/packages/api/src/mixins/iwatch.ts b/packages/api/src/mixins/iwatch.ts index 672775b0d4..26b351e13c 100644 --- a/packages/api/src/mixins/iwatch.ts +++ b/packages/api/src/mixins/iwatch.ts @@ -1,11 +1,8 @@ -import { IWatch } from "../api"; +import { Fn3, IWatch } from "../api"; import { mixin } from "../mixin"; export const IWatchMixin = mixin(>{ - addWatch( - id: string, - fn: (id: string, oldState: any, newState: any) => void - ) { + addWatch(id: string, fn: Fn3) { this._watches = this._watches || {}; if (this._watches[id]) { return false; diff --git a/packages/api/test/mixins.ts b/packages/api/test/mixins.ts index 70e4798de2..27c1e8fc3c 100644 --- a/packages/api/test/mixins.ts +++ b/packages/api/test/mixins.ts @@ -1,18 +1,21 @@ import * as assert from "assert"; - -import { Event, INotify, EVENT_ALL } from "../src/api"; +import { + Event, + EVENT_ALL, + INotify, + Listener +} from "../src/api"; import { INotifyMixin } from "../src/mixins/inotify"; -describe("mixins", () => { +describe("mixins", () => { it("INotify", () => { - @INotifyMixin class Foo implements INotify { - addListener(_: string, __: (e: Event) => void, ___?: any): boolean { + addListener(_: string, __: Listener, ___?: any): boolean { throw new Error(); } - removeListener(_: string, __: (e: Event) => void, ___?: any): boolean { + removeListener(_: string, __: Listener, ___?: any): boolean { throw new Error(); } notify(_: Event) { @@ -22,8 +25,8 @@ describe("mixins", () => { const res: any = {}; const foo = new Foo(); - const l = (e) => res[e.id] = e.value; - const lall = (e) => res[EVENT_ALL] = e.value; + const l = (e) => (res[e.id] = e.value); + const lall = (e) => (res[EVENT_ALL] = e.value); assert.doesNotThrow(() => foo.addListener("x", l)); assert.doesNotThrow(() => foo.addListener(EVENT_ALL, lall)); foo.notify({ id: "x", value: 1 }); @@ -35,4 +38,4 @@ describe("mixins", () => { foo.notify({ id: "x", value: 3 }); assert.deepEqual(res, { x: 1, [EVENT_ALL]: 2 }); }); -}); \ No newline at end of file +}); diff --git a/packages/arrays/CHANGELOG.md b/packages/arrays/CHANGELOG.md index c30343b9ec..33b60360a3 100644 --- a/packages/arrays/CHANGELOG.md +++ b/packages/arrays/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/arrays@0.1.0...@thi.ng/arrays@0.1.1) (2019-03-01) +## [0.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/arrays@0.1.4...@thi.ng/arrays@0.1.5) (2019-03-28) **Note:** Version bump only for package @thi.ng/arrays @@ -11,6 +11,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline + + # 0.1.0 (2019-02-15) diff --git a/packages/arrays/package.json b/packages/arrays/package.json index 99de3a24de..bcfd744afd 100644 --- a/packages/arrays/package.json +++ b/packages/arrays/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/arrays", - "version": "0.1.1", + "version": "0.1.5", "description": "Array / Arraylike utilities", "module": "./index.js", "main": "./lib/index.js", @@ -32,12 +32,12 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/checks": "^2.1.1", - "@thi.ng/compare": "^1.0.3", - "@thi.ng/equiv": "^1.0.3", - "@thi.ng/errors": "^1.0.3", - "@thi.ng/random": "^1.1.1" + "@thi.ng/api": "^6.0.0", + "@thi.ng/checks": "^2.1.4", + "@thi.ng/compare": "^1.0.4", + "@thi.ng/equiv": "^1.0.4", + "@thi.ng/errors": "^1.0.4", + "@thi.ng/random": "^1.1.3" }, "keywords": [ "arrays", diff --git a/packages/associative/CHANGELOG.md b/packages/associative/CHANGELOG.md index e67ff2e8ac..f233b0076d 100644 --- a/packages/associative/CHANGELOG.md +++ b/packages/associative/CHANGELOG.md @@ -3,57 +3,37 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.0.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@1.0.6...@thi.ng/associative@1.0.7) (2019-03-01) +# [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@1.0.12...@thi.ng/associative@2.0.0) (2019-03-28) -**Note:** Version bump only for package @thi.ng/associative +### Code Refactoring +* **associative:** fix/update invertMap() / invertObj() ([b57a1c0](https://github.com/thi-ng/umbrella/commit/b57a1c0)) +* **associative:** update set combinator ops ([9e78d20](https://github.com/thi-ng/umbrella/commit/9e78d20)) +### Features -## [1.0.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@1.0.5...@thi.ng/associative@1.0.6) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/associative - - - - - -## [1.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@1.0.4...@thi.ng/associative@1.0.5) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/associative - - - - - -## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@1.0.3...@thi.ng/associative@1.0.4) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/associative - - - - - -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@1.0.2...@thi.ng/associative@1.0.3) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/associative - - - - - -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@1.0.1...@thi.ng/associative@1.0.2) (2019-01-31) - -**Note:** Version bump only for package @thi.ng/associative +* **associative:** add polymorphic into() ([4577646](https://github.com/thi-ng/umbrella/commit/4577646)) +* **associative:** make .forEach() args readonly, add Symbol.toStringTag ([3749d41](https://github.com/thi-ng/umbrella/commit/3749d41)) +* **associative:** update SortedSet, IEquivSet, add tests ([e8234e8](https://github.com/thi-ng/umbrella/commit/e8234e8)) +* **associative:** update type sigs & args for various fns ([7bf2504](https://github.com/thi-ng/umbrella/commit/7bf2504)) +### BREAKING CHANGES +* **associative:** improved/stricter type sigs & args for various fns +- commonKeys*() +- indexed() +- join() / joinWith() +- renameKeys*() +- selectKeys*() +- first() +* **associative:** changed result type handling in invertMap(), see docstring +* **associative:** make `difference`, `intersection`, `union` immutable ops -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@1.0.0...@thi.ng/associative@1.0.1) (2019-01-21) -**Note:** Version bump only for package @thi.ng/associative diff --git a/packages/associative/package.json b/packages/associative/package.json index 2f52863cc0..211cc22264 100644 --- a/packages/associative/package.json +++ b/packages/associative/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/associative", - "version": "1.0.7", + "version": "2.0.0", "description": "Alternative Set & Map data type implementations with customizable equality semantics & supporting operations", "module": "./index.js", "main": "./lib/index.js", @@ -32,13 +32,13 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/checks": "^2.1.1", - "@thi.ng/compare": "^1.0.3", - "@thi.ng/dcons": "^2.0.7", - "@thi.ng/equiv": "^1.0.3", - "@thi.ng/errors": "^1.0.3", - "@thi.ng/transducers": "^5.1.1" + "@thi.ng/api": "^6.0.0", + "@thi.ng/checks": "^2.1.4", + "@thi.ng/compare": "^1.0.4", + "@thi.ng/dcons": "^2.0.13", + "@thi.ng/equiv": "^1.0.4", + "@thi.ng/errors": "^1.0.4", + "@thi.ng/transducers": "^5.3.1" }, "keywords": [ "data structures", diff --git a/packages/associative/src/api.ts b/packages/associative/src/api.ts index d1444ceaee..5206ef293c 100644 --- a/packages/associative/src/api.ts +++ b/packages/associative/src/api.ts @@ -3,6 +3,8 @@ import { ICopy, IEmpty, IEquiv, + IGet, + IInto, Predicate2 } from "@thi.ng/api"; @@ -10,19 +12,17 @@ export interface IEquivSet extends Set, ICopy>, IEmpty>, - IEquiv { - readonly [Symbol.species]: EquivSetConstructor; - into(xs: Iterable): this; + IEquiv, + IGet, + IInto> { disj(xs: Iterable): this; - get(val: T, notFound?: any): any; first(): T; - opts(): EquivSetOpts; } -export interface EquivSetConstructor { - new (): IEquivSet; - new (values?: Iterable, opts?: EquivSetOpts): IEquivSet; - readonly prototype: IEquivSet; +export interface EquivSetConstructor { + new (): IEquivSet; + new (values?: Iterable, opts?: any): IEquivSet; + readonly prototype: IEquivSet; } export interface EquivSetOpts { @@ -36,13 +36,13 @@ export interface EquivSetOpts { } export interface EquivMapOpts extends EquivSetOpts { - keys: EquivSetConstructor; + keys: EquivSetConstructor; } /** * SortedMapOpts implementation config settings. */ -export interface SortedMapOpts extends EquivSetOpts { +export interface SortedMapOpts { /** * Key comparison function. Must follow standard comparator contract * and return: @@ -50,7 +50,8 @@ export interface SortedMapOpts extends EquivSetOpts { * - positive if `a > b` * - `0` if `a == b` * - * Note: The `SortedMap` implementation only uses `<` comparisons. + * Note: The `SortedMap` implementation only uses `<` and `==` style + * comparisons. * * Default: `@thi.ng/compare` */ @@ -59,12 +60,12 @@ export interface SortedMapOpts extends EquivSetOpts { * Initial capacity before resizing (doubling) occurs. * This value will be rounded up to next pow2. * - * Default: 16 + * Default: 8 */ capacity: number; /** - * Probability for a value to exist in any express lane. - * Default: `1 / Math.E` + * Probability for a value to exist in any express lane of the + * underlying Skip List implementation. Default: `1 / Math.E` */ probability: number; } diff --git a/packages/associative/src/array-set.ts b/packages/associative/src/array-set.ts index 333f60f0e3..c0cf356f7d 100644 --- a/packages/associative/src/array-set.ts +++ b/packages/associative/src/array-set.ts @@ -1,4 +1,9 @@ -import { Pair, Predicate2, SEMAPHORE } from "@thi.ng/api"; +import { + Fn3, + Pair, + Predicate2, + SEMAPHORE +} from "@thi.ng/api"; import { equiv } from "@thi.ng/equiv"; import { EquivSetOpts, IEquivSet } from "./api"; @@ -33,13 +38,18 @@ export class ArraySet extends Set implements IEquivSet { return ArraySet; } + get [Symbol.toStringTag]() { + return "ArraySet"; + } + get size() { return __private.get(this).vals.length; } copy() { - const s = new ArraySet(null, this.opts()); - __private.get(s).vals = [...__private.get(this).vals]; + const $this = __private.get(this); + const s = new ArraySet(null, { equiv: $this.equiv }); + __private.get(s).vals = $this.vals.slice(); return s; } @@ -131,7 +141,7 @@ export class ArraySet extends Set implements IEquivSet { return true; } - forEach(fn: (val: T, val2: T, set: Set) => void, thisArg?: any) { + forEach(fn: Fn3, Readonly, Set, void>, thisArg?: any) { const vals = __private.get(this).vals; for (let i = vals.length - 1; i >= 0; i--) { const v = vals[i]; diff --git a/packages/associative/src/common-keys.ts b/packages/associative/src/common-keys.ts index 02dd706b4c..8b40f0c141 100644 --- a/packages/associative/src/common-keys.ts +++ b/packages/associative/src/common-keys.ts @@ -1,19 +1,19 @@ -import { IObjectOf } from "@thi.ng/api"; - /** * Like `commonKeysObj()`, but for ES6 Maps. * * @param a * @param b + * @param out */ -export const commonKeysMap = (a: Map, b: Map) => { - const res: K[] = []; +export const commonKeysMap = ( + a: Map, + b: Map, + out: K[] = [] +) => { for (let k of a.keys()) { - if (b.has(k)) { - res.push(k); - } + b.has(k) && out.push(k); } - return res; + return out; }; /** @@ -27,13 +27,15 @@ export const commonKeysMap = (a: Map, b: Map) => { * * @param a * @param b + * @param out */ -export const commonKeysObj = (a: IObjectOf, b: IObjectOf) => { - const res: string[] = []; +export const commonKeysObj = ( + a: A, + b: B, + out: string[] = [] +): (keyof A & keyof B)[] => { for (let k in a) { - if (b.hasOwnProperty(k)) { - res.push(k); - } + b.hasOwnProperty(k) && out.push(k); } - return res; + return out; }; diff --git a/packages/associative/src/difference.ts b/packages/associative/src/difference.ts index 959b1f9298..f0312209db 100644 --- a/packages/associative/src/difference.ts +++ b/packages/associative/src/difference.ts @@ -1,12 +1,22 @@ +import { into } from "./into"; import { copy, empty } from "./utils"; -export const difference = (a: Set, b: Set): Set => { +/** + * Computes the difference of sets `a - b` and writes results to new set + * or optionally given set `out` (assumed to be empty for correct + * results). + * + * @param a + * @param b + * @param out + */ +export const difference = (a: Set, b: Set, out?: Set): Set => { if (a === b) { - return empty(a, Set); + return out || empty(a, Set); } - const res = copy(a, Set); + out = out ? into(out, a) : copy(a, Set); for (let i of b) { - res.delete(i); + out.delete(i); } - return res; + return out; }; diff --git a/packages/associative/src/equiv-map.ts b/packages/associative/src/equiv-map.ts index 9594417779..44a7454651 100644 --- a/packages/associative/src/equiv-map.ts +++ b/packages/associative/src/equiv-map.ts @@ -1,4 +1,5 @@ import { + Fn3, ICopy, IEmpty, IEquiv, @@ -26,16 +27,22 @@ export class EquivMap extends Map IEquiv { /** * Converts given vanilla object into an `EquivMap` instance with - * default options and returns it. + * default (or optionally provided) options and returns it. By + * default uses strict `===` equality check for `equiv` option. * * @param obj + * @param opts */ - static fromObject(obj: IObjectOf): EquivMap { - const m = new EquivMap(); + static fromObject( + obj: IObjectOf, + opts?: Partial> + ): EquivMap { + const m = new EquivMap(null, { + equiv: (a, b) => a === b, + ...opts + }); for (let k in obj) { - if (obj.hasOwnProperty(k)) { - m.set(k, obj[k]); - } + obj.hasOwnProperty(k) && m.set(k, obj[k]); } return m; } @@ -51,10 +58,7 @@ export class EquivMap extends Map */ constructor(pairs?: Iterable>, opts?: Partial>) { super(); - const _opts: EquivMapOpts = Object.assign( - { equiv, keys: ArraySet }, - opts - ); + const _opts: EquivMapOpts = { equiv, keys: ArraySet, ...opts }; __private.set(this, { keys: new _opts.keys(null, { equiv: _opts.equiv }), map: new Map(), @@ -73,6 +77,10 @@ export class EquivMap extends Map return EquivMap; } + get [Symbol.toStringTag]() { + return "EquivMap"; + } + get size() { return __private.get(this).keys.size; } @@ -134,7 +142,7 @@ export class EquivMap extends Map return this; } - forEach(fn: (val: V, key: K, map: Map) => void, thisArg?: any) { + forEach(fn: Fn3, Map, void>, thisArg?: any) { for (let pair of __private.get(this).map) { fn.call(thisArg, pair[1], pair[0], this); } diff --git a/packages/associative/src/index.ts b/packages/associative/src/index.ts index 9d0da2837f..cdfdfbdbaa 100644 --- a/packages/associative/src/index.ts +++ b/packages/associative/src/index.ts @@ -4,6 +4,7 @@ export * from "./difference"; export * from "./equiv-map"; export * from "./indexed"; export * from "./intersection"; +export * from "./into"; export * from "./invert"; export * from "./join"; export * from "./ll-set"; diff --git a/packages/associative/src/indexed.ts b/packages/associative/src/indexed.ts index af6acda55b..4b5e54bccb 100644 --- a/packages/associative/src/indexed.ts +++ b/packages/associative/src/indexed.ts @@ -20,8 +20,8 @@ import { empty } from "./utils"; * @param records objects to index * @param ks keys used for indexing */ -export const indexed = (records: Iterable, ks: PropertyKey[]) => { - const res = new EquivMap>(); +export const indexed = (records: Iterable, ks: (keyof T)[]) => { + const res = new EquivMap<{ [id in keyof T]?: T[id] }, Set>(); let x, ik, rv; for (x of records) { ik = selectKeysObj(x, ks); diff --git a/packages/associative/src/intersection.ts b/packages/associative/src/intersection.ts index 8c1d033ab2..c89cd44f14 100644 --- a/packages/associative/src/intersection.ts +++ b/packages/associative/src/intersection.ts @@ -1,17 +1,28 @@ +import { into } from "./into"; import { empty } from "./utils"; -export const intersection = (a: Set, b: Set): Set => { +/** + * Computes the intersection of sets `a` and `b` and writes results into + * new set or optionally given set `out` (assumed to be empty for + * correct results). If `out` is *not* given, the returned Set type will + * be that of `a` (provided it defines `Symbol.species`). + * + * @param a + * @param b + * @param out + */ +export const intersection = (a: Set, b: Set, out?: Set): Set => { + out = out || empty(a, Set); if (a === b) { - return a; + return into(out, a); } if (b.size < a.size) { - return intersection(b, a); + return intersection(b, a, out); } - const res = empty(a, Set); for (let i of b) { if (a.has(i)) { - res.add(i); + out.add(i); } } - return res; + return out; }; diff --git a/packages/associative/src/into.ts b/packages/associative/src/into.ts new file mode 100644 index 0000000000..c7aac008b7 --- /dev/null +++ b/packages/associative/src/into.ts @@ -0,0 +1,26 @@ +import { Pair } from "@thi.ng/api"; +import { isMap } from "@thi.ng/checks"; + +/** + * Adds elements from `src` iterable to `dest` Map or Set. + * + * @param dest + * @param src + */ +export function into( + dest: Map, + src: Iterable> +): Map; +export function into(dest: Set, src: Iterable): Set; +export function into(dest: Map | Set, src: Iterable) { + if (isMap(dest)) { + for (let x of src) { + dest.set(x[0], x[1]); + } + } else { + for (let x of src) { + dest.add(x); + } + } + return dest; +} diff --git a/packages/associative/src/invert.ts b/packages/associative/src/invert.ts index 710097f39e..ebb40f254d 100644 --- a/packages/associative/src/invert.ts +++ b/packages/associative/src/invert.ts @@ -1,19 +1,23 @@ import { IObjectOf } from "@thi.ng/api"; -import { empty } from "./utils"; /** * Returns a new map in which the original values are used as keys and - * original keys as values. + * original keys as values. If `dest` is given, writes results in that + * map instead. Depending on the value type of `src` and/or if the + * inverted map should use custom key equality semantics as provided by + * the Map types in this package, you MUST provide a `dest` map, since + * the default `dest` will only be a standard ES6 Map. * * ``` - * invertMap(new Map([["a", 1], ["b", 2]])); + * invertMap(new Map(), new Map([["a", 1], ["b", 2]])); * // Map { 1 => 'a', 2 => 'b' } * ``` * * @param src + * @param dest */ -export const invertMap = (src: Map) => { - const dest: Map = empty(src, Map); +export const invertMap = (src: Map, dest?: Map) => { + dest = dest || new Map(); for (let p of src) { dest.set(p[1], p[0]); } @@ -22,7 +26,8 @@ export const invertMap = (src: Map) => { /** * Returns a new object in which the original values are used as keys - * and original keys as values. + * and original keys as values. If `dest` is given, writes results in + * that object instead. * * ``` * invertObj({a: 1, b: 2}) @@ -30,9 +35,12 @@ export const invertMap = (src: Map) => { * ``` * * @param src + * @param dest */ -export const invertObj = (src: IObjectOf) => { - const dest: IObjectOf = {}; +export const invertObj = ( + src: IObjectOf, + dest: IObjectOf = {} +) => { for (let k in src) { dest[src[k]] = k; } diff --git a/packages/associative/src/join.ts b/packages/associative/src/join.ts index 27247b1650..1f90e2358d 100644 --- a/packages/associative/src/join.ts +++ b/packages/associative/src/join.ts @@ -12,7 +12,7 @@ import { empty, first, objValues } from "./utils"; * is assumed to have plain objects as values with at least one of the * keys present in both sides. Furthermore the objects in each set are * assumed to have the same internal structure (i.e. sets of keys). - * Returns new set of same type as `xrel`. + * Returns new set of same type as `a`. * * ``` * join( @@ -30,26 +30,26 @@ import { empty, first, objValues } from "./utils"; * // } * ``` * - * @param xrel - * @param yrel + * @param a + * @param b */ -export const join = ( - xrel: Set>, - yrel: Set> -): Set> => { - if (xrel.size && yrel.size) { - const ks = commonKeysObj(first(xrel) || {}, first(yrel) || {}); - let a: Set, b: Set; - if (xrel.size <= yrel.size) { - a = xrel; - b = yrel; +export const join = ( + a: Set, + b: Set +): Set & Pick> => { + if (a.size && b.size) { + const ks = commonKeysObj(first(a) || {}, first(b) || {}); + let aa: Set, bb: Set; + if (a.size <= b.size) { + aa = a; + bb = b; } else { - a = yrel; - b = xrel; + aa = b; + bb = a; } - const idx = indexed(a, ks); - const res: Set = empty(xrel, Set); - for (let x of b) { + const idx = indexed(aa, ks); + const res: Set = empty(a, Set); + for (let x of bb) { const found = idx.get(selectKeysObj(x, ks)); if (found) { for (let f of found) { @@ -59,16 +59,16 @@ export const join = ( } return res; } - return empty(xrel, Set); + return empty(a, Set); }; /** * Similar to `join()`, computes the join between two sets of relations, * using the given keys in `kmap` only for joining and ignoring others. - * `kmap` can also be used to translate join keys in `yrel` where + * `kmap` can also be used to translate join keys in `b` where * needed. Else, if no renaming is desired, the values in `kmap` should * be the same as their respective keys, e.g. `{id: "id"}`. Returns new - * set of same type as `xrel`. + * set of same type as `a`. * * ``` * joinWith( @@ -86,31 +86,31 @@ export const join = ( * // { type: 2, color: 'blue', id: 2, name: 'bar' } } * ``` * - * @param xrel - * @param yrel + * @param a + * @param b * @param kmap keys to compute join for */ -export const joinWith = ( - xrel: Set, - yrel: Set, - kmap: IObjectOf +export const joinWith = ( + a: Set, + b: Set, + kmap: { [id in keyof A]?: keyof B } ): Set => { - if (xrel.size && yrel.size) { - let r: Set, s: Set; + if (a.size && b.size) { + let aa: Set, bb: Set; let k: IObjectOf; - if (xrel.size <= yrel.size) { - r = xrel; - s = yrel; + if (a.size <= b.size) { + aa = a; + bb = b; k = invertObj(kmap); } else { - r = yrel; - s = xrel; + aa = b; + bb = a; k = kmap; } - const idx = indexed(r, objValues(k)); + const idx = indexed(aa, objValues(k)); const ks = Object.keys(k); - const res: Set = empty(xrel, Set); - for (let x of s) { + const res: Set = empty(a, Set); + for (let x of bb) { const found = idx.get(renameKeysObj(selectKeysObj(x, ks), k)); if (found) { for (let f of found) { @@ -120,5 +120,7 @@ export const joinWith = ( } return res; } - return empty(xrel, Set); + return empty(a, Set); }; + +joinWith(new Set([{ a: 1, b: 2 }]), new Set([{ id: 1, c: 2 }]), { a: "id" }); diff --git a/packages/associative/src/ll-set.ts b/packages/associative/src/ll-set.ts index 6b329a92b9..c227306b34 100644 --- a/packages/associative/src/ll-set.ts +++ b/packages/associative/src/ll-set.ts @@ -1,4 +1,9 @@ -import { Pair, Predicate2, SEMAPHORE } from "@thi.ng/api"; +import { + Fn3, + Pair, + Predicate2, + SEMAPHORE +} from "@thi.ng/api"; import { DCons } from "@thi.ng/dcons"; import { equiv } from "@thi.ng/equiv"; import { EquivSetOpts, IEquivSet } from "./api"; @@ -37,6 +42,10 @@ export class LLSet extends Set implements IEquivSet { return LLSet; } + get [Symbol.toStringTag]() { + return "LLSet"; + } + get size() { return __private.get(this).vals.length; } @@ -139,7 +148,7 @@ export class LLSet extends Set implements IEquivSet { return true; } - forEach(fn: (val: T, val2: T, set: Set) => void, thisArg?: any) { + forEach(fn: Fn3, Readonly, Set, void>, thisArg?: any) { let i = __private.get(this).vals.head; while (i) { fn.call(thisArg, i.value, i.value, this); diff --git a/packages/associative/src/merge-apply.ts b/packages/associative/src/merge-apply.ts index 89c7b05935..c80d76067e 100644 --- a/packages/associative/src/merge-apply.ts +++ b/packages/associative/src/merge-apply.ts @@ -22,14 +22,22 @@ export const mergeApplyMap = ( }; /** - * Similar to `mergeObj()`, but only supports 2 args and any function - * values in `xs` will be called with respective value in `src` to - * produce a new / derived value for that key. Returns new merged object - * and does not modify any of the inputs. + * Similar to `mergeObjWith()`, but only supports 2 args and any + * function values in `xs` will be called with respective value in `src` + * to produce a new / derived value for that key, i.e. * * ``` - * mapKeysObj({a: "hello", b: 23}, {a: (x) => x + " world", b: 42}); - * // { a: 'hello world', b: 42 } + * dest[k] = xs[k](src[k]) + * ``` + * + * Returns new merged object and does not modify any of the inputs. + * + * ``` + * mergeApplyObj( + * {a: "hello", b: 23, c: 12}, + * {a: (x) => x + " world", b: 42} + * ); + * // { a: 'hello world', b: 42, c: 12 } * ``` * * @param src diff --git a/packages/associative/src/merge-with.ts b/packages/associative/src/merge-with.ts index 352da4393a..85e67c341a 100644 --- a/packages/associative/src/merge-with.ts +++ b/packages/associative/src/merge-with.ts @@ -1,8 +1,8 @@ -import { IObjectOf } from "@thi.ng/api"; +import { Fn2, IObjectOf } from "@thi.ng/api"; import { copy } from "./utils"; export const mergeMapWith = ( - f: (a: V, b: V) => V, + f: Fn2, dest: Map, ...xs: Map[] ) => { @@ -20,7 +20,7 @@ export const mergeMapWith = ( }; export const mergeObjWith = ( - f: (a: T, b: T) => T, + f: Fn2, dest: IObjectOf, ...xs: IObjectOf[] ) => { diff --git a/packages/associative/src/rename-keys.ts b/packages/associative/src/rename-keys.ts index aca528f8ae..ddb0aac22b 100644 --- a/packages/associative/src/rename-keys.ts +++ b/packages/associative/src/rename-keys.ts @@ -1,4 +1,3 @@ -import { IObjectOf } from "@thi.ng/api"; import { empty } from "./utils"; /** @@ -7,13 +6,18 @@ import { empty } from "./utils"; * * @param src * @param km + * @param out */ -export const renameKeysMap = (src: Map, km: Map) => { - const dest: Map = empty(src, Map); +export const renameKeysMap = ( + src: Map, + km: Map, + out?: Map +) => { + out = out || empty(src, Map); for (let [k, v] of src) { - dest.set(km.has(k) ? km.get(k) : k, v); + out.set(km.has(k) ? km.get(k) : k, v); } - return dest; + return out; }; /** @@ -30,12 +34,12 @@ export const renameKeysMap = (src: Map, km: Map) => { * @param km */ export const renameKeysObj = ( - src: IObjectOf, - km: IObjectOf + src: T, + km: { [id in keyof T]?: PropertyKey }, + out: any = {} ) => { - const dest = {}; for (let k in src) { - dest[km.hasOwnProperty(k) ? km[k] : k] = src[k]; + out[km.hasOwnProperty(k) ? km[k] : k] = src[k]; } - return dest; + return out; }; diff --git a/packages/associative/src/select-keys.ts b/packages/associative/src/select-keys.ts index dac0f64ce8..05e6952703 100644 --- a/packages/associative/src/select-keys.ts +++ b/packages/associative/src/select-keys.ts @@ -1,4 +1,3 @@ -import { IObjectOf } from "@thi.ng/api"; import { empty } from "./utils"; /** @@ -8,12 +7,13 @@ import { empty } from "./utils"; * @param src * @param ks selected keys */ -export const selectKeysMap = (src: Map, ks: Iterable): any => { +export const selectKeysMap = ( + src: Map, + ks: Iterable +): Map => { const dest = empty(src, Map); for (let k of ks) { - if (src.has(k)) { - dest.set(k, src.get(k)); - } + src.has(k) && dest.set(k, src.get(k)); } return dest; }; @@ -26,14 +26,12 @@ export const selectKeysMap = (src: Map, ks: Iterable): any => { * @param ks */ export const selectKeysObj = ( - src: IObjectOf, + src: T, ks: Iterable -): any => { - const dest: IObjectOf = {}; +): { [id in keyof T]?: T[id] } => { + const dest: any = {}; for (let k of ks) { - if (src.hasOwnProperty(k)) { - dest[k] = src[k]; - } + src.hasOwnProperty(k) && (dest[k] = src[k]); } return dest; }; diff --git a/packages/associative/src/sorted-map.ts b/packages/associative/src/sorted-map.ts index b99155bd7e..18e662a9c7 100644 --- a/packages/associative/src/sorted-map.ts +++ b/packages/associative/src/sorted-map.ts @@ -1,109 +1,91 @@ import { Comparator, - ICompare, - ICopy, - IEmpty, - IEquiv, + Fn3, IObjectOf, Pair, - Predicate2, SEMAPHORE } from "@thi.ng/api"; -import { isArray } from "@thi.ng/checks"; import { compare } from "@thi.ng/compare"; import { equiv } from "@thi.ng/equiv"; -import { illegalArgs } from "@thi.ng/errors"; -import { - IReducible, - isReduced, - map, - ReductionFn -} from "@thi.ng/transducers"; +import { isReduced, map, ReductionFn } from "@thi.ng/transducers"; import { SortedMapOpts } from "./api"; -// stores private properties for all instances -// http://fitzgeraldnick.com/2014/01/13/hiding-implementation-details-with-e6-weakmaps.html -const __private = new WeakMap, SortedMapProps>(); - -interface SortedMapProps { - head: any[]; - tail: any[]; - update: any[]; - nil: any[]; - equiv: Predicate2; - cmp: Comparator; - level: number; - maxLevel: number; - p: number; - cap: number; +interface SortedMapState { + head: Node; + cmp: Comparator; + maxh: number; + h: number; length: number; + cap: number; + p: number; } -const KEY = 0; -const VAL = 1; -const PREV = 2; -const NEXT = 3; +class Node { + k: K; + v: V; + next: Node[]; -const makeNode = (level: number, key?, value?) => { - const node = new Array(4 + level); - node[KEY] = key; - node[VAL] = value; - return node; -}; + constructor(k: K, v: V, h: number) { + this.k = k; + this.v = v; + this.next = new Array(h + 1); + } +} -/** - * This class is an alternative implementation of the ES6 Map API using - * a Skip list as backing store and supports configurable key equality - * and sorting semantics. - * - * William Pugh (creator of this data structure) description: - * - * "Skip lists are probabilistic data structures that have the same - * asymptotic expected time bounds as balanced trees, are simpler, - * faster and use less space." - * - * Adapted & refactored from Python version: - * - http://pythonsweetness.tumblr.com/post/45227295342/fast-pypy-compatible-ordered-map-in-89-lines-of - * - * Data structure description: - * - ftp://ftp.cs.umd.edu/pub/skipLists/skiplists.pdf - * - https://en.wikipedia.org/wiki/Skip_list - */ -export class SortedMap extends Map - implements - ICopy>, - ICompare>, - IEmpty>, - IEquiv, - IReducible> { - static fromObject(obj: IObjectOf): SortedMap { +// stores private properties for all instances +// http://fitzgeraldnick.com/2014/01/13/hiding-implementation-details-with-e6-weakmaps.html +const __private = new WeakMap, SortedMapState>(); + +export class SortedMap extends Map { + /** + * Creates new `SortedMap` instance from given object's key-value + * pairs. + * + * @param obj + * @param opts + */ + static fromObject( + obj: IObjectOf, + opts?: Partial> + ): SortedMap { const m = new SortedMap(null, { - capacity: Object.keys(obj).length + capacity: Object.keys(obj).length, + ...opts }); for (let k in obj) { - m.set(k, obj[k]); + obj.hasOwnProperty(k) && m.set(k, obj[k]); } return m; } - static readonly DEFAULT_CAP = 16; - static readonly DEFAULT_P = 1 / Math.E; + static DEFAULT_CAP = 8; + static DEFAULT_P = 1 / Math.E; /** - * Creates new instance with optional given key-value pairs and/or - * implementation options. + * Creates new `SortedMap` instance with optionally given pairs + * and/or options. * - * @param values + * @param pairs * @param opts */ constructor( - values?: Iterable>, + pairs?: Iterable>, opts: Partial> = {} ) { super(); - values = this.init(values, opts); - if (values) { - this.into(values); + const cap = opts.capacity || SortedMap.DEFAULT_CAP; + const maxh = Math.ceil(Math.log2(cap)); + __private.set(this, { + head: new Node(null, null, 0), + cap: Math.pow(2, maxh), + cmp: opts.compare || compare, + p: opts.probability || SortedMap.DEFAULT_P, + maxh, + length: 0, + h: 0 + }); + if (pairs) { + this.into(pairs); } } @@ -111,8 +93,40 @@ export class SortedMap extends Map return SortedMap; } - [Symbol.iterator]() { - return this.entries(); + *[Symbol.iterator](): IterableIterator> { + let node = __private.get(this).head; + while ((node = node.next[0])) { + yield [node.k, node.v]; + } + } + + *entries(key?: K, max = false): IterableIterator> { + const $this = __private.get(this); + let node = $this.head; + const cmp = $this.cmp; + let code: number; + if (max) { + while ((node = node.next[0])) { + if (key === undefined || (code = cmp(node.k, key)) <= 0) { + yield [node.k, node.v]; + if (code === 0) return; + } + } + } else { + while ((node = node.next[0])) { + if (key === undefined || (code = cmp(node.k, key)) >= 0) { + yield [node.k, node.v]; + } + } + } + } + + keys(key?: K, max = false): IterableIterator { + return map((p) => p[0], this.entries(key, max)); + } + + values(key?: K, max = false): IterableIterator { + return map((p) => p[1], this.entries(key, max)); } get size() { @@ -120,7 +134,10 @@ export class SortedMap extends Map } clear() { - this.init(null, { ...this.opts(), capacity: SortedMap.DEFAULT_CAP }); + const $this = __private.get(this); + $this.head = new Node(null, null, 0); + $this.length = 0; + $this.h = 0; } empty(): SortedMap { @@ -135,8 +152,8 @@ export class SortedMap extends Map } compare(o: Map) { - const n = this.size, - m = o.size; + const n = this.size; + const m = o.size; if (n < m) return -1; if (n > m) return 1; const i = this.entries(); @@ -173,93 +190,85 @@ export class SortedMap extends Map } first(): Pair { - const node = __private.get(this).head[NEXT]; - if (node[KEY] !== undefined) { - return [node[KEY], node[VAL]]; - } + const node = __private.get(this).head.next[0]; + return node ? [node.k, node.v] : undefined; } - forEach(fn: (val: V, key: K, map: Map) => void, thisArg?: any) { - for (let p of this) { - fn.call(thisArg, p[1], p[0], this); - } + get(k: K, notFound?: V) { + const node = this.findPredNode(k).next[0]; + return node && __private.get(this).cmp(node.k, k) === 0 + ? node.v + : notFound; } - set(key: K, value: V) { - let $this = __private.get(this); - const update = $this.update.slice(); - let node = this.findLessAndUpdate(update, key); - let prev = node; - node = node[NEXT]; - if ($this.equiv(node[KEY], key)) node[VAL] = value; - else { - if ($this.length >= $this.cap) { - this.grow(); - $this = __private.get(this); - prev = this.findLessAndUpdate(update, key); - } - const newLevel = this.randomLevel(); - $this.level = Math.max($this.level, newLevel); - node = makeNode(newLevel, key, value); - node[PREV] = prev; - for (let i = 0; i <= newLevel; i++) { - const j = i + NEXT; - node[j] = update[i][j]; - update[i][j] = node; - } - if (node[NEXT] === $this.nil) { - $this.tail = node; - } else { - node[NEXT][PREV] = node; - } - $this.length++; - } - return this; + has(key: K) { + return this.get(key, SEMAPHORE) !== SEMAPHORE; } - delete(key: K) { + set(k: K, v: V) { const $this = __private.get(this); - const update = $this.update.slice(); - let node = this.findLessAndUpdate(update, key)[NEXT]; - if ($this.equiv(node[KEY], key)) { - node[NEXT][PREV] = update[0]; - for (let i = 0; i <= $this.level; i++) { - const j = i + NEXT; - if (update[i][j] !== node) { - break; - } - update[i][j] = node[j]; - } + let node = $this.head; + let level = $this.h; + let stack = new Array(level); + const cmp = $this.cmp; + let code: number; + while (level >= 0) { while ( - $this.level > 0 && - $this.head[$this.level + NEXT][KEY] === undefined + node.next[level] && + (code = cmp(node.next[level].k, k)) < 0 ) { - $this.level--; + node = node.next[level]; } - if ($this.tail === node) { - $this.tail = node[PREV]; + if (node.next[level] && code === 0) { + do { + node.next[level].v = v; + } while (--level >= 0); + return this; } - $this.length--; - return true; + stack[level--] = node; } - return false; - } - - dissoc(...keys: K[]) { - for (let k of keys) { - this.delete(k); + const h = this.pickHeight($this.maxh, $this.h, $this.p); + node = new Node(k, v, h); + while ($this.h < h) { + stack[++$this.h] = $this.head; + } + for (let i = 0; i <= h; i++) { + node.next[i] = stack[i].next[i]; + stack[i].next[i] = node; + } + $this.length++; + if ($this.length >= $this.cap) { + $this.cap *= 2; + $this.maxh++; } return this; } - has(key: K) { - return this.get(key, SEMAPHORE) !== SEMAPHORE; - } - - get(key: K, notFound?: any) { + delete(k: K) { const $this = __private.get(this); - const node = this.findLess(key)[NEXT]; - return $this.equiv(node[KEY], key) ? node[VAL] : notFound; + let node: Node = $this.head; + let level = $this.h; + let removed = false; + const cmp = $this.cmp; + let code: number; + while (level >= 0) { + while ( + node.next[level] && + (code = cmp(node.next[level].k, k)) < 0 + ) { + node = node.next[level]; + } + if (node.next[level] && code === 0) { + removed = true; + node.next[level] = node.next[level].next[level]; + if (node == $this.head && !node.next[level]) { + $this.h = Math.max(0, $this.h - 1); + } + } + level--; + } + if (removed) $this.length--; + return removed; } into(pairs: Iterable>) { @@ -269,139 +278,56 @@ export class SortedMap extends Map return this; } - $reduce(rfn: ReductionFn>, acc: any) { - const $this = __private.get(this); - let node = $this.head[NEXT]; - while (node[KEY] !== undefined && !isReduced(acc)) { - acc = rfn(acc, [node[KEY], node[VAL]]); - node = node[NEXT]; + dissoc(...keys: K[]) { + for (let k of keys) { + this.delete(k); } - return acc; + return this; } - *entries(key?: K, reverse = false): IterableIterator> { - const $this = __private.get(this); - const step = reverse ? PREV : NEXT; - let node = reverse ? $this.tail : $this.head[NEXT]; - if (key !== undefined) { - const found = this.findLess(key); - // the original python impl doesn't handle unknown and out-of-range keys properly - node = - !reverse || - (found[NEXT] != $this.nil && $this.equiv(found[NEXT][KEY], key)) - ? found[NEXT] - : found; - } - while (node[KEY] !== undefined) { - yield [node[KEY], node[VAL]]; - node = node[step]; + forEach(fn: Fn3, Map, void>, thisArg?: any) { + for (let p of this) { + fn.call(thisArg, p[1], p[0], this); } } - keys(key?: K, reverse = false): IterableIterator { - return map((p) => p[0], this.entries(key, reverse)); - } - - values(key?: K, reverse = false): IterableIterator { - return map((p) => p[1], this.entries(key, reverse)); - } - - protected init( - values: Iterable>, - opts: Partial> - ) { - let cap; - if (values && !opts.capacity) { - values = isArray(values) ? values : [...values]; - cap = Math.max((values).length, SortedMap.DEFAULT_CAP); - } else { - cap = opts.capacity || SortedMap.DEFAULT_CAP; + $reduce(rfn: ReductionFn>, acc: any) { + let node = __private.get(this).head; + while ((node = node.next[0]) && !isReduced(acc)) { + acc = rfn(acc, [node.k, node.v]); } - cap < 1 && illegalArgs(`invalid capacity: ${cap}`); - const maxLevel = Math.ceil(Math.log2(cap)); - const nil = makeNode(-1); - const head = makeNode(maxLevel).fill(nil, 3); - const update = new Array(maxLevel + 1).fill(head); - __private.set(this, { - head, - update, - nil, - tail: nil, - equiv: opts.equiv || equiv, - cmp: opts.compare || compare, - level: 0, - maxLevel, - p: opts.probability || SortedMap.DEFAULT_P, - cap: Math.pow(2, maxLevel), - length: 0 - }); - return values; + return acc; } - opts(growFactor = 1): SortedMapOpts { + opts(): SortedMapOpts { const $this = __private.get(this); return { - capacity: $this.cap * growFactor, - equiv: $this.equiv, + capacity: $this.cap, compare: $this.cmp, probability: $this.p }; } - /** - * Recreates map with double capacity. - */ - protected grow() { - const tmp = new SortedMap(this.entries(), this.opts(2)); - __private.set(this, __private.get(tmp)); - __private.delete(tmp); - } - - protected randomLevel() { - const $this = __private.get(this); - const max = Math.min($this.maxLevel, $this.level + 1); - const p = $this.p; - let level = 0; - while (Math.random() < p && level < max) { - level++; - } - return level; - } - - protected findLess(key: K) { + protected findPredNode(k: K) { const $this = __private.get(this); const cmp = $this.cmp; let node = $this.head; - for (let i = $this.level; i >= 0; i--) { - const j = i + NEXT; - let k = node[j][KEY]; - while (k !== undefined && cmp(k, key) < 0) { - node = node[j]; - k = node[j][KEY]; + let level = $this.h; + while (level >= 0) { + while (node.next[level] && cmp(node.next[level].k, k) < 0) { + node = node.next[level]; } + level--; } return node; } - /** - * Like `findLess`, but records path in `update` array - * - * @param update - * @param key - */ - protected findLessAndUpdate(update, key: K) { - const $this = __private.get(this); - const cmp = $this.cmp; - let node = $this.head; - for (let i = $this.level; i >= 0; i--) { - const j = i + NEXT; - let k = node[j][KEY]; - while (k !== undefined && cmp(k, key) < 0) { - node = node[j]; - k = node[j][KEY]; - } - update[i] = node; + protected pickHeight(maxh: number, h: number, p: number) { + const max = Math.min(maxh, h + 1); + let level = 0; + while (Math.random() < p && level < max) { + level++; } - return node; + return level; } } diff --git a/packages/associative/src/sorted-set.ts b/packages/associative/src/sorted-set.ts index 30ef7e30f3..6c9eba83b4 100644 --- a/packages/associative/src/sorted-set.ts +++ b/packages/associative/src/sorted-set.ts @@ -1,4 +1,4 @@ -import { ICompare, Pair } from "@thi.ng/api"; +import { Fn3, ICompare, Pair } from "@thi.ng/api"; import { compare } from "@thi.ng/compare"; import { IReducible, map, ReductionFn } from "@thi.ng/transducers"; import { IEquivSet, SortedSetOpts } from "./api"; @@ -50,6 +50,10 @@ export class SortedSet extends Set return SortedSet; } + get [Symbol.toStringTag]() { + return "SortedSet"; + } + get size() { return __private.get(this).size; } @@ -66,8 +70,8 @@ export class SortedSet extends Set } compare(o: Set) { - const n = this.size, - m = o.size; + const n = this.size; + const m = o.size; if (n < m) return -1; if (n > m) return 1; const i = this.entries(); @@ -104,16 +108,16 @@ export class SortedSet extends Set return __private.get(this).$reduce((_acc, x) => rfn(_acc, x[0]), acc); } - entries(): IterableIterator> { - return __private.get(this).entries(); + entries(key?: T, max = false): IterableIterator> { + return __private.get(this).entries(key, max); } - keys(): IterableIterator { - return __private.get(this).keys(); + keys(key?: T, max = false): IterableIterator { + return __private.get(this).keys(key, max); } - values(): IterableIterator { - return __private.get(this).values(); + values(key?: T, max = false): IterableIterator { + return __private.get(this).values(key, max); } add(value: T) { @@ -148,7 +152,10 @@ export class SortedSet extends Set return this; } - forEach(fn: (val: T, val2: T, set: Set) => void, thisArg?: any): void { + forEach( + fn: Fn3, Readonly, Set, void>, + thisArg?: any + ): void { for (let p of this) { fn.call(thisArg, p[0], p[0], this); } diff --git a/packages/associative/src/union.ts b/packages/associative/src/union.ts index 67751a5bf4..8cc548c1ba 100644 --- a/packages/associative/src/union.ts +++ b/packages/associative/src/union.ts @@ -1,15 +1,15 @@ +import { into } from "./into"; import { copy } from "./utils"; -export const union = (a: Set, b: Set): Set => { - if (a === b) { - return a; - } - if (b.size > a.size) { - return union(b, a); - } - const res = copy(a, Set); - for (let i of b) { - res.add(i); - } - return res; +/** + * Computes union of sets `a` and `b` and writes results to new set or + * optionally given set `out` (assumed to be empty for correct results). + * + * @param a + * @param b + * @param out + */ +export const union = (a: Set, b: Set, out?: Set): Set => { + out = out ? into(out, a) : copy(a, Set); + return a === b ? out : into(out, b); }; diff --git a/packages/associative/src/utils.ts b/packages/associative/src/utils.ts index c2f937ea9d..981f0cda53 100644 --- a/packages/associative/src/utils.ts +++ b/packages/associative/src/utils.ts @@ -10,12 +10,12 @@ export const copy = (x, ctor) => ? x.copy() : new (x[Symbol.species] || ctor)(x); -export const first = (x: Iterable) => x[Symbol.iterator]().next().value; +export const first = (x: Iterable) => x[Symbol.iterator]().next().value; export const objValues = (src: any) => { const vals = []; for (let k in src) { - vals.push(src[k]); + src.hasOwnProperty(k) && vals.push(src[k]); } return vals; }; diff --git a/packages/associative/test/difference.ts b/packages/associative/test/difference.ts index 8d92167766..ef81b1662d 100644 --- a/packages/associative/test/difference.ts +++ b/packages/associative/test/difference.ts @@ -1,10 +1,8 @@ import * as assert from "assert"; - import { ArraySet } from "../src/array-set"; import { difference } from "../src/difference"; describe("difference", () => { - it("native (numbers)", () => { const a = new Set([1, 2, 3, 4]); const b = new Set([3, 4, 5]); @@ -36,4 +34,16 @@ describe("difference", () => { assert.notStrictEqual(d, a); assert.notStrictEqual(d, b); }); + + it("w/ out", () => { + assert.deepEqual( + difference(new Set([1, 2, 3]), new Set([2, 4]), new Set([5])), + new Set([1, 3, 5]) + ); + }); + + it("same", () => { + const a = new Set([1]); + assert.deepEqual(difference(a, a), new Set()); + }); }); diff --git a/packages/associative/test/intersection.ts b/packages/associative/test/intersection.ts index 45ce17114e..880647ccf3 100644 --- a/packages/associative/test/intersection.ts +++ b/packages/associative/test/intersection.ts @@ -1,10 +1,8 @@ import * as assert from "assert"; - import { ArraySet } from "../src/array-set"; import { intersection } from "../src/intersection"; describe("intersection", () => { - it("native (numbers)", () => { const a = new Set([1, 2, 3, 4]); const b = new Set([3, 4, 5, 6]); @@ -32,4 +30,11 @@ describe("intersection", () => { const i = intersection(a, b); assert.deepEqual(i, new ArraySet([{ a: 3 }, { a: 4 }])); }); + + it("w/ out", () => { + assert.deepEqual( + intersection(new Set([1, 2, 3]), new Set([2, 4]), new Set([5])), + new Set([2, 5]) + ); + }); }); diff --git a/packages/associative/test/sorted-map.ts b/packages/associative/test/sorted-map.ts index 9b94d3b9dd..67d48733d6 100644 --- a/packages/associative/test/sorted-map.ts +++ b/packages/associative/test/sorted-map.ts @@ -1,16 +1,16 @@ +import { shuffle } from "@thi.ng/arrays"; +import { equiv } from "@thi.ng/equiv"; +import { range, repeat, zip } from "@thi.ng/transducers"; import * as assert from "assert"; - import { SortedMap } from "../src/sorted-map"; describe("SortedMap", () => { - let m: SortedMap; beforeEach(() => { m = SortedMap.fromObject({ a: 1, b: 2, c: 3 }); }); - it("size", () => { assert.equal(m.size, 3); m.set("a", 10); @@ -23,6 +23,28 @@ describe("SortedMap", () => { assert.equal(m.size, 3); }); + it("clear", () => { + m.clear(); + assert.equal(m.size, 0); + assert.deepEqual([...m.entries()], []); + }); + + it("empty", () => { + const m2 = m.empty(); + assert.equal(m.size, 3); + assert.equal(m2.size, 0); + assert.deepEqual([...m2.entries()], []); + }); + + it("copy", () => { + assert.deepEqual(m.copy(), m); + }); + + it("equiv", () => { + assert.ok(equiv(m.copy(), m)); + assert.ok(!equiv(m, new SortedMap())); + }); + it("has", () => { assert(m.has("a")); assert(m.has("b")); @@ -32,6 +54,12 @@ describe("SortedMap", () => { assert(!m.has("@")); }); + it("first", () => { + assert.deepEqual(["a", 1], m.first()); + m.set("A", 10); + assert.deepEqual(["A", 10], m.first()); + }); + it("get", () => { assert.strictEqual(m.get("a"), 1); assert.strictEqual(m.get("b"), 2); @@ -45,57 +73,57 @@ describe("SortedMap", () => { assert.deepEqual([...m], [["a", 1], ["b", 2], ["c", 3]]); }); - it("entries rev", () => { - assert.deepEqual([...m.entries(undefined, true)], [["c", 3], ["b", 2], ["a", 1]]); - }); + // it("entries rev", () => { + // assert.deepEqual([...m.entries(undefined, true)], [["c", 3], ["b", 2], ["a", 1]]); + // }); it("entries a", () => { assert.deepEqual([...m.entries("a")], [["a", 1], ["b", 2], ["c", 3]]); }); - it("entries a rev", () => { - assert.deepEqual([...m.entries("a", true)], [["a", 1]]); - }); + // it("entries a rev", () => { + // assert.deepEqual([...m.entries("a", true)], [["a", 1]]); + // }); it("entries aa", () => { assert.deepEqual([...m.entries("aa")], [["b", 2], ["c", 3]]); }); - it("entries aa rev", () => { - assert.deepEqual([...m.entries("aa", true)], [["a", 1]]); - }); + // it("entries aa rev", () => { + // assert.deepEqual([...m.entries("aa", true)], [["a", 1]]); + // }); it("entries bb", () => { assert.deepEqual([...m.entries("bb")], [["c", 3]]); }); - it("entries bb rev", () => { - assert.deepEqual([...m.entries("bb", true)], [["b", 2], ["a", 1]]); - }); + // it("entries bb rev", () => { + // assert.deepEqual([...m.entries("bb", true)], [["b", 2], ["a", 1]]); + // }); it("entries c", () => { assert.deepEqual([...m.entries("c")], [["c", 3]]); }); - it("entries c rev", () => { - assert.deepEqual([...m.entries("c", true)], [["c", 3], ["b", 2], ["a", 1]]); - }); + // it("entries c rev", () => { + // assert.deepEqual([...m.entries("c", true)], [["c", 3], ["b", 2], ["a", 1]]); + // }); it("entries 0", () => { assert.deepEqual([...m.entries("0")], [["a", 1], ["b", 2], ["c", 3]]); }); - it("entries 0 rev", () => { - assert.deepEqual([...m.entries("0", true)], []); - }); + // it("entries 0 rev", () => { + // assert.deepEqual([...m.entries("0", true)], []); + // }); it("entries d", () => { assert.deepEqual([...m.entries("d")], []); }); - it("entries d rev", () => { - assert.deepEqual([...m.entries("d", true)], [["c", 3], ["b", 2], ["a", 1]]); - }); + // it("entries d rev", () => { + // assert.deepEqual([...m.entries("d", true)], [["c", 3], ["b", 2], ["a", 1]]); + // }); it("keys", () => { assert.deepEqual([...m.keys()], ["a", "b", "c"]); @@ -110,4 +138,23 @@ describe("SortedMap", () => { m.set("d", 0); assert.deepEqual([...m.values()], [1, 0, 2, 3, 0]); }); + + it("comparator", () => { + m = SortedMap.fromObject( + { a: 1, b: 2, c: 3 }, + { + compare: (a: string, b: string) => + a === b ? 0 : a < b ? 1 : -1 + } + ); + assert.deepEqual([["c", 3], ["b", 2], ["a", 1]], [...m.entries()]); + }); + + it("fuzz", () => { + const keys = [...range(32)]; + for (let i = 0; i < 1000; i++) { + m = new SortedMap(zip(shuffle(keys.slice()), repeat(1))); + assert.deepEqual([...m.keys()], keys); + } + }); }); diff --git a/packages/associative/test/union.ts b/packages/associative/test/union.ts index 948393823a..558db36e0a 100644 --- a/packages/associative/test/union.ts +++ b/packages/associative/test/union.ts @@ -1,10 +1,9 @@ import * as assert from "assert"; - import { ArraySet } from "../src/array-set"; import { union } from "../src/union"; -describe("union", () => { +describe("union", () => { it("native (numbers)", () => { const a = new Set([1, 2, 3, 4]); const b = new Set([3, 4, 5, 6]); @@ -36,4 +35,11 @@ describe("union", () => { assert.notStrictEqual(u, a); assert.notStrictEqual(u, b); }); + + it("w/ out", () => { + assert.deepEqual( + union(new Set([1, 2, 3]), new Set([2, 4]), new Set([5])), + new Set([1, 2, 3, 4, 5]) + ); + }); }); diff --git a/packages/atom/CHANGELOG.md b/packages/atom/CHANGELOG.md index 489c3e91d9..fc273052d1 100644 --- a/packages/atom/CHANGELOG.md +++ b/packages/atom/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [2.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/atom@2.0.3...@thi.ng/atom@2.0.4) (2019-03-01) +## [2.0.8](https://github.com/thi-ng/umbrella/compare/@thi.ng/atom@2.0.7...@thi.ng/atom@2.0.8) (2019-03-28) **Note:** Version bump only for package @thi.ng/atom @@ -11,28 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [2.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/atom@2.0.2...@thi.ng/atom@2.0.3) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/atom - - - - - -## [2.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/atom@2.0.1...@thi.ng/atom@2.0.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/atom - - - - - -## [2.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/atom@2.0.0...@thi.ng/atom@2.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/atom - - - # [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/atom@1.5.8...@thi.ng/atom@2.0.0) (2019-01-21) diff --git a/packages/atom/package.json b/packages/atom/package.json index 64d3c87204..2ad1c2278e 100644 --- a/packages/atom/package.json +++ b/packages/atom/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/atom", - "version": "2.0.4", + "version": "2.0.8", "description": "Mutable wrappers for nested immutable values w/ optional undo/redo history", "module": "./index.js", "main": "./lib/index.js", @@ -32,11 +32,11 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/checks": "^2.1.1", - "@thi.ng/equiv": "^1.0.3", - "@thi.ng/errors": "^1.0.3", - "@thi.ng/paths": "^2.0.4" + "@thi.ng/api": "^6.0.0", + "@thi.ng/checks": "^2.1.4", + "@thi.ng/equiv": "^1.0.4", + "@thi.ng/errors": "^1.0.4", + "@thi.ng/paths": "^2.0.7" }, "keywords": [ "derived views", diff --git a/packages/atom/src/cursor.ts b/packages/atom/src/cursor.ts index 8e349bce97..17996f1d15 100644 --- a/packages/atom/src/cursor.ts +++ b/packages/atom/src/cursor.ts @@ -1,4 +1,10 @@ -import { IID, IRelease, Watch } from "@thi.ng/api"; +import { + Fn, + Fn2, + IID, + IRelease, + Watch +} from "@thi.ng/api"; import { isArray, isFunction } from "@thi.ng/checks"; import { illegalArgs, illegalArity } from "@thi.ng/errors"; import { getter, Path, setter } from "@thi.ng/paths"; @@ -43,15 +49,15 @@ export class Cursor implements IAtom, IID, IRelease { parent: IAtom; protected local: Atom; - protected lookup: (s: any) => T; + protected lookup: Fn; protected selfUpdate: boolean; constructor(opts: CursorOpts); constructor(parent: IAtom, path: Path); constructor( parent: IAtom, - lookup: (s: any) => T, - update: (s: any, v: T) => any + lookup: Fn, + update: Fn2 ); constructor(...args: any[]) { let parent, id, lookup, update, validate, opts: CursorOpts; diff --git a/packages/atom/src/history.ts b/packages/atom/src/history.ts index c3718590ed..7d60296d13 100644 --- a/packages/atom/src/history.ts +++ b/packages/atom/src/history.ts @@ -1,6 +1,7 @@ import { Event, INotifyMixin, + Listener, Predicate2, Watch } from "@thi.ng/api"; @@ -256,11 +257,11 @@ export class History implements IHistory { return true; } - addListener(_: string, __: (e: Event) => void, ___?: any): boolean { + addListener(_: string, __: Listener, ___?: any): boolean { return false; } - removeListener(_: string, __: (e: Event) => void, ___?: any): boolean { + removeListener(_: string, __: Listener, ___?: any): boolean { return false; } diff --git a/packages/bench/CHANGELOG.md b/packages/bench/CHANGELOG.md index dd8c86d617..75e4cc9f3b 100644 --- a/packages/bench/CHANGELOG.md +++ b/packages/bench/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/bench@1.0.2...@thi.ng/bench@1.0.3) (2019-03-01) +## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/bench@1.0.3...@thi.ng/bench@1.0.4) (2019-03-28) **Note:** Version bump only for package @thi.ng/bench @@ -11,20 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/bench@1.0.1...@thi.ng/bench@1.0.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/bench - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/bench@1.0.0...@thi.ng/bench@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/bench - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/bench@0.3.1...@thi.ng/bench@1.0.0) (2019-01-21) diff --git a/packages/bench/package.json b/packages/bench/package.json index 870b143752..6e9ea1943e 100644 --- a/packages/bench/package.json +++ b/packages/bench/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/bench", - "version": "1.0.3", + "version": "1.0.4", "description": "Basic benchmarking helpers", "module": "./index.js", "main": "./lib/index.js", diff --git a/packages/bencode/CHANGELOG.md b/packages/bencode/CHANGELOG.md index 4b46137578..85752c3993 100644 --- a/packages/bencode/CHANGELOG.md +++ b/packages/bencode/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.2.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/bencode@0.2.2...@thi.ng/bencode@0.2.3) (2019-03-01) +## [0.2.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/bencode@0.2.10...@thi.ng/bencode@0.2.11) (2019-03-28) **Note:** Version bump only for package @thi.ng/bencode @@ -11,12 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.2.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/bencode@0.2.1...@thi.ng/bencode@0.2.2) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/bencode - - - ## [0.2.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/bencode@0.2.0...@thi.ng/bencode@0.2.1) (2019-02-20) @@ -28,8 +22,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - - # [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/bencode@0.1.1...@thi.ng/bencode@0.2.0) (2019-02-15) @@ -39,16 +31,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - - -## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/bencode@0.1.0...@thi.ng/bencode@0.1.1) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/bencode - - - - - # 0.1.0 (2019-02-05) diff --git a/packages/bencode/package.json b/packages/bencode/package.json index fee74e37ca..30cbfda749 100644 --- a/packages/bencode/package.json +++ b/packages/bencode/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/bencode", - "version": "0.2.3", + "version": "0.2.11", "description": "Bencode binary encoder / decoder with optional UTF8 encoding", "module": "./index.js", "main": "./lib/index.js", @@ -32,13 +32,13 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/arrays": "^0.1.1", - "@thi.ng/checks": "^2.1.1", - "@thi.ng/defmulti": "^1.0.3", - "@thi.ng/errors": "^1.0.3", - "@thi.ng/transducers": "^5.1.1", - "@thi.ng/transducers-binary": "^0.2.2" + "@thi.ng/api": "^6.0.0", + "@thi.ng/arrays": "^0.1.5", + "@thi.ng/checks": "^2.1.4", + "@thi.ng/defmulti": "^1.0.5", + "@thi.ng/errors": "^1.0.4", + "@thi.ng/transducers": "^5.3.1", + "@thi.ng/transducers-binary": "^0.3.6" }, "keywords": [ "bencode", diff --git a/packages/binary/CHANGELOG.md b/packages/binary/CHANGELOG.md index 303608de73..0114bffa06 100644 --- a/packages/binary/CHANGELOG.md +++ b/packages/binary/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/binary@1.0.2...@thi.ng/binary@1.0.3) (2019-03-01) +## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/binary@1.0.3...@thi.ng/binary@1.0.4) (2019-03-28) **Note:** Version bump only for package @thi.ng/binary @@ -11,20 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/binary@1.0.1...@thi.ng/binary@1.0.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/binary - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/binary@1.0.0...@thi.ng/binary@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/binary - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/binary@0.1.2...@thi.ng/binary@1.0.0) (2019-01-21) diff --git a/packages/binary/package.json b/packages/binary/package.json index 088f0b7492..1a7ffb1c80 100644 --- a/packages/binary/package.json +++ b/packages/binary/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/binary", - "version": "1.0.3", + "version": "1.0.4", "description": "Assorted binary / bitwise operations, conversions, utilities.", "module": "./index.js", "main": "./lib/index.js", diff --git a/packages/bitfield/CHANGELOG.md b/packages/bitfield/CHANGELOG.md index 550c4b51d5..e2cc353649 100644 --- a/packages/bitfield/CHANGELOG.md +++ b/packages/bitfield/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitfield@0.1.0...@thi.ng/bitfield@0.1.1) (2019-03-01) +## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitfield@0.1.2...@thi.ng/bitfield@0.1.3) (2019-03-28) **Note:** Version bump only for package @thi.ng/bitfield @@ -11,6 +11,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline + + # 0.1.0 (2019-02-17) diff --git a/packages/bitfield/package.json b/packages/bitfield/package.json index 6da98046a2..a6ea95e6ba 100644 --- a/packages/bitfield/package.json +++ b/packages/bitfield/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/bitfield", - "version": "0.1.1", + "version": "0.1.3", "description": "1D / 2D bit field implementations", "module": "./index.js", "main": "./lib/index.js", @@ -32,9 +32,9 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/binary": "^1.0.3", - "@thi.ng/strings": "^1.0.4" + "@thi.ng/api": "^6.0.0", + "@thi.ng/binary": "^1.0.4", + "@thi.ng/strings": "^1.0.6" }, "keywords": [ "1D", diff --git a/packages/bitstream/CHANGELOG.md b/packages/bitstream/CHANGELOG.md index 03907888d3..0c4004212f 100644 --- a/packages/bitstream/CHANGELOG.md +++ b/packages/bitstream/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitstream@1.0.2...@thi.ng/bitstream@1.0.3) (2019-03-01) +## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitstream@1.0.3...@thi.ng/bitstream@1.0.4) (2019-03-28) **Note:** Version bump only for package @thi.ng/bitstream @@ -11,20 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitstream@1.0.1...@thi.ng/bitstream@1.0.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/bitstream - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitstream@1.0.0...@thi.ng/bitstream@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/bitstream - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitstream@0.4.21...@thi.ng/bitstream@1.0.0) (2019-01-21) diff --git a/packages/bitstream/package.json b/packages/bitstream/package.json index effd92f988..38568d4a55 100644 --- a/packages/bitstream/package.json +++ b/packages/bitstream/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/bitstream", - "version": "1.0.3", + "version": "1.0.4", "description": "ES6 iterator based read/write bit streams & support for variable word widths", "module": "./index.js", "main": "./lib/index.js", @@ -24,7 +24,7 @@ "pub": "yarn build && yarn publish --access public" }, "dependencies": { - "@thi.ng/errors": "^1.0.3" + "@thi.ng/errors": "^1.0.4" }, "devDependencies": { "@types/mocha": "^5.2.5", diff --git a/packages/cache/CHANGELOG.md b/packages/cache/CHANGELOG.md index de6ecdee42..09af5138fa 100644 --- a/packages/cache/CHANGELOG.md +++ b/packages/cache/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.0.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/cache@1.0.6...@thi.ng/cache@1.0.7) (2019-03-01) +## [1.0.13](https://github.com/thi-ng/umbrella/compare/@thi.ng/cache@1.0.12...@thi.ng/cache@1.0.13) (2019-03-28) **Note:** Version bump only for package @thi.ng/cache @@ -11,52 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.0.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/cache@1.0.5...@thi.ng/cache@1.0.6) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/cache - - - - - -## [1.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/cache@1.0.4...@thi.ng/cache@1.0.5) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/cache - - - - - -## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/cache@1.0.3...@thi.ng/cache@1.0.4) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/cache - - - - - -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/cache@1.0.2...@thi.ng/cache@1.0.3) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/cache - - - - - -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/cache@1.0.1...@thi.ng/cache@1.0.2) (2019-01-31) - -**Note:** Version bump only for package @thi.ng/cache - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/cache@1.0.0...@thi.ng/cache@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/cache - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/cache@0.2.40...@thi.ng/cache@1.0.0) (2019-01-21) diff --git a/packages/cache/package.json b/packages/cache/package.json index 9235099af1..cd77fc6170 100644 --- a/packages/cache/package.json +++ b/packages/cache/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/cache", - "version": "1.0.7", + "version": "1.0.13", "description": "In-memory cache implementations with ES6 Map-like API and different eviction strategies", "module": "./index.js", "main": "./lib/index.js", @@ -32,9 +32,9 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/dcons": "^2.0.7", - "@thi.ng/transducers": "^5.1.1" + "@thi.ng/api": "^6.0.0", + "@thi.ng/dcons": "^2.0.13", + "@thi.ng/transducers": "^5.3.1" }, "keywords": [ "cache", diff --git a/packages/cache/src/api.ts b/packages/cache/src/api.ts index 0fb31166a9..c353d8a788 100644 --- a/packages/cache/src/api.ts +++ b/packages/cache/src/api.ts @@ -1,4 +1,7 @@ import { + Fn, + Fn0, + Fn2, ICopy, IEmpty, ILength, @@ -16,7 +19,7 @@ export interface ICache has(key: K): boolean; get(key: K, notFound?: V): V; set(key: K, val: V): V; - getSet(key: K, fn: () => Promise): Promise; + getSet(key: K, fn: Fn0>): Promise; delete(key: K): boolean; entries(): IterableIterator]>>; @@ -25,10 +28,10 @@ export interface ICache } export interface CacheOpts { - ksize: (k: K) => number; - vsize: (v: V) => number; - release: (k: K, v: V) => void; - map: () => Map; + ksize: Fn; + vsize: Fn; + release: Fn2; + map: Fn0>; maxlen: number; maxsize: number; } diff --git a/packages/cache/src/lru.ts b/packages/cache/src/lru.ts index 1e945c7968..2dbfe5adde 100644 --- a/packages/cache/src/lru.ts +++ b/packages/cache/src/lru.ts @@ -1,3 +1,4 @@ +import { Fn0 } from "@thi.ng/api"; import { ConsCell, DCons } from "@thi.ng/dcons"; import { map } from "@thi.ng/transducers"; import { CacheEntry, CacheOpts, ICache } from "./api"; @@ -124,7 +125,7 @@ export class LRUCache implements ICache { return this; } - getSet(key: K, retrieve: () => Promise): Promise { + getSet(key: K, retrieve: Fn0>): Promise { const e = this.map.get(key); if (e) { return Promise.resolve(this.resetEntry(e)); diff --git a/packages/cache/src/tlru.ts b/packages/cache/src/tlru.ts index 0f67b522e0..c13b0c0466 100644 --- a/packages/cache/src/tlru.ts +++ b/packages/cache/src/tlru.ts @@ -1,3 +1,4 @@ +import { Fn0 } from "@thi.ng/api"; import { ConsCell, DCons } from "@thi.ng/dcons"; import { CacheEntry, CacheOpts } from "./api"; import { LRUCache } from "./lru"; @@ -76,11 +77,7 @@ export class TLRUCache extends LRUCache { return value; } - getSet( - key: K, - retrieve: () => Promise, - ttl = this.opts.ttl - ): Promise { + getSet(key: K, retrieve: Fn0>, ttl = this.opts.ttl): Promise { const e = this.get(key); if (e) { return Promise.resolve(e); diff --git a/packages/checks/AUTHORS.md b/packages/checks/AUTHORS.md new file mode 100644 index 0000000000..63da9e3bda --- /dev/null +++ b/packages/checks/AUTHORS.md @@ -0,0 +1,8 @@ +## Maintainer + +- Karsten Schmidt (@postspectacular) + +## Contributors + +- Gavin Cannizzaro (@gavinpc-mindgrub) +- Jay Zawrotny (@eccentric-j) diff --git a/packages/checks/CHANGELOG.md b/packages/checks/CHANGELOG.md index 99f95d33f4..49e562ed91 100644 --- a/packages/checks/CHANGELOG.md +++ b/packages/checks/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [2.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/checks@2.1.0...@thi.ng/checks@2.1.1) (2019-03-01) +## [2.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/checks@2.1.3...@thi.ng/checks@2.1.4) (2019-03-28) **Note:** Version bump only for package @thi.ng/checks @@ -11,30 +11,23 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -# [2.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/checks@2.0.2...@thi.ng/checks@2.1.0) (2019-02-10) - - -### Features - -* **checks:** add isPrimitive() ([190701e](https://github.com/thi-ng/umbrella/commit/190701e)) - - +## [2.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/checks@2.1.1...@thi.ng/checks@2.1.2) (2019-03-12) -## [2.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/checks@2.0.1...@thi.ng/checks@2.0.2) (2019-02-05) -**Note:** Version bump only for package @thi.ng/checks +### Bug Fixes +* **checks:** fix [#77](https://github.com/thi-ng/umbrella/issues/77), update & minor optimization isPlainObject() ([47ac88a](https://github.com/thi-ng/umbrella/commit/47ac88a)) +# [2.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/checks@2.0.2...@thi.ng/checks@2.1.0) (2019-02-10) -## [2.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/checks@2.0.0...@thi.ng/checks@2.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/checks +### Features +* **checks:** add isPrimitive() ([190701e](https://github.com/thi-ng/umbrella/commit/190701e)) diff --git a/packages/checks/package.json b/packages/checks/package.json index 36e5356c00..edde0d3db5 100644 --- a/packages/checks/package.json +++ b/packages/checks/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/checks", - "version": "2.1.1", + "version": "2.1.4", "description": "Single-function sub-modules for type, feature & value checks", "module": "./index.js", "main": "./lib/index.js", diff --git a/packages/checks/src/is-plain-object.ts b/packages/checks/src/is-plain-object.ts index bc6025367c..c4cbc08863 100644 --- a/packages/checks/src/is-plain-object.ts +++ b/packages/checks/src/is-plain-object.ts @@ -1,4 +1,4 @@ -const OBJP = Object.getPrototypeOf({}); +const OBJP = Object.getPrototypeOf; /** * Similar to `isObject()`, but also checks if prototype is that of @@ -7,9 +7,10 @@ const OBJP = Object.getPrototypeOf({}); * @param x */ export const isPlainObject = (x: any): x is object => { - let proto; + let p; return ( - Object.prototype.toString.call(x) === "[object Object]" && - ((proto = Object.getPrototypeOf(x)), proto === null || proto === OBJP) + x != null && + typeof x === "object" && + ((p = OBJP(x)) === null || OBJP(p) === null) ); }; diff --git a/packages/checks/test/index.ts b/packages/checks/test/index.ts index c70a02cc61..7e6b24f135 100644 --- a/packages/checks/test/index.ts +++ b/packages/checks/test/index.ts @@ -1,5 +1,5 @@ import * as assert from "assert"; - +import * as vm from "vm"; import { existsAndNotNull } from "../src/exists-not-null"; import { implementsFunction } from "../src/implements-function"; import { isArray } from "../src/is-array"; @@ -12,8 +12,7 @@ import { isSymbol } from "../src/is-symbol"; import { isTransferable } from "../src/is-transferable"; import { isTypedArray } from "../src/is-typedarray"; -describe("checks", function () { - +describe("checks", function() { it("existsAndNotNull", () => { assert.ok(existsAndNotNull([]), "empty array"); assert.ok(existsAndNotNull(new Uint8Array(1)), "typedarray"); @@ -66,7 +65,7 @@ describe("checks", function () { }); it("isObject", () => { - function Foo() { }; + function Foo() {} assert.ok(isObject([]), "empty array"); assert.ok(isObject(new Uint8Array(1)), "typedarray"); assert.ok(isObject({}), "obj"); @@ -79,10 +78,16 @@ describe("checks", function () { }); it("isPlainObject", () => { - function Foo() { }; + const ctxClass = vm.runInNewContext("class A {}; new A();"); + const ctxObj = vm.runInNewContext("({})"); + + function Foo() {} + assert.ok(isPlainObject({}), "obj"); + assert.ok(isPlainObject(Object.create(null)), "obj"); assert.ok(isPlainObject(new Object()), "obj ctor"); assert.ok(!isPlainObject(Foo), "fn"); + assert.ok(!isPlainObject((function*() {})()), "generator"); assert.ok(!isPlainObject(new Foo()), "class"); assert.ok(!isPlainObject([]), "empty array"); assert.ok(!isPlainObject(new Uint8Array(1)), "typedarray"); @@ -90,6 +95,8 @@ describe("checks", function () { assert.ok(!isPlainObject(0), "zero"); assert.ok(!isPlainObject(null), "null"); assert.ok(!isPlainObject(undefined), "null"); + assert.ok(isPlainObject(ctxObj), "vm ctx obj"); + assert.ok(!isPlainObject(ctxClass), "vm ctx class"); }); it("isString", () => { @@ -142,5 +149,4 @@ describe("checks", function () { assert.ok(!isTransferable(null), "null"); assert.ok(!isTransferable(undefined), "undefined"); }); - }); diff --git a/packages/color/CHANGELOG.md b/packages/color/CHANGELOG.md index 35f95f1ea8..2d80b47076 100644 --- a/packages/color/CHANGELOG.md +++ b/packages/color/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.1.8](https://github.com/thi-ng/umbrella/compare/@thi.ng/color@0.1.7...@thi.ng/color@0.1.8) (2019-03-01) +## [0.1.15](https://github.com/thi-ng/umbrella/compare/@thi.ng/color@0.1.14...@thi.ng/color@0.1.15) (2019-03-28) **Note:** Version bump only for package @thi.ng/color @@ -11,62 +11,23 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.1.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/color@0.1.6...@thi.ng/color@0.1.7) (2019-02-28) - - -### Bug Fixes - -* **color:** update ColorMode & Hue const enum handling ([bb71b7c](https://github.com/thi-ng/umbrella/commit/bb71b7c)) - - - - - -## [0.1.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/color@0.1.5...@thi.ng/color@0.1.6) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/color - - - - - -## [0.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/color@0.1.4...@thi.ng/color@0.1.5) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/color - - +## [0.1.10](https://github.com/thi-ng/umbrella/compare/@thi.ng/color@0.1.9...@thi.ng/color@0.1.10) (2019-03-04) -## [0.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/color@0.1.3...@thi.ng/color@0.1.4) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/color - - - - - -## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/color@0.1.2...@thi.ng/color@0.1.3) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/color - - - - - -## [0.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/color@0.1.1...@thi.ng/color@0.1.2) (2019-01-31) - -**Note:** Version bump only for package @thi.ng/color +### Bug Fixes +* **color:** add/update luminanceRGB/luminanceInt, add to re-exports ([566cf02](https://github.com/thi-ng/umbrella/commit/566cf02)) -## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/color@0.1.0...@thi.ng/color@0.1.1) (2019-01-21) +## [0.1.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/color@0.1.6...@thi.ng/color@0.1.7) (2019-02-28) -**Note:** Version bump only for package @thi.ng/color +### Bug Fixes +* **color:** update ColorMode & Hue const enum handling ([bb71b7c](https://github.com/thi-ng/umbrella/commit/bb71b7c)) diff --git a/packages/color/package.json b/packages/color/package.json index 160f29acaa..a82467d5bb 100644 --- a/packages/color/package.json +++ b/packages/color/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/color", - "version": "0.1.8", + "version": "0.1.15", "description": "Raw, array-based, color ops, conversions, opt. type wrappers, multi-color gradients", "module": "./index.js", "main": "./lib/index.js", @@ -32,14 +32,14 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/compose": "^1.1.2", - "@thi.ng/defmulti": "^1.0.3", - "@thi.ng/errors": "^1.0.3", - "@thi.ng/math": "^1.1.1", - "@thi.ng/strings": "^1.0.4", - "@thi.ng/transducers": "^5.1.1", - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/api": "^6.0.0", + "@thi.ng/compose": "^1.2.1", + "@thi.ng/defmulti": "^1.0.5", + "@thi.ng/errors": "^1.0.4", + "@thi.ng/math": "^1.2.1", + "@thi.ng/strings": "^1.0.6", + "@thi.ng/transducers": "^5.3.1", + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "alpha", diff --git a/packages/color/src/index.ts b/packages/color/src/index.ts index 413f74e6bb..1749075203 100644 --- a/packages/color/src/index.ts +++ b/packages/color/src/index.ts @@ -45,6 +45,7 @@ export * from "./closest-hue"; export * from "./cosine-gradients"; export * from "./invert"; export * from "./luminance"; +export * from "./luminance-rgb"; export * from "./mix"; export * from "./porter-duff"; export * from "./premultiply"; diff --git a/packages/color/src/luminance-rgb.ts b/packages/color/src/luminance-rgb.ts index 993dd44b83..fb5f0f5232 100644 --- a/packages/color/src/luminance-rgb.ts +++ b/packages/color/src/luminance-rgb.ts @@ -1,5 +1,5 @@ import { dot3 } from "@thi.ng/vectors"; -import { INV8BIT, ReadonlyColor, RGB_LUMINANCE } from "./api"; +import { ReadonlyColor, RGB_LUMINANCE } from "./api"; export const luminanceRGB = (rgb: ReadonlyColor, weights = RGB_LUMINANCE) => dot3(rgb, weights); @@ -7,6 +7,5 @@ export const luminanceRGB = (rgb: ReadonlyColor, weights = RGB_LUMINANCE) => export const luminanceInt = (rgb: number) => (((rgb >>> 16) & 0xff) * 76 + ((rgb >>> 8) & 0xff) * 150 + - (rgb & 0xff) * 29) * - INV8BIT * - INV8BIT; + (rgb & 0xff) * 29) / + 0xfe01; diff --git a/packages/color/src/porter-duff.ts b/packages/color/src/porter-duff.ts index 08f376e230..114d7b6170 100644 --- a/packages/color/src/porter-duff.ts +++ b/packages/color/src/porter-duff.ts @@ -1,3 +1,4 @@ +import { Fn2, Fn3 } from "@thi.ng/api"; import { setC4, setN4 } from "@thi.ng/vectors"; import { Color, ReadonlyColor } from "./api"; import { postmultiply, premultiply } from "./premultiply"; @@ -24,7 +25,7 @@ import { postmultiply, premultiply } from "./premultiply"; * @param z factor of "dest" region */ export const porterDuff = ( - f: (s: number, d: number) => number, + f: Fn2, x: 0 | 1, y: 0 | 1, z: 0 | 1 @@ -36,9 +37,9 @@ export const porterDuff = ( : (s: number, d: number, sda: number, sy: number) => f(s, d) * sda + s * sy : z - ? (s: number, d: number, sda: number, _, sz: number) => - f(s, d) * sda + d * sz - : (s: number, d: number, sda: number) => f(s, d) * sda; + ? (s: number, d: number, sda: number, _, sz: number) => + f(s, d) * sda + d * sz + : (s: number, d: number, sda: number) => f(s, d) * sda; return (out: Color, src: ReadonlyColor, dest: ReadonlyColor) => { const sa = src[3]; const da = dest[3]; @@ -68,7 +69,7 @@ export const porterDuffP = ( out: Color, src: ReadonlyColor, dest: ReadonlyColor, - mode: (out: Color, src: ReadonlyColor, dest: ReadonlyColor) => Color + mode: Fn3 ) => postmultiply( null, diff --git a/packages/compare/CHANGELOG.md b/packages/compare/CHANGELOG.md index bd35147b68..f9ee9a0522 100644 --- a/packages/compare/CHANGELOG.md +++ b/packages/compare/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/compare@1.0.2...@thi.ng/compare@1.0.3) (2019-03-01) +## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/compare@1.0.3...@thi.ng/compare@1.0.4) (2019-03-28) **Note:** Version bump only for package @thi.ng/compare @@ -11,20 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/compare@1.0.1...@thi.ng/compare@1.0.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/compare - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/compare@1.0.0...@thi.ng/compare@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/compare - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/compare@0.1.12...@thi.ng/compare@1.0.0) (2019-01-21) diff --git a/packages/compare/package.json b/packages/compare/package.json index 25353042fb..cc60490930 100644 --- a/packages/compare/package.json +++ b/packages/compare/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/compare", - "version": "1.0.3", + "version": "1.0.4", "description": "Comparator with optional delegation for types implementing @thi.ng/api/ICompare interface", "module": "./index.js", "main": "./lib/index.js", diff --git a/packages/compose/CHANGELOG.md b/packages/compose/CHANGELOG.md index a665b5adf1..9aa5776746 100644 --- a/packages/compose/CHANGELOG.md +++ b/packages/compose/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/compose@1.1.1...@thi.ng/compose@1.1.2) (2019-03-01) +## [1.2.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/compose@1.2.0...@thi.ng/compose@1.2.1) (2019-03-28) **Note:** Version bump only for package @thi.ng/compose @@ -11,11 +11,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/compose@1.1.0...@thi.ng/compose@1.1.1) (2019-02-26) +# [1.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/compose@1.1.2...@thi.ng/compose@1.2.0) (2019-03-10) -**Note:** Version bump only for package @thi.ng/compose +### Features +* **compose:** add complement() ([5a5a2d1](https://github.com/thi-ng/umbrella/commit/5a5a2d1)) +* **compose:** add trampoline() ([9e4c171](https://github.com/thi-ng/umbrella/commit/9e4c171)) @@ -33,24 +35,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - - -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/compose@1.0.1...@thi.ng/compose@1.0.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/compose - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/compose@1.0.0...@thi.ng/compose@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/compose - - - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/compose@0.3.0...@thi.ng/compose@1.0.0) (2019-01-21) diff --git a/packages/compose/README.md b/packages/compose/README.md index f611b4f75c..a92e174ba6 100644 --- a/packages/compose/README.md +++ b/packages/compose/README.md @@ -9,12 +9,12 @@ This project is part of the -- [About](#about) -- [Installation](#installation) -- [Dependencies](#dependencies) -- [Usage examples](#usage-examples) -- [Authors](#authors) -- [License](#license) +- [About](#about) +- [Installation](#installation) +- [Dependencies](#dependencies) +- [Usage examples](#usage-examples) +- [Authors](#authors) +- [License](#license) @@ -22,12 +22,13 @@ This project is part of the Functional composition helpers: -- [comp()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/comp.ts) -- [compL()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/comp.ts#L52) -- [juxt()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/juxt.ts) -- [partial()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/partial.ts) -- [threadFirst()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/thread-first.ts) -- [threadLast()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/thread-last.ts) +- [comp()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/comp.ts) +- [compL()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/comp.ts#L52) +- [juxt()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/juxt.ts) +- [partial()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/partial.ts) +- [threadFirst()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/thread-first.ts) +- [threadLast()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/thread-last.ts) +- [trampoline()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/trampoline.ts) ## Installation @@ -37,8 +38,8 @@ yarn add @thi.ng/compose ## Dependencies -- [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/master/packages/api) -- [@thi.ng/errors](https://github.com/thi-ng/umbrella/tree/master/packages/errors) +- [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/master/packages/api) +- [@thi.ng/errors](https://github.com/thi-ng/umbrella/tree/master/packages/errors) ## Usage examples @@ -48,7 +49,7 @@ import { comp, compL, juxt } from "@thi.ng/compose"; ## Authors -- Karsten Schmidt +- Karsten Schmidt ## License diff --git a/packages/compose/package.json b/packages/compose/package.json index e069567b0b..787e4ef010 100644 --- a/packages/compose/package.json +++ b/packages/compose/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/compose", - "version": "1.1.2", + "version": "1.2.1", "description": "Arity-optimized functional composition helpers", "module": "./index.js", "main": "./lib/index.js", @@ -32,8 +32,8 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/errors": "^1.0.3" + "@thi.ng/api": "^6.0.0", + "@thi.ng/errors": "^1.0.4" }, "keywords": [ "composition", diff --git a/packages/compose/src/complement.ts b/packages/compose/src/complement.ts new file mode 100644 index 0000000000..fc46e935da --- /dev/null +++ b/packages/compose/src/complement.ts @@ -0,0 +1,37 @@ +import { + Fn, + Fn0, + Fn2, + Fn3, + Fn4, + Fn5, + Fn6, + Fn7, + Fn8, + FnAny +} from "@thi.ng/api"; + +export function complement(f: Fn0): Fn0; +export function complement(f: Fn): Fn; +export function complement(f: Fn2): Fn2; +export function complement( + f: Fn3 +): Fn3; +export function complement( + f: Fn4 +): Fn4; +export function complement( + f: Fn5 +): Fn5; +export function complement( + f: Fn6 +): Fn6; +export function complement( + f: Fn7 +): Fn7; +export function complement( + f: Fn8 +): Fn8; +export function complement(f: FnAny) { + return (...xs) => !f(...xs); +} diff --git a/packages/compose/src/delay.ts b/packages/compose/src/delay.ts index a1b470ef1f..2483936400 100644 --- a/packages/compose/src/delay.ts +++ b/packages/compose/src/delay.ts @@ -1,13 +1,13 @@ -import { IDeref } from "@thi.ng/api"; +import { Fn0, IDeref } from "@thi.ng/api"; -export const delay = (body: () => T) => new Delay(body); +export const delay = (body: Fn0) => new Delay(body); export class Delay implements IDeref { value: T; - protected body: () => T; + protected body: Fn0; protected realized: boolean; - constructor(body: () => T) { + constructor(body: Fn0) { this.body = body; this.realized = false; } diff --git a/packages/compose/src/index.ts b/packages/compose/src/index.ts index f9c76d4c74..330397535b 100644 --- a/packages/compose/src/index.ts +++ b/packages/compose/src/index.ts @@ -1,4 +1,5 @@ export * from "./comp"; +export * from "./complement"; export * from "./constantly"; export * from "./delay"; export * from "./delayed"; @@ -7,3 +8,4 @@ export * from "./juxt"; export * from "./partial"; export * from "./thread-first"; export * from "./thread-last"; +export * from "./trampoline"; diff --git a/packages/compose/src/partial.ts b/packages/compose/src/partial.ts index 615cc84739..49f1eb2ecc 100644 --- a/packages/compose/src/partial.ts +++ b/packages/compose/src/partial.ts @@ -1,46 +1,50 @@ +import { + FnAny, + FnO, + FnO2, + FnO3, + FnO4, + FnO5, + FnO6, + FnO7, + FnO8 +} from "@thi.ng/api"; import { illegalArgs } from "@thi.ng/errors"; -export function partial( - fn: (a: A, ...args: any[]) => T, - a: A -): (...args: any[]) => T; -export function partial( - fn: (a: A, b: B, ...args: any[]) => T, - a: A, - b: B -): (...args: any[]) => T; +export function partial(fn: FnO, a: A): FnAny; +export function partial(fn: FnO2, a: A, b: B): FnAny; export function partial( - fn: (a: A, b: B, c: C, ...args: any[]) => T, + fn: FnO3, a: A, b: B, c: C -): (...args: any[]) => T; +): FnAny; export function partial( - fn: (a: A, b: B, c: C, d: D, ...args: any[]) => T, + fn: FnO4, a: A, b: B, c: C, d: D -): (...args: any[]) => T; +): FnAny; export function partial( - fn: (a: A, b: B, c: C, d: D, e: E, ...args: any[]) => T, + fn: FnO5, a: A, b: B, c: C, d: D, e: E -): (...args: any[]) => T; +): FnAny; export function partial( - fn: (a: A, b: B, c: C, d: D, e: E, f: F, ...args: any[]) => T, + fn: FnO6, a: A, b: B, c: C, d: D, e: E, f: F -): (...args: any[]) => T; +): FnAny; export function partial( - fn: (a: A, b: B, c: C, d: D, e: E, f: F, g: G, ...args: any[]) => T, + fn: FnO7, a: A, b: B, c: C, @@ -48,9 +52,9 @@ export function partial( e: E, f: F, g: G -): (...args: any[]) => T; +): FnAny; export function partial( - fn: (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, ...args: any[]) => T, + fn: FnO8, a: A, b: B, c: C, @@ -59,7 +63,7 @@ export function partial( f: F, g: G, h: H -): (...args: any[]) => T; +): FnAny; export function partial(fn, ...args: any[]) { let [a, b, c, d, e, f, g, h] = args; switch (args.length) { diff --git a/packages/compose/src/trampoline.ts b/packages/compose/src/trampoline.ts new file mode 100644 index 0000000000..2dd86302f0 --- /dev/null +++ b/packages/compose/src/trampoline.ts @@ -0,0 +1,35 @@ +import { Fn0 } from "@thi.ng/api"; + +/** + * Takes a function returning either a no-arg function (thunk) or its + * already realized (non-function) result. Re-executes thunk for as long + * as it returns another function/thunk. Once a non-function result has + * been produced, `trampoline` returns that value itself. If the final + * result should be function, it needs to wrapped (e.g. as a 1-elem + * array). + * + * This function should be used for non-stack consuming recursion. I.e. + * a trampoline is a form of continuation passing style and only ever + * consumes max. 2 extra stack frames, independent from recursion depth. + * + * ``` + * const countdown = (acc, x) => + * x >= 0 ? + * () => (acc.push(x), countdown(acc, x-1)) : + * acc; + * + * trampoline(countdown([], 4)) + * // [ 4, 3, 2, 1, 0 ] + * + * trampoline(countdown([], -1)) + * // [] + * ``` + * + * @param f + */ +export const trampoline = (f: T | Fn0>) => { + while (typeof f === "function") { + f = (f)(); + } + return f; +}; diff --git a/packages/csp/CHANGELOG.md b/packages/csp/CHANGELOG.md index d73465759c..5358e25b19 100644 --- a/packages/csp/CHANGELOG.md +++ b/packages/csp/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.0.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/csp@1.0.6...@thi.ng/csp@1.0.7) (2019-03-01) +## [1.0.13](https://github.com/thi-ng/umbrella/compare/@thi.ng/csp@1.0.12...@thi.ng/csp@1.0.13) (2019-03-28) **Note:** Version bump only for package @thi.ng/csp @@ -11,52 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.0.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/csp@1.0.5...@thi.ng/csp@1.0.6) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/csp - - - - - -## [1.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/csp@1.0.4...@thi.ng/csp@1.0.5) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/csp - - - - - -## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/csp@1.0.3...@thi.ng/csp@1.0.4) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/csp - - - - - -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/csp@1.0.2...@thi.ng/csp@1.0.3) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/csp - - - - - -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/csp@1.0.1...@thi.ng/csp@1.0.2) (2019-01-31) - -**Note:** Version bump only for package @thi.ng/csp - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/csp@1.0.0...@thi.ng/csp@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/csp - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/csp@0.3.79...@thi.ng/csp@1.0.0) (2019-01-21) diff --git a/packages/csp/package.json b/packages/csp/package.json index 6714827be8..8835341305 100644 --- a/packages/csp/package.json +++ b/packages/csp/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/csp", - "version": "1.0.7", + "version": "1.0.13", "description": "ES6 promise based CSP implementation", "module": "./index.js", "main": "./lib/index.js", @@ -36,12 +36,12 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/arrays": "^0.1.1", - "@thi.ng/checks": "^2.1.1", - "@thi.ng/dcons": "^2.0.7", - "@thi.ng/errors": "^1.0.3", - "@thi.ng/transducers": "^5.1.1" + "@thi.ng/api": "^6.0.0", + "@thi.ng/arrays": "^0.1.5", + "@thi.ng/checks": "^2.1.4", + "@thi.ng/dcons": "^2.0.13", + "@thi.ng/errors": "^1.0.4", + "@thi.ng/transducers": "^5.3.1" }, "keywords": [ "async", diff --git a/packages/csp/src/api.ts b/packages/csp/src/api.ts index b6a0101857..5a9533415c 100644 --- a/packages/csp/src/api.ts +++ b/packages/csp/src/api.ts @@ -1,4 +1,9 @@ -import { IID, ILength, IRelease } from "@thi.ng/api"; +import { + Fn, + IID, + ILength, + IRelease +} from "@thi.ng/api"; import { Channel } from "./channel"; export const enum State { @@ -13,8 +18,8 @@ export const enum State { // export const __State = (exports).State; export interface ChannelItem { - value: () => Promise; - resolve: (success: boolean) => void; + value(): Promise; + resolve(success: boolean): void; } export interface IBuffer extends ILength, IRelease { @@ -41,6 +46,6 @@ export interface IReadWriteableChannel extends IReadableChannel, IWriteableChannel {} -export type TopicFn = (x: T) => string; +export type TopicFn = Fn; export type ErrorHandler = (e: Error, chan: Channel, val?: any) => void; diff --git a/packages/csp/src/channel.ts b/packages/csp/src/channel.ts index efb20be895..28bd441d0b 100644 --- a/packages/csp/src/channel.ts +++ b/packages/csp/src/channel.ts @@ -1,4 +1,4 @@ -import { Predicate } from "@thi.ng/api"; +import { Fn, Fn0, Predicate } from "@thi.ng/api"; import { shuffle } from "@thi.ng/arrays"; import { isFunction } from "@thi.ng/checks"; import { DCons } from "@thi.ng/dcons"; @@ -28,7 +28,7 @@ export class Channel implements IReadWriteableChannel { return chan; } - static repeatedly(fn: () => T, delay?: number) { + static repeatedly(fn: Fn0, delay?: number) { const chan = new Channel(delay ? delayed(delay) : null); chan.produce(fn); return chan; @@ -417,7 +417,7 @@ export class Channel implements IReadWriteableChannel { ); } - consume(fn: (x: T) => any = (x: T) => console.log(this.id, ":", x)) { + consume(fn: Fn = (x) => console.log(this.id, ":", x)) { return (async () => { let x; while (((x = null), (x = await this.read())) !== undefined) { @@ -427,7 +427,7 @@ export class Channel implements IReadWriteableChannel { })(); } - produce(fn: () => T, close = true) { + produce(fn: Fn0, close = true) { return (async () => { while (!this.isClosed()) { const val = await fn(); @@ -440,9 +440,7 @@ export class Channel implements IReadWriteableChannel { })(); } - consumeWhileReadable( - fn: (x: T) => any = (x: T) => console.log(this.id, ":", x) - ) { + consumeWhileReadable(fn: Fn = (x) => console.log(this.id, ":", x)) { return (async () => { let x; while (this.isReadable()) { diff --git a/packages/dcons/CHANGELOG.md b/packages/dcons/CHANGELOG.md index 907a7c9a96..22a11b8147 100644 --- a/packages/dcons/CHANGELOG.md +++ b/packages/dcons/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [2.0.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/dcons@2.0.6...@thi.ng/dcons@2.0.7) (2019-03-01) +## [2.0.13](https://github.com/thi-ng/umbrella/compare/@thi.ng/dcons@2.0.12...@thi.ng/dcons@2.0.13) (2019-03-28) **Note:** Version bump only for package @thi.ng/dcons @@ -11,52 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [2.0.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/dcons@2.0.5...@thi.ng/dcons@2.0.6) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/dcons - - - - - -## [2.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/dcons@2.0.4...@thi.ng/dcons@2.0.5) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/dcons - - - - - -## [2.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/dcons@2.0.3...@thi.ng/dcons@2.0.4) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/dcons - - - - - -## [2.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/dcons@2.0.2...@thi.ng/dcons@2.0.3) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/dcons - - - - - -## [2.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/dcons@2.0.1...@thi.ng/dcons@2.0.2) (2019-01-31) - -**Note:** Version bump only for package @thi.ng/dcons - - - - - -## [2.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/dcons@2.0.0...@thi.ng/dcons@2.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/dcons - - - # [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/dcons@1.1.23...@thi.ng/dcons@2.0.0) (2019-01-21) diff --git a/packages/dcons/package.json b/packages/dcons/package.json index a73f83430a..bcd236035c 100644 --- a/packages/dcons/package.json +++ b/packages/dcons/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/dcons", - "version": "2.0.7", + "version": "2.0.13", "description": "Comprehensive doubly linked list structure w/ iterator support", "module": "./index.js", "main": "./lib/index.js", @@ -32,12 +32,12 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/checks": "^2.1.1", - "@thi.ng/compare": "^1.0.3", - "@thi.ng/equiv": "^1.0.3", - "@thi.ng/errors": "^1.0.3", - "@thi.ng/transducers": "^5.1.1" + "@thi.ng/api": "^6.0.0", + "@thi.ng/checks": "^2.1.4", + "@thi.ng/compare": "^1.0.4", + "@thi.ng/equiv": "^1.0.4", + "@thi.ng/errors": "^1.0.4", + "@thi.ng/transducers": "^5.3.1" }, "keywords": [ "datastructure", diff --git a/packages/dcons/src/index.ts b/packages/dcons/src/index.ts index 88504c67fd..0157ac02f6 100644 --- a/packages/dcons/src/index.ts +++ b/packages/dcons/src/index.ts @@ -1,5 +1,6 @@ import { Comparator, + Fn, ICompare, ICopy, IEmpty, @@ -30,7 +31,7 @@ export class DCons ILength, IReducible, IRelease, - IStack> { + IStack> { head: ConsCell; tail: ConsCell; protected _length: number = 0; @@ -437,7 +438,7 @@ export class DCons } } - map(fn: (x: T) => R) { + map(fn: Fn) { const res = new DCons(); let cell = this.head; while (cell) { @@ -457,12 +458,12 @@ export class DCons return res; } - reduce(rfn: (acc: R, x: T) => R, initial: R) { + reduce(rfn: ReductionFn, initial: R) { let acc: R = initial; let cell = this.head; while (cell) { // TODO add early termination support - acc = rfn(acc, cell.value); + acc = rfn(acc, cell.value); cell = cell.next; } return acc; @@ -529,8 +530,8 @@ export class DCons cell.value != null ? cell.value.toString() : cell.value === undefined - ? "undefined" - : "null" + ? "undefined" + : "null" ); cell = cell.next; } diff --git a/packages/defmulti/CHANGELOG.md b/packages/defmulti/CHANGELOG.md index afe6129e30..4752b5c1de 100644 --- a/packages/defmulti/CHANGELOG.md +++ b/packages/defmulti/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/defmulti@1.0.2...@thi.ng/defmulti@1.0.3) (2019-03-01) +## [1.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/defmulti@1.0.4...@thi.ng/defmulti@1.0.5) (2019-03-28) **Note:** Version bump only for package @thi.ng/defmulti @@ -11,20 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/defmulti@1.0.1...@thi.ng/defmulti@1.0.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/defmulti - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/defmulti@1.0.0...@thi.ng/defmulti@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/defmulti - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/defmulti@0.7.0...@thi.ng/defmulti@1.0.0) (2019-01-21) diff --git a/packages/defmulti/package.json b/packages/defmulti/package.json index 56bc011f05..40a8d7e3c0 100644 --- a/packages/defmulti/package.json +++ b/packages/defmulti/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/defmulti", - "version": "1.0.3", + "version": "1.0.5", "description": "Dynamically extensible multiple dispatch via user supplied dispatch function.", "module": "./index.js", "main": "./lib/index.js", @@ -32,8 +32,8 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/errors": "^1.0.3" + "@thi.ng/api": "^6.0.0", + "@thi.ng/errors": "^1.0.4" }, "keywords": [ "ES6", diff --git a/packages/defmulti/src/index.ts b/packages/defmulti/src/index.ts index 3e3802285f..9cabfaa801 100644 --- a/packages/defmulti/src/index.ts +++ b/packages/defmulti/src/index.ts @@ -1,16 +1,27 @@ -import { IObjectOf } from "@thi.ng/api"; -import { illegalArgs, unsupported, illegalArity } from "@thi.ng/errors"; +import { + Fn, + Fn2, + Fn3, + Fn4, + Fn5, + Fn6, + Fn7, + Fn8, + FnAny, + IObjectOf +} from "@thi.ng/api"; +import { illegalArgs, illegalArity, unsupported } from "@thi.ng/errors"; export const DEFAULT: unique symbol = Symbol(); -export type DispatchFn = (...args) => PropertyKey; -export type DispatchFn1 = (a: A) => PropertyKey; +export type DispatchFn = FnAny; +export type DispatchFn1 = Fn; export type DispatchFn1O = (a: A, b?: B) => PropertyKey; -export type DispatchFn2 = (a: A, b: B) => PropertyKey; +export type DispatchFn2 = Fn2; export type DispatchFn2O = (a: A, b: B, c?: C) => PropertyKey; -export type DispatchFn3 = (a: A, b: B, c: C) => PropertyKey; +export type DispatchFn3 = Fn3; export type DispatchFn3O = (a: A, b: B, c: C, d?: D) => PropertyKey; -export type DispatchFn4 = (a: A, b: B, c: C, d: D) => PropertyKey; +export type DispatchFn4 = Fn4; export type DispatchFn4O = ( a: A, b: B, @@ -18,13 +29,7 @@ export type DispatchFn4O = ( d: D, e?: E ) => PropertyKey; -export type DispatchFn5 = ( - a: A, - b: B, - c: C, - d: D, - e: E -) => PropertyKey; +export type DispatchFn5 = Fn5; export type DispatchFn5O = ( a: A, b: B, @@ -33,14 +38,7 @@ export type DispatchFn5O = ( e: E, f?: F ) => PropertyKey; -export type DispatchFn6 = ( - a: A, - b: B, - c: C, - d: D, - e: E, - f: F -) => PropertyKey; +export type DispatchFn6 = Fn6; export type DispatchFn6O = ( a: A, b: B, @@ -50,15 +48,16 @@ export type DispatchFn6O = ( f: F, g?: G ) => PropertyKey; -export type DispatchFn7 = ( - a: A, - b: B, - c: C, - d: D, - e: E, - f: F, - g: G -) => PropertyKey; +export type DispatchFn7 = Fn7< + A, + B, + C, + D, + E, + F, + G, + PropertyKey +>; export type DispatchFn7O = ( a: A, b: B, @@ -69,16 +68,17 @@ export type DispatchFn7O = ( g: G, h?: H ) => PropertyKey; -export type DispatchFn8 = ( - a: A, - b: B, - c: C, - d: D, - e: E, - f: F, - g: G, - h: H -) => PropertyKey; +export type DispatchFn8 = Fn8< + A, + B, + C, + D, + E, + F, + G, + H, + PropertyKey +>; export type DispatchFn8O = ( a: A, b: B, @@ -91,14 +91,14 @@ export type DispatchFn8O = ( i?: I ) => PropertyKey; -export type Implementation = (...args: any[]) => T; -export type Implementation1 = (a: A) => T; +export type Implementation = FnAny; +export type Implementation1 = Fn; export type Implementation1O = (a: A, b?: B) => T; -export type Implementation2 = (a: A, b: B) => T; +export type Implementation2 = Fn2; export type Implementation2O = (a: A, b: B, c?: C) => T; -export type Implementation3 = (a: A, b: B, c: C) => T; +export type Implementation3 = Fn3; export type Implementation3O = (a: A, b: B, c: C, d?: D) => T; -export type Implementation4 = (a: A, b: B, c: C, d: D) => T; +export type Implementation4 = Fn4; export type Implementation4O = ( a: A, b: B, @@ -106,13 +106,7 @@ export type Implementation4O = ( d: D, e?: E ) => T; -export type Implementation5 = ( - a: A, - b: B, - c: C, - d: D, - e: E -) => T; +export type Implementation5 = Fn5; export type Implementation5O = ( a: A, b: B, @@ -121,14 +115,7 @@ export type Implementation5O = ( e: E, f?: F ) => T; -export type Implementation6 = ( - a: A, - b: B, - c: C, - d: D, - e: E, - f: F -) => T; +export type Implementation6 = Fn6; export type Implementation6O = ( a: A, b: B, @@ -138,15 +125,16 @@ export type Implementation6O = ( f: F, g?: G ) => T; -export type Implementation7 = ( - a: A, - b: B, - c: C, - d: D, - e: E, - f: F, - g: G -) => T; +export type Implementation7 = Fn7< + A, + B, + C, + D, + E, + F, + G, + T +>; export type Implementation7O = ( a: A, b: B, @@ -157,16 +145,17 @@ export type Implementation7O = ( g: G, h?: H ) => T; -export type Implementation8 = ( - a: A, - b: B, - c: C, - d: D, - e: E, - f: F, - g: G, - h: H -) => T; +export type Implementation8 = Fn8< + A, + B, + C, + D, + E, + F, + G, + H, + T +>; export type Implementation8O = ( a: A, b: B, diff --git a/packages/dgraph/CHANGELOG.md b/packages/dgraph/CHANGELOG.md index 1d9c222a8d..71fc468074 100644 --- a/packages/dgraph/CHANGELOG.md +++ b/packages/dgraph/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.0.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/dgraph@1.0.6...@thi.ng/dgraph@1.0.7) (2019-03-01) +## [1.0.13](https://github.com/thi-ng/umbrella/compare/@thi.ng/dgraph@1.0.12...@thi.ng/dgraph@1.0.13) (2019-03-28) **Note:** Version bump only for package @thi.ng/dgraph @@ -11,52 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.0.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/dgraph@1.0.5...@thi.ng/dgraph@1.0.6) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/dgraph - - - - - -## [1.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/dgraph@1.0.4...@thi.ng/dgraph@1.0.5) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/dgraph - - - - - -## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/dgraph@1.0.3...@thi.ng/dgraph@1.0.4) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/dgraph - - - - - -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/dgraph@1.0.2...@thi.ng/dgraph@1.0.3) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/dgraph - - - - - -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/dgraph@1.0.1...@thi.ng/dgraph@1.0.2) (2019-01-31) - -**Note:** Version bump only for package @thi.ng/dgraph - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/dgraph@1.0.0...@thi.ng/dgraph@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/dgraph - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/dgraph@0.2.35...@thi.ng/dgraph@1.0.0) (2019-01-21) diff --git a/packages/dgraph/package.json b/packages/dgraph/package.json index 254dc42732..9476494ff4 100644 --- a/packages/dgraph/package.json +++ b/packages/dgraph/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/dgraph", - "version": "1.0.7", + "version": "1.0.13", "description": "Type-agnostic directed acyclic graph (DAG) & graph operations", "module": "./index.js", "main": "./lib/index.js", @@ -32,11 +32,11 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/associative": "^1.0.7", - "@thi.ng/equiv": "^1.0.3", - "@thi.ng/errors": "^1.0.3", - "@thi.ng/transducers": "^5.1.1" + "@thi.ng/api": "^6.0.0", + "@thi.ng/associative": "^2.0.0", + "@thi.ng/equiv": "^1.0.4", + "@thi.ng/errors": "^1.0.4", + "@thi.ng/transducers": "^5.3.1" }, "keywords": [ "data structure", diff --git a/packages/diff/CHANGELOG.md b/packages/diff/CHANGELOG.md index a20c88509d..38361bc0eb 100644 --- a/packages/diff/CHANGELOG.md +++ b/packages/diff/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [3.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/diff@3.0.2...@thi.ng/diff@3.0.3) (2019-03-01) +## [3.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/diff@3.0.4...@thi.ng/diff@3.0.5) (2019-03-28) **Note:** Version bump only for package @thi.ng/diff @@ -11,20 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [3.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/diff@3.0.1...@thi.ng/diff@3.0.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/diff - - - - - -## [3.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/diff@3.0.0...@thi.ng/diff@3.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/diff - - - # [3.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/diff@2.0.2...@thi.ng/diff@3.0.0) (2019-01-21) diff --git a/packages/diff/package.json b/packages/diff/package.json index ca57debfdc..8b7ce38607 100644 --- a/packages/diff/package.json +++ b/packages/diff/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/diff", - "version": "3.0.3", + "version": "3.0.5", "description": "Array & object Diff", "module": "./index.js", "main": "./lib/index.js", @@ -31,8 +31,8 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/equiv": "^1.0.3" + "@thi.ng/api": "^6.0.0", + "@thi.ng/equiv": "^1.0.4" }, "keywords": [ "additions", diff --git a/packages/dlogic/CHANGELOG.md b/packages/dlogic/CHANGELOG.md index 6d473a18b9..af3fcb017e 100644 --- a/packages/dlogic/CHANGELOG.md +++ b/packages/dlogic/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/dlogic@1.0.2...@thi.ng/dlogic@1.0.3) (2019-03-01) +## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/dlogic@1.0.3...@thi.ng/dlogic@1.0.4) (2019-03-28) **Note:** Version bump only for package @thi.ng/dlogic @@ -11,20 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/dlogic@1.0.1...@thi.ng/dlogic@1.0.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/dlogic - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/dlogic@1.0.0...@thi.ng/dlogic@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/dlogic - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/dlogic@0.1.2...@thi.ng/dlogic@1.0.0) (2019-01-21) diff --git a/packages/dlogic/package.json b/packages/dlogic/package.json index d18fe46f03..bd2b1cc6d1 100644 --- a/packages/dlogic/package.json +++ b/packages/dlogic/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/dlogic", - "version": "1.0.3", + "version": "1.0.4", "description": "Assorted digital logic ops / constructs.", "module": "./index.js", "main": "./lib/index.js", diff --git a/packages/dot/CHANGELOG.md b/packages/dot/CHANGELOG.md index e5b3fca643..fef5bdb803 100644 --- a/packages/dot/CHANGELOG.md +++ b/packages/dot/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/dot@1.0.3...@thi.ng/dot@1.0.4) (2019-03-01) +## [1.0.8](https://github.com/thi-ng/umbrella/compare/@thi.ng/dot@1.0.7...@thi.ng/dot@1.0.8) (2019-03-28) **Note:** Version bump only for package @thi.ng/dot @@ -11,28 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/dot@1.0.2...@thi.ng/dot@1.0.3) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/dot - - - - - -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/dot@1.0.1...@thi.ng/dot@1.0.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/dot - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/dot@1.0.0...@thi.ng/dot@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/dot - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/dot@0.1.18...@thi.ng/dot@1.0.0) (2019-01-21) diff --git a/packages/dot/package.json b/packages/dot/package.json index 0a64abcaa6..c9c89faf07 100644 --- a/packages/dot/package.json +++ b/packages/dot/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/dot", - "version": "1.0.4", + "version": "1.0.8", "description": "Graphviz DOM abstraction as vanilla JS objects & serialization to DOT format", "module": "./index.js", "main": "./lib/index.js", @@ -32,8 +32,8 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/checks": "^2.1.1" + "@thi.ng/api": "^6.0.0", + "@thi.ng/checks": "^2.1.4" }, "keywords": [ "ES6", diff --git a/packages/dsp/CHANGELOG.md b/packages/dsp/CHANGELOG.md index 8386511389..e47ed4dfb2 100644 --- a/packages/dsp/CHANGELOG.md +++ b/packages/dsp/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/dsp@1.0.2...@thi.ng/dsp@1.0.3) (2019-03-01) +## [1.0.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/dsp@1.0.5...@thi.ng/dsp@1.0.6) (2019-03-28) **Note:** Version bump only for package @thi.ng/dsp @@ -11,20 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/dsp@1.0.1...@thi.ng/dsp@1.0.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/dsp - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/dsp@1.0.0...@thi.ng/dsp@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/dsp - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/dsp@0.1.3...@thi.ng/dsp@1.0.0) (2019-01-21) diff --git a/packages/dsp/package.json b/packages/dsp/package.json index 81f1df2e8c..7d0f2e4c46 100644 --- a/packages/dsp/package.json +++ b/packages/dsp/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/dsp", - "version": "1.0.3", + "version": "1.0.6", "description": "Assorted DSP utils, oscillators etc.", "module": "./index.js", "main": "./lib/index.js", @@ -32,7 +32,8 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/math": "^1.1.1" + "@thi.ng/api": "^6.0.0", + "@thi.ng/math": "^1.2.1" }, "keywords": [ "additive", diff --git a/packages/dsp/src/osc.ts b/packages/dsp/src/osc.ts index 181e93f352..0a81d8bffd 100644 --- a/packages/dsp/src/osc.ts +++ b/packages/dsp/src/osc.ts @@ -1,4 +1,11 @@ -import { fract, HALF_PI, mix as _mix, TAU, wrap01 } from "@thi.ng/math"; +import { Fn } from "@thi.ng/api"; +import { + fract, + HALF_PI, + mix as _mix, + TAU, + wrap01 +} from "@thi.ng/math"; import { StatelessOscillator } from "./api"; export class Oscillator implements Iterable { @@ -112,8 +119,8 @@ export const mix = ( export const additive = ( osc: StatelessOscillator, - freqFn: (i: number) => number, - ampFn: (i: number) => number, + freqFn: Fn, + ampFn: Fn, n: number ) => (phase: number, freq: number, amp = 1, dc = 0) => { let y = 0; @@ -172,5 +179,5 @@ export const polyBLEP = (eps: number, x: number) => x < eps ? ((x /= eps), x + x - x * x - 1) : x > 1 - eps - ? ((x = (x - 1) / eps), x * x + x + x + 1) - : 0; + ? ((x = (x - 1) / eps), x * x + x + x + 1) + : 0; diff --git a/packages/equiv/CHANGELOG.md b/packages/equiv/CHANGELOG.md index fa764fb7f6..f96a9ba68d 100644 --- a/packages/equiv/CHANGELOG.md +++ b/packages/equiv/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/equiv@1.0.2...@thi.ng/equiv@1.0.3) (2019-03-01) +## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/equiv@1.0.3...@thi.ng/equiv@1.0.4) (2019-03-28) **Note:** Version bump only for package @thi.ng/equiv @@ -11,20 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/equiv@1.0.1...@thi.ng/equiv@1.0.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/equiv - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/equiv@1.0.0...@thi.ng/equiv@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/equiv - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/equiv@0.1.15...@thi.ng/equiv@1.0.0) (2019-01-21) diff --git a/packages/equiv/package.json b/packages/equiv/package.json index 52f82f9011..d342ee2299 100644 --- a/packages/equiv/package.json +++ b/packages/equiv/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/equiv", - "version": "1.0.3", + "version": "1.0.4", "description": "Extensible deep equivalence checking for any data types", "module": "./index.js", "main": "./lib/index.js", diff --git a/packages/errors/CHANGELOG.md b/packages/errors/CHANGELOG.md index d38ed2f1b3..4d16b13680 100644 --- a/packages/errors/CHANGELOG.md +++ b/packages/errors/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/errors@1.0.2...@thi.ng/errors@1.0.3) (2019-03-01) +## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/errors@1.0.3...@thi.ng/errors@1.0.4) (2019-03-28) **Note:** Version bump only for package @thi.ng/errors @@ -11,20 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/errors@1.0.1...@thi.ng/errors@1.0.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/errors - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/errors@1.0.0...@thi.ng/errors@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/errors - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/errors@0.1.12...@thi.ng/errors@1.0.0) (2019-01-21) diff --git a/packages/errors/package.json b/packages/errors/package.json index f6b651edf2..0e25ac88fc 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/errors", - "version": "1.0.3", + "version": "1.0.4", "description": "Custom error types and helper fns.", "module": "./index.js", "main": "./lib/index.js", diff --git a/packages/fsm/CHANGELOG.md b/packages/fsm/CHANGELOG.md index dd3fbb9c92..b991d22064 100644 --- a/packages/fsm/CHANGELOG.md +++ b/packages/fsm/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [2.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/fsm@2.1.2...@thi.ng/fsm@2.1.3) (2019-03-01) +## [2.1.9](https://github.com/thi-ng/umbrella/compare/@thi.ng/fsm@2.1.8...@thi.ng/fsm@2.1.9) (2019-03-28) **Note:** Version bump only for package @thi.ng/fsm @@ -11,20 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [2.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/fsm@2.1.1...@thi.ng/fsm@2.1.2) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/fsm - - - - - -## [2.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/fsm@2.1.0...@thi.ng/fsm@2.1.1) (2019-02-21) - -**Note:** Version bump only for package @thi.ng/fsm - - - # [2.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/fsm@2.0.0...@thi.ng/fsm@2.1.0) (2019-02-20) @@ -56,40 +42,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - - -## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/fsm@1.0.3...@thi.ng/fsm@1.0.4) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/fsm - - - - - -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/fsm@1.0.2...@thi.ng/fsm@1.0.3) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/fsm - - - - - -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/fsm@1.0.1...@thi.ng/fsm@1.0.2) (2019-01-31) - -**Note:** Version bump only for package @thi.ng/fsm - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/fsm@1.0.0...@thi.ng/fsm@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/fsm - - - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/fsm@0.1.0...@thi.ng/fsm@1.0.0) (2019-01-21) @@ -110,8 +62,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - - # 0.1.0 (2019-01-04) diff --git a/packages/fsm/package.json b/packages/fsm/package.json index 32f1ee818d..cd137185f9 100644 --- a/packages/fsm/package.json +++ b/packages/fsm/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/fsm", - "version": "2.1.3", + "version": "2.1.9", "description": "Composable primitives for building declarative, transducer based Finite-State machines & parsers for arbitrary data streams", "module": "./index.js", "main": "./lib/index.js", @@ -32,11 +32,11 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/arrays": "^0.1.1", - "@thi.ng/equiv": "^1.0.3", - "@thi.ng/errors": "^1.0.3", - "@thi.ng/transducers": "^5.1.1" + "@thi.ng/api": "^6.0.0", + "@thi.ng/arrays": "^0.1.5", + "@thi.ng/equiv": "^1.0.4", + "@thi.ng/errors": "^1.0.4", + "@thi.ng/transducers": "^5.3.1" }, "keywords": [ "ES6", diff --git a/packages/fsm/src/fsm.ts b/packages/fsm/src/fsm.ts index 660b42b164..614e742d11 100644 --- a/packages/fsm/src/fsm.ts +++ b/packages/fsm/src/fsm.ts @@ -1,12 +1,12 @@ -import { IObjectOf } from "@thi.ng/api"; +import { Fn2, IObjectOf } from "@thi.ng/api"; import { illegalArgs, illegalState } from "@thi.ng/errors"; import { ensureReduced, isReduced, + iterator, Reducer, Transducer, - unreduced, - iterator + unreduced } from "@thi.ng/transducers"; import { Match, Matcher } from "./api"; @@ -44,20 +44,20 @@ export function fsm( states: IObjectOf>, ctx: C, initial: string | number, - update?: (ctx: C, x: T) => void + update?: Fn2 ): Transducer; export function fsm( states: IObjectOf>, ctx: C, initial: string | number, - update?: (ctx: C, x: T) => void, + update?: Fn2, src?: Iterable ): IterableIterator; export function fsm( states: IObjectOf>, ctx: C, initial: string | number = "start", - update?: (ctx: C, x: T) => void, + update?: Fn2, src?: Iterable ) { return src diff --git a/packages/geom-accel/CHANGELOG.md b/packages/geom-accel/CHANGELOG.md index 781884e565..20eaad8de1 100644 --- a/packages/geom-accel/CHANGELOG.md +++ b/packages/geom-accel/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-accel@1.1.4...@thi.ng/geom-accel@1.1.5) (2019-03-01) +## [1.1.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-accel@1.1.10...@thi.ng/geom-accel@1.1.11) (2019-03-28) **Note:** Version bump only for package @thi.ng/geom-accel @@ -11,19 +11,14 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-accel@1.1.3...@thi.ng/geom-accel@1.1.4) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/geom-accel - - +## [1.1.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-accel@1.1.6...@thi.ng/geom-accel@1.1.7) (2019-03-10) -## [1.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-accel@1.1.2...@thi.ng/geom-accel@1.1.3) (2019-02-20) - -**Note:** Version bump only for package @thi.ng/geom-accel +### Bug Fixes +* **geom-accel:** fix/update existing point search in add()/select*() ([8186f12](https://github.com/thi-ng/umbrella/commit/8186f12)) @@ -36,16 +31,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - - -## [1.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-accel@1.1.0...@thi.ng/geom-accel@1.1.1) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/geom-accel - - - - - # [1.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-accel@1.0.2...@thi.ng/geom-accel@1.1.0) (2019-02-05) @@ -60,16 +45,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - - -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-accel@1.0.1...@thi.ng/geom-accel@1.0.2) (2019-01-31) - -**Note:** Version bump only for package @thi.ng/geom-accel - - - - - ## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-accel@1.0.0...@thi.ng/geom-accel@1.0.1) (2019-01-21) @@ -79,8 +54,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-accel@0.1.11...@thi.ng/geom-accel@1.0.0) (2019-01-21) diff --git a/packages/geom-accel/package.json b/packages/geom-accel/package.json index bf9b7b7656..2fc155cbb8 100644 --- a/packages/geom-accel/package.json +++ b/packages/geom-accel/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/geom-accel", - "version": "1.1.5", + "version": "1.1.11", "description": "nD spatial indexing data structures", "module": "./index.js", "main": "./lib/index.js", @@ -32,13 +32,13 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/arrays": "^0.1.1", - "@thi.ng/geom-api": "^0.1.4", - "@thi.ng/heaps": "^1.0.4", - "@thi.ng/math": "^1.1.1", - "@thi.ng/transducers": "^5.1.1", - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/api": "^6.0.0", + "@thi.ng/arrays": "^0.1.5", + "@thi.ng/geom-api": "^0.1.10", + "@thi.ng/heaps": "^1.0.6", + "@thi.ng/math": "^1.2.1", + "@thi.ng/transducers": "^5.3.1", + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "2D", diff --git a/packages/geom-accel/src/kdtree.ts b/packages/geom-accel/src/kdtree.ts index 094f0d10ab..7ef1b7fcaa 100644 --- a/packages/geom-accel/src/kdtree.ts +++ b/packages/geom-accel/src/kdtree.ts @@ -94,17 +94,17 @@ export class KdTree const search = ( node: KdNode, parent: KdNode - ): KdNode | false => + ): KdNode => node - ? distSq(p, node.k) > eps - ? search(p[node.d] < node.k[node.d] ? node.l : node.r, node) - : false + ? search(p[node.d] < node.k[node.d] ? node.l : node.r, node) : parent; - const parent = search(this.root, null); - if (parent === false) return false; - if (parent == null) { - this.root = new KdNode(null, 0, p, v); - } else { + let parent: KdNode; + if (this.root) { + parent = nearest1(p, [eps * eps, null], [], this.dim, this.root)[1]; + if (parent) { + return false; + } + parent = search(this.root, null); const dim = parent.d; parent[p[dim] < parent.k[dim] ? "l" : "r"] = new KdNode( parent, @@ -112,6 +112,8 @@ export class KdTree p, v ); + } else { + this.root = new KdNode(null, 0, p, v); } this._length++; return true; @@ -160,7 +162,7 @@ export class KdTree if (maxNum === 1) { const sel = nearest1( q, - [maxDist != null ? maxDist : Infinity, null], + [maxDist != null ? maxDist * maxDist : Infinity, null], [], this.dim, this.root @@ -182,7 +184,7 @@ export class KdTree if (maxNum === 1) { const sel = nearest1( q, - [maxDist != null ? maxDist : Infinity, null], + [maxDist != null ? maxDist * maxDist : Infinity, null], [], this.dim, this.root @@ -204,7 +206,7 @@ export class KdTree if (maxNum === 1) { const sel = nearest1( q, - [maxDist != null ? maxDist : Infinity, null], + [maxDist != null ? maxDist * maxDist : Infinity, null], [], this.dim, this.root @@ -363,10 +365,10 @@ const nearest = ( let best = !node.r ? node.l : !node.l - ? node.r - : q[ndim] < p[ndim] - ? node.l - : node.r; + ? node.r + : q[ndim] < p[ndim] + ? node.l + : node.r; nearest(q, acc, tmp, dims, maxNum, best); if (!acc.length || ndist < acc.peek()[0]) { if (acc.length >= maxNum) { @@ -413,10 +415,10 @@ const nearest1 = ( let best = !node.r ? node.l : !node.l - ? node.r - : q[ndim] < p[ndim] - ? node.l - : node.r; + ? node.r + : q[ndim] < p[ndim] + ? node.l + : node.r; nearest1(q, acc, tmp, dims, best); if (ndist < acc[0]) { acc[0] = ndist; diff --git a/packages/geom-api/CHANGELOG.md b/packages/geom-api/CHANGELOG.md index e33b0b8ebf..57fc332538 100644 --- a/packages/geom-api/CHANGELOG.md +++ b/packages/geom-api/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-api@0.1.3...@thi.ng/geom-api@0.1.4) (2019-03-01) +## [0.1.10](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-api@0.1.9...@thi.ng/geom-api@0.1.10) (2019-03-28) **Note:** Version bump only for package @thi.ng/geom-api @@ -11,28 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-api@0.1.2...@thi.ng/geom-api@0.1.3) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/geom-api - - - - - -## [0.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-api@0.1.1...@thi.ng/geom-api@0.1.2) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/geom-api - - - - - -## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-api@0.1.0...@thi.ng/geom-api@0.1.1) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/geom-api - - - # 0.1.0 (2019-02-05) diff --git a/packages/geom-api/package.json b/packages/geom-api/package.json index 43ff402df4..59b5e60396 100644 --- a/packages/geom-api/package.json +++ b/packages/geom-api/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/geom-api", - "version": "0.1.4", + "version": "0.1.10", "description": "Shared type & interface declarations for @thi.ng/geom packages", "module": "./index.js", "main": "./lib/index.js", @@ -32,8 +32,8 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/api": "^6.0.0", + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "ES6", diff --git a/packages/geom-arc/CHANGELOG.md b/packages/geom-arc/CHANGELOG.md index 563f562a7d..3e3208cdba 100644 --- a/packages/geom-arc/CHANGELOG.md +++ b/packages/geom-arc/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-arc@0.1.4...@thi.ng/geom-arc@0.1.5) (2019-03-01) +## [0.1.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-arc@0.1.10...@thi.ng/geom-arc@0.1.11) (2019-03-28) **Note:** Version bump only for package @thi.ng/geom-arc @@ -11,36 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-arc@0.1.3...@thi.ng/geom-arc@0.1.4) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/geom-arc - - - - - -## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-arc@0.1.2...@thi.ng/geom-arc@0.1.3) (2019-02-20) - -**Note:** Version bump only for package @thi.ng/geom-arc - - - - - -## [0.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-arc@0.1.1...@thi.ng/geom-arc@0.1.2) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/geom-arc - - - - - -## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-arc@0.1.0...@thi.ng/geom-arc@0.1.1) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/geom-arc - - - # 0.1.0 (2019-02-05) diff --git a/packages/geom-arc/package.json b/packages/geom-arc/package.json index eaf0cc4889..977e7c26cd 100644 --- a/packages/geom-arc/package.json +++ b/packages/geom-arc/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/geom-arc", - "version": "0.1.5", + "version": "0.1.11", "description": "2D circular / elliptic arc operations", "module": "./index.js", "main": "./lib/index.js", @@ -32,11 +32,11 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/checks": "^2.1.1", - "@thi.ng/geom-api": "^0.1.4", - "@thi.ng/geom-resample": "^0.1.5", - "@thi.ng/math": "^1.1.1", - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/checks": "^2.1.4", + "@thi.ng/geom-api": "^0.1.10", + "@thi.ng/geom-resample": "^0.1.11", + "@thi.ng/math": "^1.2.1", + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "2D", diff --git a/packages/geom-clip/CHANGELOG.md b/packages/geom-clip/CHANGELOG.md index 50babf83df..b41abc4ad2 100644 --- a/packages/geom-clip/CHANGELOG.md +++ b/packages/geom-clip/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.0.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-clip@0.0.6...@thi.ng/geom-clip@0.0.7) (2019-03-01) +## [0.0.13](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-clip@0.0.12...@thi.ng/geom-clip@0.0.13) (2019-03-28) **Note:** Version bump only for package @thi.ng/geom-clip @@ -11,36 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.0.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-clip@0.0.5...@thi.ng/geom-clip@0.0.6) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/geom-clip - - - - - -## [0.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-clip@0.0.4...@thi.ng/geom-clip@0.0.5) (2019-02-20) - -**Note:** Version bump only for package @thi.ng/geom-clip - - - - - -## [0.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-clip@0.0.3...@thi.ng/geom-clip@0.0.4) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/geom-clip - - - - - -## [0.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-clip@0.0.2...@thi.ng/geom-clip@0.0.3) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/geom-clip - - - ## 0.0.2 (2019-02-05) diff --git a/packages/geom-clip/package.json b/packages/geom-clip/package.json index 8f3799f365..95424a97bd 100644 --- a/packages/geom-clip/package.json +++ b/packages/geom-clip/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/geom-clip", - "version": "0.0.7", + "version": "0.0.13", "description": "2D line & convex polygon clipping (Liang-Barsky / Sutherland-Hodgeman)", "module": "./index.js", "main": "./lib/index.js", @@ -32,10 +32,10 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/geom-isec": "^0.1.5", - "@thi.ng/geom-poly-utils": "^0.1.5", - "@thi.ng/math": "^1.1.1", - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/geom-isec": "^0.1.11", + "@thi.ng/geom-poly-utils": "^0.1.11", + "@thi.ng/math": "^1.2.1", + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "2D", diff --git a/packages/geom-closest-point/CHANGELOG.md b/packages/geom-closest-point/CHANGELOG.md index aecf0f8009..7bde5e11f7 100644 --- a/packages/geom-closest-point/CHANGELOG.md +++ b/packages/geom-closest-point/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.1.4...@thi.ng/geom-closest-point@0.1.5) (2019-03-01) +## [0.1.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.1.10...@thi.ng/geom-closest-point@0.1.11) (2019-03-28) **Note:** Version bump only for package @thi.ng/geom-closest-point @@ -11,36 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.1.3...@thi.ng/geom-closest-point@0.1.4) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/geom-closest-point - - - - - -## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.1.2...@thi.ng/geom-closest-point@0.1.3) (2019-02-20) - -**Note:** Version bump only for package @thi.ng/geom-closest-point - - - - - -## [0.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.1.1...@thi.ng/geom-closest-point@0.1.2) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/geom-closest-point - - - - - -## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.1.0...@thi.ng/geom-closest-point@0.1.1) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/geom-closest-point - - - # 0.1.0 (2019-02-05) diff --git a/packages/geom-closest-point/package.json b/packages/geom-closest-point/package.json index 8ed71afe93..f50416b93b 100644 --- a/packages/geom-closest-point/package.json +++ b/packages/geom-closest-point/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/geom-closest-point", - "version": "0.1.5", + "version": "0.1.11", "description": "Closest point / proximity helpers", "module": "./index.js", "main": "./lib/index.js", @@ -32,7 +32,7 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "ES6", diff --git a/packages/geom-hull/CHANGELOG.md b/packages/geom-hull/CHANGELOG.md index 3cb3508ae1..0c708fb70b 100644 --- a/packages/geom-hull/CHANGELOG.md +++ b/packages/geom-hull/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.0.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-hull@0.0.6...@thi.ng/geom-hull@0.0.7) (2019-03-01) +## [0.0.13](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-hull@0.0.12...@thi.ng/geom-hull@0.0.13) (2019-03-28) **Note:** Version bump only for package @thi.ng/geom-hull @@ -11,36 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.0.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-hull@0.0.5...@thi.ng/geom-hull@0.0.6) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/geom-hull - - - - - -## [0.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-hull@0.0.4...@thi.ng/geom-hull@0.0.5) (2019-02-20) - -**Note:** Version bump only for package @thi.ng/geom-hull - - - - - -## [0.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-hull@0.0.3...@thi.ng/geom-hull@0.0.4) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/geom-hull - - - - - -## [0.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-hull@0.0.2...@thi.ng/geom-hull@0.0.3) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/geom-hull - - - ## 0.0.2 (2019-02-05) diff --git a/packages/geom-hull/package.json b/packages/geom-hull/package.json index 3e696d64ab..d1c2c14685 100644 --- a/packages/geom-hull/package.json +++ b/packages/geom-hull/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/geom-hull", - "version": "0.0.7", + "version": "0.0.13", "description": "Fast 2D convex hull (Graham Scan)", "module": "./index.js", "main": "./lib/index.js", @@ -32,8 +32,8 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/math": "^1.1.1", - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/math": "^1.2.1", + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "2D", diff --git a/packages/geom-isec/CHANGELOG.md b/packages/geom-isec/CHANGELOG.md index d7da44e5bb..73047f11f2 100644 --- a/packages/geom-isec/CHANGELOG.md +++ b/packages/geom-isec/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-isec@0.1.4...@thi.ng/geom-isec@0.1.5) (2019-03-01) +## [0.1.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-isec@0.1.10...@thi.ng/geom-isec@0.1.11) (2019-03-28) **Note:** Version bump only for package @thi.ng/geom-isec @@ -11,36 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-isec@0.1.3...@thi.ng/geom-isec@0.1.4) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/geom-isec - - - - - -## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-isec@0.1.2...@thi.ng/geom-isec@0.1.3) (2019-02-20) - -**Note:** Version bump only for package @thi.ng/geom-isec - - - - - -## [0.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-isec@0.1.1...@thi.ng/geom-isec@0.1.2) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/geom-isec - - - - - -## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-isec@0.1.0...@thi.ng/geom-isec@0.1.1) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/geom-isec - - - # 0.1.0 (2019-02-05) diff --git a/packages/geom-isec/package.json b/packages/geom-isec/package.json index 324f7accca..671a00904e 100644 --- a/packages/geom-isec/package.json +++ b/packages/geom-isec/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/geom-isec", - "version": "0.1.5", + "version": "0.1.11", "description": "2D/3D shape intersection checks", "module": "./index.js", "main": "./lib/index.js", @@ -32,10 +32,11 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/geom-api": "^0.1.4", - "@thi.ng/geom-closest-point": "^0.1.5", - "@thi.ng/math": "^1.1.1", - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/api": "^6.0.0", + "@thi.ng/geom-api": "^0.1.10", + "@thi.ng/geom-closest-point": "^0.1.11", + "@thi.ng/math": "^1.2.1", + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "2D", diff --git a/packages/geom-isec/src/ray-rect.ts b/packages/geom-isec/src/ray-rect.ts index d20594fd5e..f7829b817c 100644 --- a/packages/geom-isec/src/ray-rect.ts +++ b/packages/geom-isec/src/ray-rect.ts @@ -1,3 +1,4 @@ +import { Fn4 } from "@thi.ng/api"; import { IntersectionType } from "@thi.ng/geom-api"; import { maddN, ReadonlyVec } from "@thi.ng/vectors"; import { NONE } from "./api"; @@ -29,7 +30,7 @@ const rayRect = ( (p = rpos[1]), (d = 1 / dir[1]); t1 = (bmin[1] - p) * d; t2 = (bmax[1] - p) * d; - return [max(tmin, min(t1, t2)), min(tmax, max(t1, t2))]; + return <[number, number]>[max(tmin, min(t1, t2)), min(tmax, max(t1, t2))]; }; /** @@ -60,16 +61,17 @@ const rayBox = ( t2 = (bmax[2] - p) * d; tmin = max(tmin, min(t1, t2)); tmax = min(tmax, max(t1, t2)); - return [max(tmin, min(t1, t2)), min(tmax, max(t1, t2))]; + return <[number, number]>[max(tmin, min(t1, t2)), min(tmax, max(t1, t2))]; }; const intersectWith = ( - fn: ( - a: ReadonlyVec, - b: ReadonlyVec, - c: ReadonlyVec, - d: ReadonlyVec - ) => number[] + fn: Fn4< + ReadonlyVec, + ReadonlyVec, + ReadonlyVec, + ReadonlyVec, + [number, number] + > ) => ( rpos: ReadonlyVec, dir: ReadonlyVec, diff --git a/packages/geom-isoline/CHANGELOG.md b/packages/geom-isoline/CHANGELOG.md index ae36606669..98bdf7c0bc 100644 --- a/packages/geom-isoline/CHANGELOG.md +++ b/packages/geom-isoline/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-isoline@0.1.4...@thi.ng/geom-isoline@0.1.5) (2019-03-01) +## [0.1.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-isoline@0.1.10...@thi.ng/geom-isoline@0.1.11) (2019-03-28) **Note:** Version bump only for package @thi.ng/geom-isoline @@ -11,20 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-isoline@0.1.3...@thi.ng/geom-isoline@0.1.4) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/geom-isoline - - - - - -## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-isoline@0.1.2...@thi.ng/geom-isoline@0.1.3) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/geom-isoline - - - ## [0.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-isoline@0.1.1...@thi.ng/geom-isoline@0.1.2) (2019-02-11) @@ -36,8 +22,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - - ## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-isoline@0.1.0...@thi.ng/geom-isoline@0.1.1) (2019-02-10) diff --git a/packages/geom-isoline/package.json b/packages/geom-isoline/package.json index dcccbf0938..c945251116 100644 --- a/packages/geom-isoline/package.json +++ b/packages/geom-isoline/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/geom-isoline", - "version": "0.1.5", + "version": "0.1.11", "description": "Fast 2D contour line extraction / generation", "module": "./index.js", "main": "./lib/index.js", @@ -32,8 +32,8 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/transducers": "^5.1.1", - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/transducers": "^5.3.1", + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "2D", diff --git a/packages/geom-poly-utils/CHANGELOG.md b/packages/geom-poly-utils/CHANGELOG.md index 70e527455f..499b366f13 100644 --- a/packages/geom-poly-utils/CHANGELOG.md +++ b/packages/geom-poly-utils/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-poly-utils@0.1.4...@thi.ng/geom-poly-utils@0.1.5) (2019-03-01) +## [0.1.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-poly-utils@0.1.10...@thi.ng/geom-poly-utils@0.1.11) (2019-03-28) **Note:** Version bump only for package @thi.ng/geom-poly-utils @@ -11,36 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-poly-utils@0.1.3...@thi.ng/geom-poly-utils@0.1.4) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/geom-poly-utils - - - - - -## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-poly-utils@0.1.2...@thi.ng/geom-poly-utils@0.1.3) (2019-02-20) - -**Note:** Version bump only for package @thi.ng/geom-poly-utils - - - - - -## [0.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-poly-utils@0.1.1...@thi.ng/geom-poly-utils@0.1.2) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/geom-poly-utils - - - - - -## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-poly-utils@0.1.0...@thi.ng/geom-poly-utils@0.1.1) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/geom-poly-utils - - - # 0.1.0 (2019-02-05) diff --git a/packages/geom-poly-utils/package.json b/packages/geom-poly-utils/package.json index 43790b92b6..47f0840bb1 100644 --- a/packages/geom-poly-utils/package.json +++ b/packages/geom-poly-utils/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/geom-poly-utils", - "version": "0.1.5", + "version": "0.1.11", "description": "Polygon / triangle analysis & processing utilities", "module": "./index.js", "main": "./lib/index.js", @@ -32,10 +32,10 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/errors": "^1.0.3", - "@thi.ng/geom-api": "^0.1.4", - "@thi.ng/math": "^1.1.1", - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/errors": "^1.0.4", + "@thi.ng/geom-api": "^0.1.10", + "@thi.ng/math": "^1.2.1", + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "2D", diff --git a/packages/geom-resample/CHANGELOG.md b/packages/geom-resample/CHANGELOG.md index 8d43fe9900..25baa30e55 100644 --- a/packages/geom-resample/CHANGELOG.md +++ b/packages/geom-resample/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-resample@0.1.4...@thi.ng/geom-resample@0.1.5) (2019-03-01) +## [0.1.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-resample@0.1.10...@thi.ng/geom-resample@0.1.11) (2019-03-28) **Note:** Version bump only for package @thi.ng/geom-resample @@ -11,36 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-resample@0.1.3...@thi.ng/geom-resample@0.1.4) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/geom-resample - - - - - -## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-resample@0.1.2...@thi.ng/geom-resample@0.1.3) (2019-02-20) - -**Note:** Version bump only for package @thi.ng/geom-resample - - - - - -## [0.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-resample@0.1.1...@thi.ng/geom-resample@0.1.2) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/geom-resample - - - - - -## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-resample@0.1.0...@thi.ng/geom-resample@0.1.1) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/geom-resample - - - # 0.1.0 (2019-02-05) diff --git a/packages/geom-resample/package.json b/packages/geom-resample/package.json index 5bd0822f26..8fb82c3914 100644 --- a/packages/geom-resample/package.json +++ b/packages/geom-resample/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/geom-resample", - "version": "0.1.5", + "version": "0.1.11", "description": "Customizable nD polyline interpolation, re-sampling, splitting & nearest point computation", "module": "./index.js", "main": "./lib/index.js", @@ -32,11 +32,11 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/checks": "^2.1.1", - "@thi.ng/geom-api": "^0.1.4", - "@thi.ng/geom-closest-point": "^0.1.5", - "@thi.ng/math": "^1.1.1", - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/checks": "^2.1.4", + "@thi.ng/geom-api": "^0.1.10", + "@thi.ng/geom-closest-point": "^0.1.11", + "@thi.ng/math": "^1.2.1", + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "2D", diff --git a/packages/geom-splines/CHANGELOG.md b/packages/geom-splines/CHANGELOG.md index cb574783e1..55b5fcdb12 100644 --- a/packages/geom-splines/CHANGELOG.md +++ b/packages/geom-splines/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-splines@0.1.4...@thi.ng/geom-splines@0.1.5) (2019-03-01) +## [0.1.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-splines@0.1.10...@thi.ng/geom-splines@0.1.11) (2019-03-28) **Note:** Version bump only for package @thi.ng/geom-splines @@ -11,36 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-splines@0.1.3...@thi.ng/geom-splines@0.1.4) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/geom-splines - - - - - -## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-splines@0.1.2...@thi.ng/geom-splines@0.1.3) (2019-02-20) - -**Note:** Version bump only for package @thi.ng/geom-splines - - - - - -## [0.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-splines@0.1.1...@thi.ng/geom-splines@0.1.2) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/geom-splines - - - - - -## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-splines@0.1.0...@thi.ng/geom-splines@0.1.1) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/geom-splines - - - # 0.1.0 (2019-02-05) diff --git a/packages/geom-splines/package.json b/packages/geom-splines/package.json index 617bdeccd8..0f6761ebfa 100644 --- a/packages/geom-splines/package.json +++ b/packages/geom-splines/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/geom-splines", - "version": "0.1.5", + "version": "0.1.11", "description": "nD cubic & quadratic curve analysis, conversion, interpolation, splitting", "module": "./index.js", "main": "./lib/index.js", @@ -32,12 +32,12 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/checks": "^2.1.1", - "@thi.ng/geom-api": "^0.1.4", - "@thi.ng/geom-arc": "^0.1.5", - "@thi.ng/geom-resample": "^0.1.5", - "@thi.ng/math": "^1.1.1", - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/checks": "^2.1.4", + "@thi.ng/geom-api": "^0.1.10", + "@thi.ng/geom-arc": "^0.1.11", + "@thi.ng/geom-resample": "^0.1.11", + "@thi.ng/math": "^1.2.1", + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "2D", diff --git a/packages/geom-subdiv-curve/CHANGELOG.md b/packages/geom-subdiv-curve/CHANGELOG.md index cc21814c39..b9e89e415d 100644 --- a/packages/geom-subdiv-curve/CHANGELOG.md +++ b/packages/geom-subdiv-curve/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-subdiv-curve@0.1.3...@thi.ng/geom-subdiv-curve@0.1.4) (2019-03-01) +## [0.1.10](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-subdiv-curve@0.1.9...@thi.ng/geom-subdiv-curve@0.1.10) (2019-03-28) **Note:** Version bump only for package @thi.ng/geom-subdiv-curve @@ -11,28 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-subdiv-curve@0.1.2...@thi.ng/geom-subdiv-curve@0.1.3) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/geom-subdiv-curve - - - - - -## [0.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-subdiv-curve@0.1.1...@thi.ng/geom-subdiv-curve@0.1.2) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/geom-subdiv-curve - - - - - -## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-subdiv-curve@0.1.0...@thi.ng/geom-subdiv-curve@0.1.1) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/geom-subdiv-curve - - - # 0.1.0 (2019-02-05) diff --git a/packages/geom-subdiv-curve/package.json b/packages/geom-subdiv-curve/package.json index fa2e1c9a6f..ad80a33bfd 100644 --- a/packages/geom-subdiv-curve/package.json +++ b/packages/geom-subdiv-curve/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/geom-subdiv-curve", - "version": "0.1.4", + "version": "0.1.10", "description": "Freely customizable, iterative subdivision curves for open / closed input geometries", "module": "./index.js", "main": "./lib/index.js", @@ -32,9 +32,9 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/geom-api": "^0.1.4", - "@thi.ng/transducers": "^5.1.1", - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/geom-api": "^0.1.10", + "@thi.ng/transducers": "^5.3.1", + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "2D", diff --git a/packages/geom-tessellate/CHANGELOG.md b/packages/geom-tessellate/CHANGELOG.md index 44c4f6e2ef..c4b6434507 100644 --- a/packages/geom-tessellate/CHANGELOG.md +++ b/packages/geom-tessellate/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-tessellate@0.1.4...@thi.ng/geom-tessellate@0.1.5) (2019-03-01) +## [0.1.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-tessellate@0.1.10...@thi.ng/geom-tessellate@0.1.11) (2019-03-28) **Note:** Version bump only for package @thi.ng/geom-tessellate @@ -11,36 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-tessellate@0.1.3...@thi.ng/geom-tessellate@0.1.4) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/geom-tessellate - - - - - -## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-tessellate@0.1.2...@thi.ng/geom-tessellate@0.1.3) (2019-02-20) - -**Note:** Version bump only for package @thi.ng/geom-tessellate - - - - - -## [0.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-tessellate@0.1.1...@thi.ng/geom-tessellate@0.1.2) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/geom-tessellate - - - - - -## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-tessellate@0.1.0...@thi.ng/geom-tessellate@0.1.1) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/geom-tessellate - - - # 0.1.0 (2019-02-05) diff --git a/packages/geom-tessellate/package.json b/packages/geom-tessellate/package.json index 43805d56ce..31c272eb76 100644 --- a/packages/geom-tessellate/package.json +++ b/packages/geom-tessellate/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/geom-tessellate", - "version": "0.1.5", + "version": "0.1.11", "description": "2D/3D polygon tessellators", "module": "./index.js", "main": "./lib/index.js", @@ -32,12 +32,12 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/checks": "^2.1.1", - "@thi.ng/geom-api": "^0.1.4", - "@thi.ng/geom-isec": "^0.1.5", - "@thi.ng/geom-poly-utils": "^0.1.5", - "@thi.ng/transducers": "^5.1.1", - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/checks": "^2.1.4", + "@thi.ng/geom-api": "^0.1.10", + "@thi.ng/geom-isec": "^0.1.11", + "@thi.ng/geom-poly-utils": "^0.1.11", + "@thi.ng/transducers": "^5.3.1", + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "2D", diff --git a/packages/geom-voronoi/CHANGELOG.md b/packages/geom-voronoi/CHANGELOG.md index 93dc6cc62f..11910c2909 100644 --- a/packages/geom-voronoi/CHANGELOG.md +++ b/packages/geom-voronoi/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [0.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-voronoi@0.1.4...@thi.ng/geom-voronoi@0.1.5) (2019-03-01) +## [0.1.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-voronoi@0.1.10...@thi.ng/geom-voronoi@0.1.11) (2019-03-28) **Note:** Version bump only for package @thi.ng/geom-voronoi @@ -11,36 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [0.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-voronoi@0.1.3...@thi.ng/geom-voronoi@0.1.4) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/geom-voronoi - - - - - -## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-voronoi@0.1.2...@thi.ng/geom-voronoi@0.1.3) (2019-02-20) - -**Note:** Version bump only for package @thi.ng/geom-voronoi - - - - - -## [0.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-voronoi@0.1.1...@thi.ng/geom-voronoi@0.1.2) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/geom-voronoi - - - - - -## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-voronoi@0.1.0...@thi.ng/geom-voronoi@0.1.1) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/geom-voronoi - - - # 0.1.0 (2019-02-05) diff --git a/packages/geom-voronoi/package.json b/packages/geom-voronoi/package.json index 6d6467454b..7eabbb63d4 100644 --- a/packages/geom-voronoi/package.json +++ b/packages/geom-voronoi/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/geom-voronoi", - "version": "0.1.5", + "version": "0.1.11", "description": "Fast, incremental 2D Delaunay & Voronoi mesh implementation", "module": "./index.js", "main": "./lib/index.js", @@ -32,14 +32,14 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/checks": "^2.1.1", - "@thi.ng/geom-clip": "^0.0.7", - "@thi.ng/geom-isec": "^0.1.5", - "@thi.ng/geom-poly-utils": "^0.1.5", - "@thi.ng/math": "^1.1.1", - "@thi.ng/quad-edge": "^0.1.1", - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/api": "^6.0.0", + "@thi.ng/checks": "^2.1.4", + "@thi.ng/geom-clip": "^0.0.13", + "@thi.ng/geom-isec": "^0.1.11", + "@thi.ng/geom-poly-utils": "^0.1.11", + "@thi.ng/math": "^1.2.1", + "@thi.ng/quad-edge": "^0.1.2", + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "2D", diff --git a/packages/geom/CHANGELOG.md b/packages/geom/CHANGELOG.md index 6469e57100..87b0c54e8d 100644 --- a/packages/geom/CHANGELOG.md +++ b/packages/geom/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.2.9](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom@1.2.8...@thi.ng/geom@1.2.9) (2019-03-01) +## [1.2.16](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom@1.2.15...@thi.ng/geom@1.2.16) (2019-03-28) **Note:** Version bump only for package @thi.ng/geom @@ -11,69 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.2.8](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom@1.2.7...@thi.ng/geom@1.2.8) (2019-02-28) - -**Note:** Version bump only for package @thi.ng/geom - - - - - -## [1.2.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom@1.2.6...@thi.ng/geom@1.2.7) (2019-02-27) - -**Note:** Version bump only for package @thi.ng/geom - - - - - -## [1.2.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom@1.2.5...@thi.ng/geom@1.2.6) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/geom - - - - - -## [1.2.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom@1.2.4...@thi.ng/geom@1.2.5) (2019-02-20) - -**Note:** Version bump only for package @thi.ng/geom - - - - - -## [1.2.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom@1.2.3...@thi.ng/geom@1.2.4) (2019-02-19) - -**Note:** Version bump only for package @thi.ng/geom - - - - - -## [1.2.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom@1.2.2...@thi.ng/geom@1.2.3) (2019-02-18) - -**Note:** Version bump only for package @thi.ng/geom - - - - - -## [1.2.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom@1.2.1...@thi.ng/geom@1.2.2) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/geom - - - - - -## [1.2.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom@1.2.0...@thi.ng/geom@1.2.1) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/geom - - - - # [1.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom@1.1.1...@thi.ng/geom@1.2.0) (2019-02-05) @@ -83,17 +20,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline * **geom:** add ray-rect/aabb impls for intersects() ([5f7dd63](https://github.com/thi-ng/umbrella/commit/5f7dd63)) - - - -## [1.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom@1.1.0...@thi.ng/geom@1.1.1) (2019-01-31) - -**Note:** Version bump only for package @thi.ng/geom - - - - - # [1.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom@1.0.1...@thi.ng/geom@1.1.0) (2019-01-22) @@ -101,7 +27,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline * **geom:** update Rect.toHiccup() format (separate widht/height vals) ([8c1df49](https://github.com/thi-ng/umbrella/commit/8c1df49)) - ### Features * **geom:** add asPolyline() multi-fn ([c602379](https://github.com/thi-ng/umbrella/commit/c602379)) @@ -109,16 +34,12 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - - ## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom@1.0.0...@thi.ng/geom@1.0.1) (2019-01-21) **Note:** Version bump only for package @thi.ng/geom - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom@0.2.11...@thi.ng/geom@1.0.0) (2019-01-21) diff --git a/packages/geom/package.json b/packages/geom/package.json index 54ed50c071..3e4c01a9e9 100644 --- a/packages/geom/package.json +++ b/packages/geom/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/geom", - "version": "1.2.9", + "version": "1.2.16", "description": "2D geometry types, polymorphic operations, SVG generation", "module": "./index.js", "main": "./lib/index.js", @@ -32,31 +32,31 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/arrays": "^0.1.1", - "@thi.ng/checks": "^2.1.1", - "@thi.ng/compose": "^1.1.2", - "@thi.ng/defmulti": "^1.0.3", - "@thi.ng/equiv": "^1.0.3", - "@thi.ng/errors": "^1.0.3", - "@thi.ng/geom-api": "^0.1.4", - "@thi.ng/geom-arc": "^0.1.5", - "@thi.ng/geom-clip": "^0.0.7", - "@thi.ng/geom-closest-point": "^0.1.5", - "@thi.ng/geom-hull": "^0.0.7", - "@thi.ng/geom-isec": "^0.1.5", - "@thi.ng/geom-poly-utils": "^0.1.5", - "@thi.ng/geom-resample": "^0.1.5", - "@thi.ng/geom-splines": "^0.1.5", - "@thi.ng/geom-subdiv-curve": "^0.1.4", - "@thi.ng/geom-tessellate": "^0.1.5", - "@thi.ng/hiccup": "^3.1.1", - "@thi.ng/hiccup-svg": "^3.1.9", - "@thi.ng/math": "^1.1.1", - "@thi.ng/matrices": "^0.1.8", - "@thi.ng/random": "^1.1.1", - "@thi.ng/transducers": "^5.1.1", - "@thi.ng/vectors": "^2.3.2" + "@thi.ng/api": "^6.0.0", + "@thi.ng/arrays": "^0.1.5", + "@thi.ng/checks": "^2.1.4", + "@thi.ng/compose": "^1.2.1", + "@thi.ng/defmulti": "^1.0.5", + "@thi.ng/equiv": "^1.0.4", + "@thi.ng/errors": "^1.0.4", + "@thi.ng/geom-api": "^0.1.10", + "@thi.ng/geom-arc": "^0.1.11", + "@thi.ng/geom-clip": "^0.0.13", + "@thi.ng/geom-closest-point": "^0.1.11", + "@thi.ng/geom-hull": "^0.0.13", + "@thi.ng/geom-isec": "^0.1.11", + "@thi.ng/geom-poly-utils": "^0.1.11", + "@thi.ng/geom-resample": "^0.1.11", + "@thi.ng/geom-splines": "^0.1.11", + "@thi.ng/geom-subdiv-curve": "^0.1.10", + "@thi.ng/geom-tessellate": "^0.1.11", + "@thi.ng/hiccup": "^3.1.5", + "@thi.ng/hiccup-svg": "^3.1.16", + "@thi.ng/math": "^1.2.1", + "@thi.ng/matrices": "^0.1.14", + "@thi.ng/random": "^1.1.3", + "@thi.ng/transducers": "^5.3.1", + "@thi.ng/vectors": "^2.5.0" }, "keywords": [ "2D", diff --git a/packages/hdom-canvas/CHANGELOG.md b/packages/hdom-canvas/CHANGELOG.md index 84ec9ed6eb..da5871fe33 100644 --- a/packages/hdom-canvas/CHANGELOG.md +++ b/packages/hdom-canvas/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [2.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-canvas@2.0.1...@thi.ng/hdom-canvas@2.0.2) (2019-03-01) +## [2.0.9](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-canvas@2.0.8...@thi.ng/hdom-canvas@2.0.9) (2019-03-28) **Note:** Version bump only for package @thi.ng/hdom-canvas @@ -11,12 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [2.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-canvas@2.0.0...@thi.ng/hdom-canvas@2.0.1) (2019-02-28) - -**Note:** Version bump only for package @thi.ng/hdom-canvas - - - # [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-canvas@1.1.6...@thi.ng/hdom-canvas@2.0.0) (2019-02-27) @@ -33,56 +27,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - - -## [1.1.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-canvas@1.1.5...@thi.ng/hdom-canvas@1.1.6) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/hdom-canvas - - - - - -## [1.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-canvas@1.1.4...@thi.ng/hdom-canvas@1.1.5) (2019-02-18) - -**Note:** Version bump only for package @thi.ng/hdom-canvas - - - - - -## [1.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-canvas@1.1.3...@thi.ng/hdom-canvas@1.1.4) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/hdom-canvas - - - - - -## [1.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-canvas@1.1.2...@thi.ng/hdom-canvas@1.1.3) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/hdom-canvas - - - - - -## [1.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-canvas@1.1.1...@thi.ng/hdom-canvas@1.1.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/hdom-canvas - - - - - -## [1.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-canvas@1.1.0...@thi.ng/hdom-canvas@1.1.1) (2019-01-31) - -**Note:** Version bump only for package @thi.ng/hdom-canvas - - - - - # [1.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-canvas@1.0.1...@thi.ng/hdom-canvas@1.1.0) (2019-01-22) @@ -92,16 +36,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-canvas@1.0.0...@thi.ng/hdom-canvas@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/hdom-canvas - - - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-canvas@0.1.20...@thi.ng/hdom-canvas@1.0.0) (2019-01-21) diff --git a/packages/hdom-canvas/package.json b/packages/hdom-canvas/package.json index 67a1d5885a..c93d194f2c 100644 --- a/packages/hdom-canvas/package.json +++ b/packages/hdom-canvas/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/hdom-canvas", - "version": "2.0.2", + "version": "2.0.9", "description": "Declarative canvas scenegraph & visualization for @thi.ng/hdom", "module": "./index.js", "main": "./lib/index.js", @@ -32,11 +32,11 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/checks": "^2.1.1", - "@thi.ng/color": "^0.1.8", - "@thi.ng/diff": "^3.0.3", - "@thi.ng/hdom": "^7.1.2" + "@thi.ng/api": "^6.0.0", + "@thi.ng/checks": "^2.1.4", + "@thi.ng/color": "^0.1.15", + "@thi.ng/diff": "^3.0.5", + "@thi.ng/hdom": "^7.2.1" }, "keywords": [ "ES6", diff --git a/packages/hdom-canvas/src/index.ts b/packages/hdom-canvas/src/index.ts index 0979223248..f0ae748493 100644 --- a/packages/hdom-canvas/src/index.ts +++ b/packages/hdom-canvas/src/index.ts @@ -1,4 +1,4 @@ -import { IObjectOf } from "@thi.ng/api"; +import { IObjectOf, NO_OP } from "@thi.ng/api"; import { isArray, isArrayLike, @@ -8,7 +8,12 @@ import { } from "@thi.ng/checks"; import { asCSS, ColorMode, ReadonlyColor } from "@thi.ng/color"; import { diffArray, DiffMode } from "@thi.ng/diff"; -import { equiv, HDOMImplementation, HDOMOpts, releaseTree } from "@thi.ng/hdom"; +import { + equiv, + HDOMImplementation, + HDOMOpts, + releaseTree +} from "@thi.ng/hdom"; interface DrawState { attribs: IObjectOf; @@ -109,7 +114,7 @@ const CTX_ATTRIBS = { * @param shapes shape components */ export const canvas = { - render: (_, attribs, ...body: any[]) => { + render(_, attribs, ...body: any[]) { const cattribs = { ...attribs }; delete cattribs.__diff; delete cattribs.__normalize; @@ -223,16 +228,14 @@ export const diffTree = ( } }; -const NOOP = () => {}; - export const IMPL: HDOMImplementation = { createTree, normalizeTree, diffTree, - hydrateTree: NOOP, - getElementById: NOOP, - createElement: NOOP, - createTextElement: NOOP + hydrateTree: NO_OP, + getElementById: NO_OP, + createElement: NO_OP, + createTextElement: NO_OP }; const walk = ( @@ -418,12 +421,12 @@ const resolveColor = (state: DrawState, v: any) => ? state.grads[v.substr(1)] : v : isArrayLike(v) - ? isNumber((v).mode) - ? asCSS(v) - : asCSS(v, ColorMode.RGBA) - : isNumber(v) - ? asCSS(v, ColorMode.INT32) - : v; + ? isNumber((v).mode) + ? asCSS(v) + : asCSS(v, ColorMode.RGBA) + : isNumber(v) + ? asCSS(v, ColorMode.INT32) + : v; const applyTransform = ( ctx: CanvasRenderingContext2D, diff --git a/packages/hdom-components/CHANGELOG.md b/packages/hdom-components/CHANGELOG.md index ddc4f7102b..75d3c14e93 100644 --- a/packages/hdom-components/CHANGELOG.md +++ b/packages/hdom-components/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [3.0.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-components@3.0.6...@thi.ng/hdom-components@3.0.7) (2019-03-01) +## [3.0.13](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-components@3.0.12...@thi.ng/hdom-components@3.0.13) (2019-03-28) **Note:** Version bump only for package @thi.ng/hdom-components @@ -11,52 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [3.0.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-components@3.0.5...@thi.ng/hdom-components@3.0.6) (2019-02-26) - -**Note:** Version bump only for package @thi.ng/hdom-components - - - - - -## [3.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-components@3.0.4...@thi.ng/hdom-components@3.0.5) (2019-02-15) - -**Note:** Version bump only for package @thi.ng/hdom-components - - - - - -## [3.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-components@3.0.3...@thi.ng/hdom-components@3.0.4) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/hdom-components - - - - - -## [3.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-components@3.0.2...@thi.ng/hdom-components@3.0.3) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/hdom-components - - - - - -## [3.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-components@3.0.1...@thi.ng/hdom-components@3.0.2) (2019-01-31) - -**Note:** Version bump only for package @thi.ng/hdom-components - - - - - -## [3.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-components@3.0.0...@thi.ng/hdom-components@3.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/hdom-components - - - # [3.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-components@2.4.6...@thi.ng/hdom-components@3.0.0) (2019-01-21) diff --git a/packages/hdom-components/package.json b/packages/hdom-components/package.json index c664fc7644..b3af3ac8bd 100644 --- a/packages/hdom-components/package.json +++ b/packages/hdom-components/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/hdom-components", - "version": "3.0.7", + "version": "3.0.13", "description": "Raw, skinnable UI & SVG components for @thi.ng/hdom", "module": "./index.js", "main": "./lib/index.js", @@ -32,11 +32,11 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/checks": "^2.1.1", - "@thi.ng/math": "^1.1.1", - "@thi.ng/transducers": "^5.1.1", - "@thi.ng/transducers-stats": "^1.0.7", + "@thi.ng/api": "^6.0.0", + "@thi.ng/checks": "^2.1.4", + "@thi.ng/math": "^1.2.1", + "@thi.ng/transducers": "^5.3.1", + "@thi.ng/transducers-stats": "^1.0.13", "@types/webgl2": "^0.0.4" }, "keywords": [ diff --git a/packages/hdom-components/src/canvas.ts b/packages/hdom-components/src/canvas.ts index 865343041d..394b7a0f1e 100644 --- a/packages/hdom-components/src/canvas.ts +++ b/packages/hdom-components/src/canvas.ts @@ -20,28 +20,23 @@ export interface CanvasHandlers { /** * user init handler (called only once when canvas first) */ - init: (el: HTMLCanvasElement, ctx: T, hctx?: any, ...args: any[]) => void; + init(el: HTMLCanvasElement, ctx: T, hctx?: any, ...args: any[]): void; /** * update handler (called for each hdom update iteration) */ - update: ( + update( el: HTMLCanvasElement, ctx: T, hctx?: any, time?: number, frame?: number, ...args: any[] - ) => void; + ): void; /** * release handler (called only once when canvas element is removed * from DOM) */ - release: ( - el: HTMLCanvasElement, - ctx: T, - hctx?: any, - ...args: any[] - ) => void; + release(el: HTMLCanvasElement, ctx: T, hctx?: any, ...args: any[]): void; } /** @@ -92,7 +87,7 @@ const _canvas = ( * * ``` * const glcanvas = canvasWebGL({ - * render: (canv, gl, hctx, time, frame, ...args) => { + * render(canv, gl, hctx, time, frame, ...args) { * const col = 0.5 + 0.5 * Math.sin(time); * gl.clearColor(col, col, col, 1); * } diff --git a/packages/hdom-components/src/pager.ts b/packages/hdom-components/src/pager.ts index e92e7cd168..0c95a72ced 100644 --- a/packages/hdom-components/src/pager.ts +++ b/packages/hdom-components/src/pager.ts @@ -26,36 +26,36 @@ export interface PagerOpts { * one-based. The currently active page ID is only provided for * special highlighting cases (optional). */ - button: ( + button( page: number, curr: number, max: number, label: any, disabled: boolean - ) => any; + ): any; /** * Pager root component function. Receives all 3 button groups as * arguments. Optional. Default: `["div.pager", ...body]` */ - root: (ctx: any, ...body: any[]) => any; + root(ctx: any, ...body: any[]): any; /** * Component function to provide wrapper for the first / prev nav * button group. The `first` / `prev` args are button components. * Optional. Default: `["div.pager-prev", first, prev]` */ - groupPrev: (ctx: any, first: any, prev: any) => any; + groupPrev(ctx: any, first: any, prev: any): any; /** * Component function to provide wrapper for the page buttons group. * The `buttons` argument is an array of button components. * Optional. Default: `["div.pager-pages", ...buttons]` */ - groupPages: (ctx: any, buttons: any[]) => any; + groupPages(ctx: any, buttons: any[]): any; /** * Component function to provide wrapper for the next / last nav * button group. The `next` / `last` args are button components. * Optional. Default: `["div.pager-next", next, last]` */ - groupNext: (ctx: any, next: any, last: any) => any; + groupNext(ctx: any, next: any, last: any): any; /** * Page increment for prev / next page buttons. Default: 1 */ diff --git a/packages/hdom-mock/CHANGELOG.md b/packages/hdom-mock/CHANGELOG.md index 4a1abfc226..dcd946c414 100644 --- a/packages/hdom-mock/CHANGELOG.md +++ b/packages/hdom-mock/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [1.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-mock@1.0.4...@thi.ng/hdom-mock@1.0.5) (2019-03-01) +## [1.0.9](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-mock@1.0.8...@thi.ng/hdom-mock@1.0.9) (2019-03-28) **Note:** Version bump only for package @thi.ng/hdom-mock @@ -11,36 +11,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-mock@1.0.3...@thi.ng/hdom-mock@1.0.4) (2019-02-18) - -**Note:** Version bump only for package @thi.ng/hdom-mock - - - - - -## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-mock@1.0.2...@thi.ng/hdom-mock@1.0.3) (2019-02-10) - -**Note:** Version bump only for package @thi.ng/hdom-mock - - - - - -## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-mock@1.0.1...@thi.ng/hdom-mock@1.0.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/hdom-mock - - - - - -## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-mock@1.0.0...@thi.ng/hdom-mock@1.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/hdom-mock - - - # [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom-mock@0.1.5...@thi.ng/hdom-mock@1.0.0) (2019-01-21) diff --git a/packages/hdom-mock/package.json b/packages/hdom-mock/package.json index 472832a2eb..3243cf8c9d 100644 --- a/packages/hdom-mock/package.json +++ b/packages/hdom-mock/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/hdom-mock", - "version": "1.0.5", + "version": "1.0.9", "description": "Mock base implementation for @thi.ng/hdom API", "module": "./index.js", "main": "./lib/index.js", @@ -32,9 +32,9 @@ "typescript": "^3.2.2" }, "dependencies": { - "@thi.ng/api": "^5.0.3", - "@thi.ng/checks": "^2.1.1", - "@thi.ng/hdom": "^7.1.2" + "@thi.ng/api": "^6.0.0", + "@thi.ng/checks": "^2.1.4", + "@thi.ng/hdom": "^7.2.1" }, "keywords": [ "ES6", diff --git a/packages/hdom/CHANGELOG.md b/packages/hdom/CHANGELOG.md index 9d98f40618..45f3308400 100644 --- a/packages/hdom/CHANGELOG.md +++ b/packages/hdom/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## [7.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom@7.1.1...@thi.ng/hdom@7.1.2) (2019-03-01) +## [7.2.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom@7.2.0...@thi.ng/hdom@7.2.1) (2019-03-28) **Note:** Version bump only for package @thi.ng/hdom @@ -11,11 +11,12 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [7.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom@7.1.0...@thi.ng/hdom@7.1.1) (2019-02-18) +# [7.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom@7.1.4...@thi.ng/hdom@7.2.0) (2019-03-18) -**Note:** Version bump only for package @thi.ng/hdom +### Features +* **hdom:** support more input el types in updateValueAttrib() ([8813344](https://github.com/thi-ng/umbrella/commit/8813344)) @@ -33,24 +34,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - - -## [7.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom@7.0.1...@thi.ng/hdom@7.0.2) (2019-02-05) - -**Note:** Version bump only for package @thi.ng/hdom - - - - - -## [7.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom@7.0.0...@thi.ng/hdom@7.0.1) (2019-01-21) - -**Note:** Version bump only for package @thi.ng/hdom - - - - - # [7.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/hdom@6.1.0...@thi.ng/hdom@7.0.0) (2019-01-21) diff --git a/packages/hdom/README.md b/packages/hdom/README.md index 3b9b9de335..e582589682 100644 --- a/packages/hdom/README.md +++ b/packages/hdom/README.md @@ -49,6 +49,7 @@ This project is part of the - [createTree()](#createtree) - [hydrateTree()](#hydratetree) - [User context](#user-context) + - [`value` attribute handling](#value-attribute-handling) - [Behavior control attributes](#behavior-control-attributes) - [Benchmarks](#benchmarks) - [Authors](#authors) @@ -1162,42 +1163,54 @@ const app = [ start(app, { ctx }); ``` +### `value` attribute handling + +hdom automatically saves & restores the cursor position when updating +the `value` attribute of an `` element w/ text content or +`