Generic
import { Generic } from "@fed1/jsos";
A proxy object that creates and assigns new multimethods (generic functions).
Usage
const { multi } = Generic;
const { multi } = Generic(options);
Parameters
# | Parameter | Required? | Type |
---|---|---|---|
1 | options | no | JSObject |
1. options
An optional JSObject
that configures the multimethod. It has these keys:
Type | Key | See |
---|---|---|
JSFunction |
combinator | Method Combinators |
Union{JSFunction,JSArray<Union{JSFunction,JSString}>} |
dispatchers | Multimethod Dispatch |
JSArray |
enforce | Multimethod Contracts |
TType |
expect | Multimethod Contracts |
JSArray |
scoring | Multimethod Score |
Return value
A TGeneric
that can be used like any regular JSFunction
. If it is called
and no matching primary method is found, an error is thrown.
Version History
Feature | Since version |
---|---|
Generic | 1.0 |
See also
- API: def
- Manual: Multimethods