collect-your-stuff v1.2.0
Collect your stuff (and go)!
Data allocation and manipulation.
Modules
Classes
Members
Constants
Functions
collect-your-stuff
All of the collections available.
Version: 1.0.0
Author: Joshua Heagle joshuaheagle@gmail.com
collect-your-stuff~collectYourStuff
All methods exported from this module are encapsulated within collect-your-stuff.
Kind: inner constant of collect-your-stuff
TreeLinkerIterator
Class TreeLinkerIterator returns the next value taking a left-first approach down a tree.
Kind: global class
Runnable
Identify a class that can be run.
Kind: global class
- Runnable
- new Runnable(data)
- instance
- static
- .isRunnable(thing) ⇒ boolean
new Runnable(data)
Instantiate a Runnable class.
Param | Type |
---|---|
data | * |
runnable.task ⇒ function
Retrieve the data which should be formed as a task.
Kind: instance property of Runnable
runnable.run() ⇒ *
Run the runnable task.
Kind: instance method of Runnable
Runnable.isRunnable(thing) ⇒ boolean
Check if a given thing is Runnable
Kind: static method of Runnable
Param | Type |
---|---|
thing | * |
LinkerIterator
Class LinkerIterator returns the next value when using linkers of linked type lists.
Kind: global class
DoubleLinkerIterator
Class DoubleLinkerIterator returns the next value when using linkers of linked type lists.
Kind: global class
ArrayIterator
Class ArrayIterator returns the next value when using elements of array type list.
Kind: global class
Stackable ⇐ Linker
Stackable represents a runnable entry in stack.
Kind: global class
Extends: Linker
- Stackable ⇐ Linker
- new Stackable([stackData])
- instance
- static
- .fromArray([values], [classType]) ⇒ Object
new Stackable(stackData)
Create a stackable item that can be used in a stack.
Param | Type | Default | Description |
---|---|---|---|
stackData | Object | {} | |
stackData.task | * | The data to be stored in this stackable | |
stackData.next | Stackable | null | The reference to the next stackable if any | |
stackData.ready | boolean | function | false | Indicate if the stackable is ready to run |
stackable.task ⇒ *
Retrieve the data which should be formed as a task.
Kind: instance property of Stackable
stackable.run() ⇒ *
Run the stacked task.
Kind: instance method of Stackable
Stackable.fromArray(values, classType) ⇒ Object
Convert an array into Stackable instances, return the head and tail Stackables.
Kind: static method of Stackable
Param | Type | Default | Description |
---|---|---|---|
values | Array | [] | Provide an array of data that will be converted to a chain of stackable linkers. |
classType | IsLinker | Stackable | Provide the type of IsLinker to use. |
Stack
Store a collection of items which can only be inserted and removed from the top.
Kind: global class
- Stack
- new Stack(stackedList, listClass, stackableClass)
- .empty() ⇒ boolean
- .top() ⇒ Stackable
- .pop() ⇒ Stackable | null
- .push(stackable)
- .remove() ⇒ Stackable | null
- .size() ⇒ number
new Stack(stackedList, listClass, stackableClass)
Instantiate the state with the starter stacked list.
Param | Type |
---|---|
stackedList | Iterable | LinkedList |
listClass | IsArrayable |
stackableClass | Stackable |
stack.empty() ⇒ boolean
Return true if the stack is empty (there are no tasks in the stacked list)
Kind: instance method of Stack
stack.top() ⇒ Stackable
Take a look at the next stacked task
Kind: instance method of Stack
stack.pop() ⇒ Stackable | null
Remove the next stacked task and return it.
Kind: instance method of Stack
stack.push(stackable)
Push a stackable task to the top of the stack.
Kind: instance method of Stack
Param | Type | Description |
---|---|---|
stackable | Stackable | * | Add a new stackable to the top of the stack |
stack.remove() ⇒ Stackable | null
Remove the next stacked task and return it.
Kind: instance method of Stack
stack.size() ⇒ number
Get the size of the current stack.
Kind: instance method of Stack
Queueable ⇐ Linker
Queueable represents a runnable entry in a queue.
Kind: global class
Extends: Linker
- Queueable ⇐ Linker
- new Queueable([queueableData])
- instance
- .isReady ⇒ boolean
- .task ⇒ *
- .markCompleted(completeResponse) ⇒ completeResponse
- .run() ⇒ completeResponse
- static
- .fromArray(values, [classType]) ⇒ Object
new Queueable(queueableData)
Create a queueable item that can be used in a queue.
Param | Type | Default | Description |
---|---|---|---|
queueableData | Object | {} | |
queueableData.task | * | The data to be stored in this queueable | |
queueableData.next | Queueable | null | The reference to the next queueable if any | |
queueableData.ready | boolean | function | false | Indicate if the queueable is ready to run |
queueable.isReady ⇒ boolean
Check ready state.
Kind: instance property of Queueable
queueable.task ⇒ *
Retrieve the data which should be formed as a task.
Kind: instance property of Queueable
queueable.markCompleted(completeResponse) ⇒ completeResponse
Set this queueable as completed.
Kind: instance method of Queueable
Param | Type | Default | Description |
---|---|---|---|
completeResponse | Object | ||
completeResponse.success | * | true | Indicate when the task failed (use false) or give a success message |
completeResponse.error | * | false | Indicate a task was error-free (use false) or give an error message |
completeResponse.context | * | Provide additional data in the response |
queueable.run() ⇒ completeResponse
Intend to run the queued task when it is ready. If ready, mark this task as running and run the task.
Kind: instance method of Queueable
Queueable.fromArray(values, classType) ⇒ Object
Convert an array into Queueable instances, return the head and tail Queueables.
Kind: static method of Queueable
Param | Type | Default | Description |
---|---|---|---|
values | Array | Provide an array of data that will be converted to a chain of queueable linkers. | |
classType | IsLinker | Queueable | Provide the type of IsLinker to use. |
Queue
Maintain a series of queued items.
Kind: global class
- Queue
- new Queue(queuedList, listClass, queueableClass)
- .dequeue() ⇒ completeResponse | *
- .empty() ⇒ boolean
- .enqueue(queueable)
- .peek() ⇒ Queueable
- .remove() ⇒ Queueable | null
- .size() ⇒ number
new Queue(queuedList, listClass, queueableClass)
Instantiate the queue with the given queue list.
Param | Type | Description |
---|---|---|
queuedList | Iterable | LinkedList | Give the list of queueables to start in this queue. |
listClass | IsArrayable | |
queueableClass | Queueable |
queue.dequeue() ⇒ completeResponse | *
Take a queued task from the front of the queue and run it if ready.
Kind: instance method of Queue
queue.empty() ⇒ boolean
Return true if the queue is empty (there are no tasks in the queue list)
Kind: instance method of Queue
queue.enqueue(queueable)
Add a queued task to the end of the queue
Kind: instance method of Queue
Param | Type | Description |
---|---|---|
queueable | Queueable | Add a new queueable to the end of the queue |
queue.peek() ⇒ Queueable
Take a look at the next queued task
Kind: instance method of Queue
queue.remove() ⇒ Queueable | null
Remove the next queued item and return it.
Kind: instance method of Queue
queue.size() ⇒ number
Get the length of the current queue.
Kind: instance method of Queue
TreeLinker ⇐ DoubleLinker
TreeLinker represents a node in a LinkedTreeList having a parent (or root) and child nodes.
Kind: global class
Extends: DoubleLinker
- TreeLinker ⇐ DoubleLinker
- new TreeLinker([settings], listClass)
- instance
- static
- .fromArray([values], [classType]) ⇒ Object
new TreeLinker(settings, listClass)
Create the new TreeLinker instance, provide the data and optionally set references for next, prev, parent, or children.
Param | Type | Default | Description |
---|---|---|---|
settings | Object | {} | |
settings.data | * | The data to be stored in this tree node | |
settings.next | TreeLinker | The reference to the next linker if any | |
settings.prev | TreeLinker | The reference to the previous linker if any | |
settings.children | LinkedTreeList | The references to child linkers if any | |
settings.parent | TreeLinker | The reference to a parent linker if any | |
listClass | IsArrayable.<IsTreeNode> | Give the type of list to use for storing the children |
treeLinker.childrenFromArray(children, listClass) ⇒ LinkedTreeList | null
Create the children for this tree from an array.
Kind: instance method of TreeLinker
Param | Type | Description |
---|---|---|
children | Array | null | Provide an array of data / linker references to be children of this tree node. |
listClass | IsArrayable.<IsTreeNode> | Give the type of list to use for storing the children |
TreeLinker.fromArray(values, classType) ⇒ Object
Convert an array into DoubleLinker instances, return the head and tail DoubleLinkers.
Kind: static method of TreeLinker
Param | Type | Default | Description |
---|---|---|---|
values | Array | [] | Provide an array of data that will be converted to a chain of tree-linkers. |
classType | IsTreeNode | TreeLinker | Provide the type of IsTreeNode to use. |
LinkedTreeList ⇐ DoublyLinkedList
LinkedTreeList represents a collection stored with a root and spreading in branching (tree) formation.
Kind: global class
Extends: DoublyLinkedList
- LinkedTreeList ⇐ DoublyLinkedList
- new LinkedTreeList()
- .list ⇒ TreeLinker
- .first ⇒ TreeLinker
- .last ⇒ TreeLinker
- .length ⇒ number
- .parent ⇒ TreeLinker
- .parent
- .rootParent ⇒ TreeLinker
- .initialize(initialList) ⇒ LinkedTreeList
- .setChildren(item, children)
- .insertAfter(node, newNode) ⇒ LinkedTreeList
- .insertBefore(node, newNode) ⇒ LinkedTreeList
- .append(node, after) ⇒ TreeLinker
- .prepend(node, before) ⇒ TreeLinker
- .remove(node) ⇒ TreeLinker
- .reset() ⇒ TreeLinker
- .item(index) ⇒ TreeLinker | null
- .forEach(callback, thisArg)
new LinkedTreeList()
Create the new LinkedTreeList instance, configure the list class.
linkedTreeList.list ⇒ TreeLinker
Retrieve a copy of the innerList used.
Kind: instance property of LinkedTreeList
Overrides: list
linkedTreeList.first ⇒ TreeLinker
Retrieve the first TreeLinker in the list.
Kind: instance property of LinkedTreeList
Overrides: first
linkedTreeList.last ⇒ TreeLinker
Retrieve the last TreeLinker in the list.
Kind: instance property of LinkedTreeList
Overrides: last
linkedTreeList.length ⇒ number
Return the length of the list.
Kind: instance property of LinkedTreeList
Overrides: length
linkedTreeList.parent ⇒ TreeLinker
Get the parent of this tree list.
Kind: instance property of LinkedTreeList
linkedTreeList.parent
Set the parent of this tree list
Kind: instance property of LinkedTreeList
Param | Type | Description |
---|---|---|
parent | TreeLinker | The new node to use as the parent for this group of children |
linkedTreeList.rootParent ⇒ TreeLinker
Return the root parent of the entire tree.
Kind: instance property of LinkedTreeList
linkedTreeList.initialize(initialList) ⇒ LinkedTreeList
Initialize the inner list, should only run once.
Kind: instance method of LinkedTreeList
Overrides: initialize
Param | Type | Description |
---|---|---|
initialList | TreeLinker | Give the list of tree-linkers to start in this linked-tree-list. |
linkedTreeList.setChildren(item, children)
Set the children on a parent item.
Kind: instance method of LinkedTreeList
Param | Type | Description |
---|---|---|
item | TreeLinker | The TreeLinker node that will be the parent of the children |
children | LinkedTreeList | The LinkedTreeList which has the child nodes to use |
linkedTreeList.insertAfter(node, newNode) ⇒ LinkedTreeList
Insert a new node (or data) after a node.
Kind: instance method of LinkedTreeList
Overrides: insertAfter
Param | Type | Description |
---|---|---|
node | TreeLinker | * | The existing node as reference |
newNode | TreeLinker | * | The new node to go after the existing node |
linkedTreeList.insertBefore(node, newNode) ⇒ LinkedTreeList
Insert a new node (or data) before a node.
Kind: instance method of LinkedTreeList
Overrides: insertBefore
Param | Type | Description |
---|---|---|
node | TreeLinker | * | The existing node as reference |
newNode | TreeLinker | * | The new node to go before the existing node |
linkedTreeList.append(node, after) ⇒ TreeLinker
Add a node (or data) after the given (or last) node in the list.
Kind: instance method of LinkedTreeList
Overrides: append
Param | Type | Description |
---|---|---|
node | TreeLinker | * | The new node to add to the end of the list |
after | TreeLinker | The existing last node |
linkedTreeList.prepend(node, before) ⇒ TreeLinker
Add a node (or data) before the given (or first) node in the list.
Kind: instance method of LinkedTreeList
Overrides: prepend
Param | Type | Description |
---|---|---|
node | TreeLinker | * | The new node to add to the start of the list |
before | TreeLinker | The existing first node |
linkedTreeList.remove(node) ⇒ TreeLinker
Remove a linker from this linked list.
Kind: instance method of LinkedTreeList
Overrides: remove
Param | Type | Description |
---|---|---|
node | TreeLinker | The node we wish to remove (and it will be returned after removal) |
linkedTreeList.reset() ⇒ TreeLinker
Refresh all references and return head reference.
Kind: instance method of LinkedTreeList
Overrides: reset
linkedTreeList.item(index) ⇒ TreeLinker | null
Retrieve a TreeLinker item from this list by numeric index, otherwise return null.
Kind: instance method of LinkedTreeList
Overrides: item
Param | Type | Description |
---|---|---|
index | number | The integer number for retrieving a node by position. |
linkedTreeList.forEach(callback, thisArg)
Be able to run forEach on this LinkedTreeList to iterate over the TreeLinker Items.
Kind: instance method of LinkedTreeList
Overrides: forEach
Param | Type | Description |
---|---|---|
callback | forEachCallback | The function to call for-each tree node |
thisArg | LinkedTreeList | Optional, 'this' reference |
Linker ⇐ ArrayElement
Linker represents a node in a LinkedList.
Kind: global class
Extends: ArrayElement
new Linker(nodeData)
Create the new Linker instance, provide the data and optionally give the next Linker.
Param | Type | Default | Description |
---|---|---|---|
nodeData | Object | {} | |
nodeData.data | * | The data to be stored in this linker | |
nodeData.next | Linker | null | The reference to the next linker if any |
Linker.fromArray(values, classType) ⇒ Object
Convert an array into Linker instances, return the head and tail Linkers.
Kind: static method of Linker
Param | Type | Default | Description |
---|---|---|---|
values | Array | [] | Provide an array of data that will be converted to a chain of linkers. |
classType | IsLinker | Linker | Provide the type of IsLinker to use. |
LinkedList ⇐ Arrayable
LinkedList represents a collection stored as a LinkedList with next references.
Kind: global class
Extends: Arrayable
- LinkedList ⇐ Arrayable
- new LinkedList()
- .list ⇒ Linker
- .first ⇒ Linker
- .last ⇒ Linker
- .length ⇒ number
- .initialize(initialList) ⇒ LinkedList
- .insertAfter(node, newNode) ⇒ LinkedList
- .insertBefore(node, newNode) ⇒ LinkedList
- .append(node, after) ⇒ Linker
- .prepend(node, before) ⇒ Linker
- .remove(node) ⇒ Linker
- .item(index) ⇒ Linker | null
- .forEach(callback, thisArg) ⇒ LinkedList
new LinkedList()
Create the new LinkedList instance.
linkedList.list ⇒ Linker
Retrieve a copy of the innerList used.
Kind: instance property of LinkedList
Overrides: list
linkedList.first ⇒ Linker
Retrieve the first Linker in the list.
Kind: instance property of LinkedList
Overrides: first
linkedList.last ⇒ Linker
Retrieve the last Linker in the list.
Kind: instance property of LinkedList
Overrides: last
linkedList.length ⇒ number
Return the length of the list.
Kind: instance property of LinkedList
Overrides: length
linkedList.initialize(initialList) ⇒ LinkedList
Initialize the inner list, should only run once.
Kind: instance method of LinkedList
Overrides: initialize
Param | Type | Description |
---|---|---|
initialList | Linker | Array | Give the list of linkers to start in this linked-list. |
linkedList.insertAfter(node, newNode) ⇒ LinkedList
Insert a new node (or data) after a node.
Kind: instance method of LinkedList
Overrides: insertAfter
Param | Type | Description |
---|---|---|
node | Linker | * | The existing node as reference |
newNode | Linker | * | The new node to go after the existing node |
linkedList.insertBefore(node, newNode) ⇒ LinkedList
Insert a new node (or data) before a node.
Kind: instance method of LinkedList
Overrides: insertBefore
Param | Type | Description |
---|---|---|
node | Linker | * | The existing node as reference |
newNode | Linker | * | The new node to go before the existing node |
linkedList.append(node, after) ⇒ Linker
Add a node (or data) after the given (or last) node in the list.
Kind: instance method of LinkedList
Overrides: append
Param | Type | Description |
---|---|---|
node | Linker | * | The new node to add to the end of the list |
after | Linker | The existing last node |
linkedList.prepend(node, before) ⇒ Linker
Add a node (or data) before the given (or first) node in the list.
Kind: instance method of LinkedList
Overrides: prepend
Param | Type | Description |
---|---|---|
node | Linker | * | The new node to add to the start of the list |
before | Linker | The existing first node |
linkedList.remove(node) ⇒ Linker
Remove a linker from this linked list.
Kind: instance method of LinkedList
Overrides: remove
Param | Type | Description |
---|---|---|
node | Linker | The node we wish to remove (and it will be returned after removal) |
linkedList.item(index) ⇒ Linker | null
Retrieve a Linker item from this list by numeric index, otherwise return null.
Kind: instance method of LinkedList
Overrides: item
Param | Type | Description |
---|---|---|
index | number | The integer number for retrieving a node by position. |
linkedList.forEach(callback, thisArg) ⇒ LinkedList
Be able to run forEach on this LinkedList to iterate over the linkers.
Kind: instance method of LinkedList
Overrides: forEach
Param | Type | Description |
---|---|---|
callback | forEachCallback | The function to call for-each linker |
thisArg | LinkedList | Optional, 'this' reference |
DoublyLinkedList ⇐ LinkedList
DoublyLinkedList represents a collection stored as a LinkedList with prev and next references.
Kind: global class
Extends: LinkedList
- DoublyLinkedList ⇐ LinkedList
- new DoublyLinkedList()
- .list ⇒ DoubleLinker
- .first ⇒ DoubleLinker
- .last ⇒ DoubleLinker
- .length ⇒ number
- .initialize(initialList) ⇒ DoublyLinkedList
- .insertAfter(node, newNode) ⇒ DoublyLinkedList
- .insertBefore(node, newNode) ⇒ DoublyLinkedList
- .append(node, after) ⇒ DoubleLinker
- .prepend(node, before) ⇒ DoubleLinker
- .remove(node) ⇒ DoubleLinker
- .reset() ⇒ DoubleLinker
- .item(index) ⇒ DoubleLinker | null
- .forEach(callback, thisArg)
new DoublyLinkedList()
Create the new DoublyLinkedList instance.
doublyLinkedList.list ⇒ DoubleLinker
Retrieve a copy of the innerList used.
Kind: instance property of DoublyLinkedList
Overrides: list
doublyLinkedList.first ⇒ DoubleLinker
Retrieve the first DoubleLinker in the list.
Kind: instance property of DoublyLinkedList
Overrides: first
doublyLinkedList.last ⇒ DoubleLinker
Retrieve the last DoubleLinker in the list.
Kind: instance property of DoublyLinkedList
Overrides: last
doublyLinkedList.length ⇒ number
Return the length of the list.
Kind: instance property of DoublyLinkedList
Overrides: length
doublyLinkedList.initialize(initialList) ⇒ DoublyLinkedList
Initialize the inner list, should only run once.
Kind: instance method of DoublyLinkedList
Overrides: initialize
Param | Type | Description |
---|---|---|
initialList | DoubleLinker | Give the list of double-linkers to start in this doubly linked-list. |
doublyLinkedList.insertAfter(node, newNode) ⇒ DoublyLinkedList
Insert a new node (or data) after a node.
Kind: instance method of DoublyLinkedList
Overrides: insertAfter
Param | Type | Description |
---|---|---|
node | DoubleLinker | * | The existing node as reference |
newNode | DoubleLinker | * | The new node to go after the existing node |
doublyLinkedList.insertBefore(node, newNode) ⇒ DoublyLinkedList
Insert a new node (or data) before a node.
Kind: instance method of DoublyLinkedList
Overrides: insertBefore
Param | Type | Description |
---|---|---|
node | DoubleLinker | * | The existing node as reference |
newNode | DoubleLinker | * | The new node to go before the existing node |
doublyLinkedList.append(node, after) ⇒ DoubleLinker
Add a node (or data) after the given (or last) node in the list.
Kind: instance method of DoublyLinkedList
Overrides: append
Param | Type | Description |
---|---|---|
node | DoubleLinker | * | The new node to add to the end of the list |
after | DoubleLinker | The existing last node |
doublyLinkedList.prepend(node, before) ⇒ DoubleLinker
Add a node (or data) before the given (or first) node in the list.
Kind: instance method of DoublyLinkedList
Overrides: prepend
Param | Type | Description |
---|---|---|
node | DoubleLinker | * | The new node to add to the start of the list |
before | DoubleLinker | The existing first node |
doublyLinkedList.remove(node) ⇒ DoubleLinker
Remove a linker from this linked list.
Kind: instance method of DoublyLinkedList
Overrides: remove
Param | Type | Description |
---|---|---|
node | DoubleLinker | The node we wish to remove (and it will be returned after removal) |
doublyLinkedList.reset() ⇒ DoubleLinker
Refresh all references and return head reference.
Kind: instance method of DoublyLinkedList
doublyLinkedList.item(index) ⇒ DoubleLinker | null
Retrieve a DoubleLinker item from this list by numeric index, otherwise return null.
Kind: instance method of DoublyLinkedList
Overrides: item
Param | Type | Description |
---|---|---|
index | number | The integer number for retrieving a node by position. |
doublyLinkedList.forEach(callback, thisArg)
Be able to run forEach on this DoublyLinkedList to iterate over the DoubleLinker Items.
Kind: instance method of DoublyLinkedList
Overrides: forEach
Param | Type | Description |
---|---|---|
callback | forEachCallback | The function to call for-each double linker |
thisArg | DoublyLinkedList | Optional, 'this' reference |
DoubleLinker ⇐ Linker
DoubleLinker represents a node in a DoublyLinkedList which is chained by next and prev.
Kind: global class
Extends: Linker
new DoubleLinker(nodeData)
Create the new DoubleLinker instance, provide the data and optionally the next and prev references.
Param | Type | Default | Description |
---|---|---|---|
nodeData | Object | {} | |
nodeData.data | * | The data to be stored in this linker | |
nodeData.next | DoubleLinker | null | The reference to the next linker if any | |
nodeData.prev | DoubleLinker | null | The reference to the previous linker if any |
DoubleLinker.fromArray(values, classType) ⇒ Object
Convert an array into DoubleLinker instances, return the head and tail DoubleLinkers.
Kind: static method of DoubleLinker
Param | Type | Default | Description |
---|---|---|---|
values | Array | [] | Provide an array of data that will be converted to a chain of linkers. |
classType | IsDoubleLinker | DoubleLinker | Provide the type of IsDoubleLinker to use. |
Arrayable
Arrayable represents a collection stored as an array.
Kind: global class
- Arrayable
- new Arrayable()
- .list ⇒ Array.<ArrayElement>
- .first ⇒ ArrayElement
- .last ⇒ ArrayElement
- .length ⇒ number
- .initialize(initialList) ⇒ Arrayable
- .insertAfter(node, newNode) ⇒ Arrayable
- .insertBefore(node, newNode) ⇒ Arrayable
- .append(node, after) ⇒ Arrayable
- .prepend(node, before) ⇒ Arrayable
- .remove(node) ⇒ ArrayElement
- .item(index) ⇒ ArrayElement | null
- .forEach(callback, thisArg) ⇒ Arrayable
new Arrayable()
Create the new Arrayable instance, configure the Arrayable class.
arrayable.list ⇒ Array.<ArrayElement>
Retrieve a copy of the innerList used.
Kind: instance property of Arrayable
arrayable.first ⇒ ArrayElement
Retrieve the first Element from the Arrayable
Kind: instance property of Arrayable
arrayable.last ⇒ ArrayElement
Retrieve the last Element from the Arrayable
Kind: instance property of Arrayable
arrayable.length ⇒ number
Return the length of the list.
Kind: instance property of Arrayable
arrayable.initialize(initialList) ⇒ Arrayable
Initialize the inner list, should only run once.
Kind: instance method of Arrayable
Param | Type | Description |
---|---|---|
initialList | Array.<ArrayElement> | Give the array of elements to start in this Arrayable. |
arrayable.insertAfter(node, newNode) ⇒ Arrayable
Insert a new node (or data) after a node.
Kind: instance method of Arrayable
Param | Type | Description |
---|---|---|
node | ArrayElement | * | The existing node as reference |
newNode | ArrayElement | * | The new node to go after the existing node |
arrayable.insertBefore(node, newNode) ⇒ Arrayable
Insert a new node (or data) before a node.
Kind: instance method of Arrayable
Param | Type | Description |
---|---|---|
node | ArrayElement | * | The existing node as reference |
newNode | ArrayElement | * | The new node to go before the existing node |
arrayable.append(node, after) ⇒ Arrayable
Add a node (or data) after the given (or last) node in the list.
Kind: instance method of Arrayable
Param | Type | Description |
---|---|---|
node | ArrayElement | * | The new node to add to the end of the list |
after | ArrayElement | The existing last node |
arrayable.prepend(node, before) ⇒ Arrayable
Add a node (or data) before the given (or first) node in the list.
Kind: instance method of Arrayable
Param | Type | Description |
---|---|---|
node | ArrayElement | * | The new node to add to the start of the list |
before | ArrayElement | The existing first node |
arrayable.remove(node) ⇒ ArrayElement
Remove an element from this arrayable.
Kind: instance method of Arrayable
Param | Type | Description |
---|---|---|
node | ArrayElement | The node we wish to remove (and it will be returned after removal) |
arrayable.item(index) ⇒ ArrayElement | null
Retrieve an ArrayElement item from this list by numeric index, otherwise return null.
Kind: instance method of Arrayable
Param | Type | Description |
---|---|---|
index | number | The integer number for retrieving a node by position. |
arrayable.forEach(callback, thisArg) ⇒ Arrayable
Be able to run forEach on this Arrayable to iterate over the elements.
Kind: instance method of Arrayable
Param | Type | Description |
---|---|---|
callback | forEachCallback | The function to call for-each element |
thisArg | Arrayable | Optional, 'this' reference |
ArrayElement
Element represents a node in an Arrayable.
Kind: global class
new ArrayElement(data)
Create the new Element instance, provide the data and optionally configure the type of Element.
Param | Type | Default | Description |
---|---|---|---|
data | * | The data to be stored in this element. |
ArrayElement.fromArray(values, classType) ⇒ Object
Convert an array into Element instances, return the head and tail Elements.
Kind: static method of ArrayElement
Param | Type | Default | Description |
---|---|---|---|
values | Array.<IsElement> | [] | Provide an array of data that will be converted to array of elements. |
classType | IsElement | ArrayElement | Provide the type of IsElement to use. |
Stackable ⇒ Stackable
Make a new Stackable from the data given if it is not already a valid Stackable.
Kind: global variable
Param | Type | Default | Description |
---|---|---|---|
stackable | Stackable | * | Return a valid Stackable instance from given data, or even an already valid one. | |
classType | IsLinker | Stackable | Provide the type of IsLinker to use. |
- Stackable ⇒ Stackable
- new Stackable([stackData])
- instance
- static
- .fromArray([values], [classType]) ⇒ Object
new Stackable(stackData)
Create a stackable item that can be used in a stack.
Param | Type | Default | Description |
---|---|---|---|
stackData | Object | {} | |
stackData.task | * | The data to be stored in this stackable | |
stackData.next | Stackable | null | The reference to the next stackable if any | |
stackData.ready | boolean | function | false | Indicate if the stackable is ready to run |
stackable.task ⇒ *
Retrieve the data which should be formed as a task.
Kind: instance property of Stackable
stackable.run() ⇒ *
Run the stacked task.
Kind: instance method of Stackable
Stackable.fromArray(values, classType) ⇒ Object
Convert an array into Stackable instances, return the head and tail Stackables.
Kind: static method of Stackable
Param | Type | Default | Description |
---|---|---|---|
values | Array | [] | Provide an array of data that will be converted to a chain of stackable linkers. |
classType | IsLinker | Stackable | Provide the type of IsLinker to use. |
Stack ⇒ Stack
Convert an array to a Stack.
Kind: global variable
Param | Type | Description |
---|---|---|
values | Array | An array of values which will be converted to stackables in this queue |
stackableClass | Stackable | The class to use for each stackable |
listClass | Stack | Iterable | The class to use to manage the stackables |
- Stack ⇒ Stack
- new Stack(stackedList, listClass, stackableClass)
- .empty() ⇒ boolean
- .top() ⇒ Stackable
- .pop() ⇒ Stackable | null
- .push(stackable)
- .remove() ⇒ Stackable | null
- .size() ⇒ number
new Stack(stackedList, listClass, stackableClass)
Instantiate the state with the starter stacked list.
Param | Type |
---|---|
stackedList | Iterable | LinkedList |
listClass | IsArrayable |
stackableClass | Stackable |
stack.empty() ⇒ boolean
Return true if the stack is empty (there are no tasks in the stacked list)
Kind: instance method of Stack
stack.top() ⇒ Stackable
Take a look at the next stacked task
Kind: instance method of Stack
stack.pop() ⇒ Stackable | null
Remove the next stacked task and return it.
Kind: instance method of Stack
stack.push(stackable)
Push a stackable task to the top of the stack.
Kind: instance method of Stack
Param | Type | Description |
---|---|---|
stackable | Stackable | * | Add a new stackable to the top of the stack |
stack.remove() ⇒ Stackable | null
Remove the next stacked task and return it.
Kind: instance method of Stack
stack.size() ⇒ number
Get the size of the current stack.
Kind: instance method of Stack
Queueable ⇒ Queueable
Make a new Queueable from the data given if it is not already a valid Queueable.
Kind: global variable
Param | Type | Default | Description |
---|---|---|---|
queueable | Queueable | * | Return a valid Queueable instance from given data, or even an already valid one. | |
classType | IsLinker | Queueable | Provide the type of IsLinker to use. |
- Queueable ⇒ Queueable
- new Queueable([queueableData])
- instance
- .isReady ⇒ boolean
- .task ⇒ *
- .markCompleted(completeResponse) ⇒ completeResponse
- .run() ⇒ completeResponse
- static
- .fromArray(values, [classType]) ⇒ Object
new Queueable(queueableData)
Create a queueable item that can be used in a queue.
Param | Type | Default | Description |
---|---|---|---|
queueableData | Object | {} | |
queueableData.task | * | The data to be stored in this queueable | |
queueableData.next | Queueable | null | The reference to the next queueable if any | |
queueableData.ready | boolean | function | false | Indicate if the queueable is ready to run |
queueable.isReady ⇒ boolean
Check ready state.
Kind: instance property of Queueable
queueable.task ⇒ *
Retrieve the data which should be formed as a task.
Kind: instance property of Queueable
queueable.markCompleted(completeResponse) ⇒ completeResponse
Set this queueable as completed.
Kind: instance method of Queueable
Param | Type | Default | Description |
---|---|---|---|
completeResponse | Object | ||
completeResponse.success | * | true | Indicate when the task failed (use false) or give a success message |
completeResponse.error | * | false | Indicate a task was error-free (use false) or give an error message |
completeResponse.context | * | Provide additional data in the response |
queueable.run() ⇒ completeResponse
Intend to run the queued task when it is ready. If ready, mark this task as running and run the task.
Kind: instance method of Queueable
Queueable.fromArray(values, classType) ⇒ Object
Convert an array into Queueable instances, return the head and tail Queueables.
Kind: static method of Queueable
Param | Type | Default | Description |
---|---|---|---|
values | Array | Provide an array of data that will be converted to a chain of queueable linkers. | |
classType | IsLinker | Queueable | Provide the type of IsLinker to use. |
Queue ⇒ Queue
Convert an array to a Queue.
Kind: global variable
Param | Type | Description |
---|---|---|
values | Array | An array of values which will be converted to queueables in this queue |
queueableClass | Queueable | The class to use for each queueable |
listClass | Queue | Iterable | The class to use to manage the queueables |
- Queue ⇒ Queue
- new Queue(queuedList, listClass, queueableClass)
- .dequeue() ⇒ completeResponse | *
- .empty() ⇒ boolean
- .enqueue(queueable)
- .peek() ⇒ Queueable
- .remove() ⇒ Queueable | null
- .size() ⇒ number
new Queue(queuedList, listClass, queueableClass)
Instantiate the queue with the given queue list.
Param | Type | Description |
---|---|---|
queuedList | Iterable | LinkedList | Give the list of queueables to start in this queue. |
listClass | IsArrayable | |
queueableClass | Queueable |
queue.dequeue() ⇒ completeResponse | *
Take a queued task from the front of the queue and run it if ready.
Kind: instance method of Queue
queue.empty() ⇒ boolean
Return true if the queue is empty (there are no tasks in the queue list)
Kind: instance method of Queue
queue.enqueue(queueable)
Add a queued task to the end of the queue
Kind: instance method of Queue
Param | Type | Description |
---|---|---|
queueable | Queueable | Add a new queueable to the end of the queue |
queue.peek() ⇒ Queueable
Take a look at the next queued task
Kind: instance method of [