@thi.ng/defmulti
Advanced tools
Comparing version 3.0.30 to 3.0.31
# Change Log | ||
- **Last updated**: 2024-03-07T20:40:47Z | ||
- **Last updated**: 2024-03-13T14:04:31Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -5,0 +5,0 @@ |
@@ -18,3 +18,3 @@ import type { Implementation } from "./api.js"; | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/defmulti-n.ts | ||
* import { defmultiN } from "@thi.ng/defmulti"; | ||
@@ -28,13 +28,17 @@ * | ||
* | ||
* foo(); | ||
* console.log(foo()); | ||
* // zero | ||
* foo(23); | ||
* | ||
* console.log(foo(23)); | ||
* // one: 23 | ||
* foo(1, 2, 3); | ||
* | ||
* console.log(foo(1, 2, 3)); | ||
* // three: 1, 2, 3 | ||
* foo(1, 2); | ||
* | ||
* console.log(foo(1, 2)); | ||
* // Error: illegal arity: 2 | ||
* | ||
* foo.add(2, (x, y) => `two: ${x}, ${y}`); | ||
* foo(1, 2); | ||
* | ||
* console.log(foo(1, 2)); | ||
* // two: 1, 2 | ||
@@ -48,3 +52,3 @@ * ``` | ||
[id: number]: Implementation<T>; | ||
}, fallback?: Implementation<T> | undefined) => import("./api.js").MultiFn<T>; | ||
}, fallback?: Implementation<T>) => import("./api.js").MultiFn<T>; | ||
//# sourceMappingURL=defmulti-n.d.ts.map |
@@ -19,9 +19,9 @@ import type { IObjectOf } from "@thi.ng/api"; | ||
* @example | ||
* ```ts | ||
* ```ts tangle:../export/implementations.ts | ||
* import { defmulti, implementations } from "@thi.ng/defmulti"; | ||
* | ||
* foo = defmulti((x) => x.id); | ||
* bar = defmulti((x) => x.id); | ||
* bax = defmulti((x) => x.id); | ||
* baz = defmulti((x) => x.id); | ||
* const foo = defmulti((x) => x.id); | ||
* const bar = defmulti((x) => x.id); | ||
* const bax = defmulti((x) => x.id); | ||
* const baz = defmulti((x) => x.id); | ||
* | ||
@@ -48,11 +48,20 @@ * // define impls for dispatch value `a` | ||
* baz.add("c", (x) => `baz: ${x.id}`); | ||
* | ||
* // use "c" impl for "b" | ||
* baz.isa("b", "c"); | ||
* | ||
* foo({ id: "a", val: "alice" }); // "foo: alice" | ||
* bar({ id: "a", val: "alice" }); // "bar: ALICE" | ||
* bax({ id: "a", val: "alice" }); // "bax: a" | ||
* baz({ id: "a", val: "alice" }); // "baz: a" | ||
* console.log(foo({ id: "a", val: "alice" })); | ||
* // "foo: alice" | ||
* | ||
* baz.impls(); // Set { "c", "a", "b" } | ||
* console.log(bar({ id: "a", val: "alice" })); | ||
* // "bar: ALICE" | ||
* | ||
* console.log(bax({ id: "a", val: "alice" })); | ||
* // "bax: a" | ||
* | ||
* console.log(baz({ id: "a", val: "alice" })); | ||
* // "baz: a" | ||
* | ||
* console.log([...baz.impls().keys()]); | ||
* // Set { "c", "a", "b" } | ||
* ``` | ||
@@ -59,0 +68,0 @@ * |
{ | ||
"name": "@thi.ng/defmulti", | ||
"version": "3.0.30", | ||
"version": "3.0.31", | ||
"description": "Dynamic, extensible multiple dispatch via user supplied dispatch function.", | ||
@@ -39,12 +39,12 @@ "type": "module", | ||
"dependencies": { | ||
"@thi.ng/api": "^8.9.29", | ||
"@thi.ng/errors": "^2.4.20", | ||
"@thi.ng/logger": "^3.0.5" | ||
"@thi.ng/api": "^8.9.30", | ||
"@thi.ng/errors": "^2.5.0", | ||
"@thi.ng/logger": "^3.0.6" | ||
}, | ||
"devDependencies": { | ||
"@microsoft/api-extractor": "^7.40.1", | ||
"esbuild": "^0.20.0", | ||
"@microsoft/api-extractor": "^7.42.3", | ||
"esbuild": "^0.20.1", | ||
"rimraf": "^5.0.5", | ||
"typedoc": "^0.25.7", | ||
"typescript": "^5.3.3" | ||
"typedoc": "^0.25.12", | ||
"typescript": "^5.4.2" | ||
}, | ||
@@ -95,3 +95,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "69100942474942f7446ac645d59d91e7dfc352f9\n" | ||
"gitHead": "7f3fcbd6c0462b0ce45afa141fe163d1f297fd51\n" | ||
} |
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
59313
479
Updated@thi.ng/api@^8.9.30
Updated@thi.ng/errors@^2.5.0
Updated@thi.ng/logger@^3.0.6