linkedfunclist
A linked list whose elements can store functions.
Installation
npm install linkedfunclist
Documentation
Please see Docs.
Contributing Guidelines
- Specification outline (see Docs > Specification) must be updated to include new functionality.
- All tests must pass and have descriptive tags that make it easy to tell which areas of the specification they satisfy e.g.
4.e.A
. - Code must adhere to JavaScript Standard Style.
- New code must include ESDoc documentation.
- Build must pass TravisCI.
Thanks.
License
Author
Specification
This module exports a single class, LinkedFuncList
.
Instance Properties:
1. next
- a. is
null
by default - b. can only have a value of
null
, or- an instance of
LinkedFuncList
, self-inclusive
2. func
- a. is
null
by default - b. can only have a value of
null
, or- an
object
of typefunction
3. [Symbol.iterator]
- a. returns a
generator function
that produces the ordered unique set ofnext
properties- A. starting with this
LinkedFuncList
instance, - B. continuing with all
LinkedFuncList
instances linked vianext
, and - C. terminating before any
next
whose value is- i.
null
, or - j. this (starting)
LinkedFuncList
instance.
- i.
- A. starting with this
4. chainCall
- a. is an
asynchronous function
that accepts anystart
argument, anyend
argument - b. returns a
Promise
corresponding to the ordered set of chained calls to uniquefunc
properties of thenext
properties of theLinkedFuncList
where- A. the starting function recieves the
start
argument - B. each function called in the
Promise
recieves the result of the previous function in the chain - C. the functions are called with their
this
values set to thisLinkedFuncList
instance (the initiator of the traversal - D. errors thrown in the functions cause the
Promise
to reject - E. the order of the calls to the functions corresponds to the order of iteration produced by
this[Symbol.iterator]
even if the functions are asynchronous - F. any
func
properties having non-function values will be replaced with a passthrough function that preserves the recieved value supplied to it
- A. the starting function recieves the
- c. if the
end
argument is afunction
, it is called at the end of the chain's execution with the chain's result
5. callAll
- a. is an
asynchronous function
that accepts anystart
argument, - b. returns a
Promise
corresponding to the ordered set of calls to uniquefunc
properties of thenext
properties of theLinkedFuncList
where- A. all functions recieve the
start
argument - B. the functions are called with their
this
values set to thisLinkedFuncList
instance (the initiator of the traversal - C. errors thrown in the functions cause the
Promise
to reject - D. any
func
properties having non-function values will be replaced with a passthrough function that preserves the recieved value supplied to it
- A. all functions recieve the
6. link
- a. is a
function
that accepts any number of arguments - b. substitutes passthrough functions for arguments that are not
function
objects, orLinkedFuncList
instances
- c. creates a chained list of
LinkedFuncList
instances where- A. the first element in the chain is this instance (the caller)
- B. the order of the elements in the chain correspond to the order of arguments supplied to the
link
function - C.
function
-valued arguments are replaced with newLinkedFuncList
instances whosefunc
properties correspond to the argument being replaced
7. length
- a. is a
number
always greater than 0 - b. reveals the number of
LinkedFuncList
instances in this list, including this current instance