new FunctionReflector()

Wrapper class around the js-function-reflector library.

Description

Wrapper class around the js-function-reflector library.

Properties
Name Type Description
hashSeed number

Seed for murmur hashing, positive integer.

functionMap Map.<number, Object.<String, *>>

Maps hashes to parsed functions, this acts as a cache to avoid parsing the same functions over and over.

Methods


forFunction( func [, scope ] ) → {Object.<String, *>}

Returns the result of parsing the given function.

Description

Returns the result of parsing the given function.

Parameters
Name Type Attributes Description
func function | string

Function to be parsed.

scope Object.<String, *> <optional>

A scope in which to parse the function. Currently not fully supported, since the parsed result is stored using the hash of the function regardless of the scope -- it works if you make sure to pass the correct scope the first time and if the scope never changes.

Returns

The parsed function, see the js-function-reflector documentation for more information on the structure of this object.


getArgumentInjectionPosition( func, args ) → {number}

Returns the 0-based position of the last argument of the given function, if the argument is destructuring and there is no value for the argument in the given args array.

Description

Returns the 0-based position of the last argument of the given function, if the argument is destructuring and there is no value for the argument in the given args array.

This is used to dynamically check if a function (e.g., event handler) expects a destructuring argument to be injected (e.g., metadata).

Note that you may have to fill the args array with undefined entries up to the injection point.

Parameters
Name Type Description
func function | string

The function to be inspected.

args Array

Arguments to the function, used to determine if there are arguments missing (i.e. if the function expects more parameters than were given).

Returns

0-based position of the last argument if the function seems to expect argument injection, or -1 otherwise.