@thi.ng/defmulti
Advanced tools
Comparing version 2.1.45 to 3.0.0
11
api.d.ts
@@ -79,6 +79,13 @@ import type { Fn, Fn2, Fn3, Fn4, Fn5, Fn6, Fn7, Fn8, FnAny, IObjectOf, Pair } from "@thi.ng/api"; | ||
/** | ||
* Returns a set of all registered dispatch values. | ||
* Returns a Map of all registered dispatch values (incl. rels) and their | ||
* implementations. | ||
*/ | ||
impls(): Set<PropertyKey>; | ||
impls(): Map<PropertyKey, I>; | ||
/** | ||
* Returns the actual implementation for given dispatch value or undefined | ||
* if no such implementation (and no default impl) exists. Takes all | ||
* dispatch relationships into account. | ||
*/ | ||
implForID(id: PropertyKey): I | undefined; | ||
/** | ||
* Updates dispatch hierarchy by declaring dispatch value `id` to | ||
@@ -85,0 +92,0 @@ * delegate to `parent`'s implementation. I.e. in terms of dispatch |
# Change Log | ||
- **Last updated**: 2023-09-06T13:36:28Z | ||
- **Last updated**: 2023-09-15T12:33:37Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -12,2 +12,11 @@ | ||
# [3.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/defmulti@3.0.0) (2023-09-15) | ||
#### 🛑 Breaking changes | ||
- update .impls() ([db48f57](https://github.com/thi-ng/umbrella/commit/db48f57)) | ||
- BREAKING CHANGE: update .impls() to return a Map of dispatch values and | ||
their implementations | ||
- update tests | ||
### [2.1.39](https://github.com/thi-ng/umbrella/tree/@thi.ng/defmulti@2.1.39) (2023-08-04) | ||
@@ -14,0 +23,0 @@ |
@@ -52,9 +52,17 @@ import { unsupported } from "@thi.ng/errors/unsupported"; | ||
fn.impls = () => { | ||
const res = new Set(Object.keys(impls)); | ||
const res = new Map(); | ||
for (let id in impls) { | ||
res.set(id, impls[id]); | ||
} | ||
for (let id in rels) { | ||
findImpl(impls, rels, id) && res.add(id); | ||
const impl = findImpl(impls, rels, id); | ||
if (impl) | ||
res.set(id, impl); | ||
} | ||
impls[DEFAULT] && res.add(DEFAULT); | ||
if (impls[DEFAULT]) { | ||
res.set(DEFAULT, impls[DEFAULT]); | ||
} | ||
return res; | ||
}; | ||
fn.implForID = (id) => impls[String(id)] || findImpl(impls, rels, id) || impls[DEFAULT]; | ||
fn.rels = () => rels; | ||
@@ -61,0 +69,0 @@ fn.parents = (id) => rels[id]; |
{ | ||
"name": "@thi.ng/defmulti", | ||
"version": "2.1.45", | ||
"version": "3.0.0", | ||
"description": "Dynamic, extensible multiple dispatch via user supplied dispatch function.", | ||
@@ -93,3 +93,3 @@ "type": "module", | ||
}, | ||
"gitHead": "1bbef970bab7f7def0700e587cf0471e1e1ef9f3\n" | ||
"gitHead": "b2ef5a1b8932d067af4ec2fc7da03d59d6868dc7\n" | ||
} |
@@ -64,3 +64,3 @@ <!-- This file is generated - DO NOT EDIT! --> | ||
Package sizes (brotli'd, pre-treeshake): ESM: 781 bytes | ||
Package sizes (brotli'd, pre-treeshake): ESM: 818 bytes | ||
@@ -81,7 +81,8 @@ ## Dependencies | ||
| Screenshot | Description | Live demo | Source | | ||
|:---------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------|:----------------------------------------------------------|:---------------------------------------------------------------------------------------| | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/lispy-repl.png" width="240"/> | Browser REPL for a Lispy S-expression based mini language | [Demo](https://demo.thi.ng/umbrella/lispy-repl/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/lispy-repl) | | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rstream-spreadsheet.png" width="240"/> | rstream based spreadsheet w/ S-expression formula DSL | [Demo](https://demo.thi.ng/umbrella/rstream-spreadsheet/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rstream-spreadsheet) | | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/xml-converter.png" width="240"/> | XML/HTML/SVG to hiccup/JS conversion | [Demo](https://demo.thi.ng/umbrella/xml-converter/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/xml-converter) | | ||
| Screenshot | Description | Live demo | Source | | ||
|:---------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------|:----------------------------------------------------------|:---------------------------------------------------------------------------------------| | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/lispy-repl.png" width="240"/> | Browser REPL for a Lispy S-expression based mini language | [Demo](https://demo.thi.ng/umbrella/lispy-repl/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/lispy-repl) | | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/mastodon-feed.jpg" width="240"/> | Mastodon API feed reader with support for different media types, fullscreen media modal, HTML rewriting | [Demo](https://demo.thi.ng/umbrella/mastodon-feed/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/mastodon-feed) | | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rstream-spreadsheet.png" width="240"/> | rstream based spreadsheet w/ S-expression formula DSL | [Demo](https://demo.thi.ng/umbrella/rstream-spreadsheet/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rstream-spreadsheet) | | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/xml-converter.png" width="240"/> | XML/HTML/SVG to hiccup/JS conversion | [Demo](https://demo.thi.ng/umbrella/xml-converter/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/xml-converter) | | ||
@@ -88,0 +89,0 @@ ## API |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60810
560
402