Socket
Socket
Sign inDemoInstall

@thi.ng/defmulti

Package Overview
Dependencies
Maintainers
1
Versions
183
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/defmulti - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [0.7.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/defmulti@0.6.0...@thi.ng/defmulti@0.7.0) (2019-01-02)
### Features
* **defmulti:** add opt fallback arg for defmultiN(), update docs ([1d29153](https://github.com/thi-ng/umbrella/commit/1d29153))
# [0.6.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/defmulti@0.5.1...@thi.ng/defmulti@0.6.0) (2019-01-01)

@@ -8,0 +19,0 @@

10

index.d.ts

@@ -127,5 +127,6 @@ import { IObjectOf } from "@thi.ng/api/api";

* the function is called. Internally uses `defmulti`, so new arities
* can be dynamically added (or removed) at a later time. `defmultiN`
* also registers a `DEFAULT` implementation which simply throws an
* `IllegalArityError` when invoked.
* can be dynamically added (or removed) at a later time. If no
* `fallback` is provided, `defmultiN` also registers a `DEFAULT`
* implementation which simply throws an `IllegalArityError` when
* invoked.
*

@@ -157,5 +158,6 @@ * **Note:** Unlike `defmulti` no argument type checking is supported,

* @param impls
* @param fallback
*/
export declare function defmultiN<T>(impls: {
[id: number]: Implementation<T>;
}): MultiFn<T>;
}, fallback?: Implementation<T>): MultiFn<T>;

12

index.js

@@ -77,5 +77,6 @@ "use strict";

* the function is called. Internally uses `defmulti`, so new arities
* can be dynamically added (or removed) at a later time. `defmultiN`
* also registers a `DEFAULT` implementation which simply throws an
* `IllegalArityError` when invoked.
* can be dynamically added (or removed) at a later time. If no
* `fallback` is provided, `defmultiN` also registers a `DEFAULT`
* implementation which simply throws an `IllegalArityError` when
* invoked.
*

@@ -107,6 +108,7 @@ * **Note:** Unlike `defmulti` no argument type checking is supported,

* @param impls
* @param fallback
*/
function defmultiN(impls) {
function defmultiN(impls, fallback) {
const fn = defmulti((...args) => args.length);
fn.add(exports.DEFAULT, (...args) => illegal_arity_1.illegalArity(args.length));
fn.add(exports.DEFAULT, fallback || ((...args) => illegal_arity_1.illegalArity(args.length)));
for (let id in impls) {

@@ -113,0 +115,0 @@ fn.add(id, impls[id]);

{
"name": "@thi.ng/defmulti",
"version": "0.6.0",
"version": "0.7.0",
"description": "Dynamically extensible multiple dispatch via user supplied dispatch function.",

@@ -41,3 +41,3 @@ "main": "./index.js",

},
"gitHead": "7729d993a27cc0cc69cb076c1070ad4e8eccd06a"
"gitHead": "26a29cf15b7817101ce53bc1aa903cc2f88f83c8"
}

@@ -113,5 +113,5 @@ # @thi.ng/defmulti

is called. Internally uses `defmulti`, so new arities can be dynamically
added (or removed) at a later time. `defmultiN` also registers a
`DEFAULT` implementation which simply throws an `IllegalArityError` when
invoked.
added (or removed) at a later time. If no `fallback` is provided,
`defmultiN` also registers a `DEFAULT` implementation which simply
throws an `IllegalArityError` when invoked.

@@ -118,0 +118,0 @@ **Note:** Unlike `defmulti` no argument type checking is supported,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc