Class: Genfun

Genfun

new Genfun(opts) → {function}

Creates generic functions capable of multiple dispatch across several arguments. The generic function returned by this constructor is functionally identical to a standard function: it can be called, applied, and receives the expected binding for this when appropriate.

Parameters:
Name Type Argument Description
opts object <optional>

Options used when initializing the genfun.

Source:
Returns:

New generic function.

Type
function

Methods

<static> addMethod(genfun, selector, methodFunction)

Defines a method on a generic function.

Parameters:
Name Type Description
genfun Genfun

Genfun instance to add the method to.

selector Array-like

Selector array for dispatching the method.

methodFunction function

Function to execute when the method successfully dispatches.

Source:

<static> noApplicableMethod(genfun, newthis, callArgs)

This generic function is called when genfun has been called and no applicable method was found. The default method throws an Error.

Parameters:
Name Type Description
genfun Genfun

Generic function instance that was called.

newthis *

value of this the genfun was called with.

callArgs Array

Arguments the genfun was called with.

Source:

<static> removeMethod(genfun, selector)

Removes a previously-defined method on genfun that matches selector exactly.

Parameters:
Name Type Description
genfun Genfun

Genfun to remove a method from.

selector Array-like

Objects to match on when finding a method to remove.

Source: