collect-your-stuff 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +898 -213
- package/browser/collect-your-stuff.js +2672 -20684
- package/browser/collect-your-stuff.min.js +1 -1
- package/dist/collections/arrayable/ArrayElement.d.ts +38 -38
- package/dist/collections/arrayable/ArrayElement.js +66 -66
- package/dist/collections/arrayable/Arrayable.d.ts +122 -122
- package/dist/collections/arrayable/Arrayable.js +2 -2
- package/dist/collections/doubly-linked-list/DoubleLinker.d.ts +50 -50
- package/dist/collections/doubly-linked-list/DoubleLinker.js +1 -1
- package/dist/collections/doubly-linked-list/DoublyLinkedList.d.ts +125 -125
- package/dist/collections/doubly-linked-list/DoublyLinkedList.js +3 -3
- package/dist/collections/linked-list/LinkedList.d.ts +126 -126
- package/dist/collections/linked-list/LinkedList.js +3 -3
- package/dist/collections/linked-list/Linker.d.ts +46 -46
- package/dist/collections/linked-list/Linker.js +1 -1
- package/dist/collections/linked-tree-list/LinkedTreeList.d.ts +159 -159
- package/dist/collections/linked-tree-list/LinkedTreeList.js +3 -3
- package/dist/collections/linked-tree-list/TreeLinker.d.ts +71 -71
- package/dist/collections/linked-tree-list/TreeLinker.js +2 -2
- package/dist/collections/queue/Queue.d.ts +59 -59
- package/dist/collections/queue/Queue.js +11 -9
- package/dist/collections/queue/Queueable.d.ts +83 -83
- package/dist/collections/queue/Queueable.js +9 -7
- package/dist/collections/queue/TaskQueue.d.ts +68 -68
- package/dist/collections/queue/TaskQueue.js +2 -2
- package/dist/collections/stack/Stack.d.ts +64 -64
- package/dist/collections/stack/Stack.js +11 -9
- package/dist/collections/stack/Stackable.d.ts +59 -59
- package/dist/collections/stack/Stackable.js +1 -1
- package/dist/collections/stack/TaskStack.d.ts +65 -65
- package/dist/collections/stack/TaskStack.js +2 -2
- package/dist/main.d.ts +68 -69
- package/dist/main.js +1 -2
- package/dist/main.min.js +1 -1
- package/dist/recipes/ArrayIterator.d.ts +20 -20
- package/dist/recipes/ArrayIterator.js +39 -39
- package/dist/recipes/DoubleLinkerIterator.d.ts +18 -18
- package/dist/recipes/DoubleLinkerIterator.js +33 -33
- package/dist/recipes/IsArrayable.d.ts +105 -105
- package/dist/recipes/IsArrayable.js +5 -5
- package/dist/recipes/IsDoubleLinker.d.ts +14 -14
- package/dist/recipes/IsDoubleLinker.js +5 -5
- package/dist/recipes/IsElement.d.ts +14 -14
- package/dist/recipes/IsElement.js +5 -5
- package/dist/recipes/IsLinker.d.ts +10 -10
- package/dist/recipes/IsLinker.js +5 -5
- package/dist/recipes/IsQueue.d.ts +37 -37
- package/dist/recipes/IsQueue.js +5 -5
- package/dist/recipes/IsStack.d.ts +36 -36
- package/dist/recipes/IsStack.js +5 -5
- package/dist/recipes/IsTree.d.ts +11 -11
- package/dist/recipes/IsTree.js +5 -5
- package/dist/recipes/IsTreeNode.d.ts +29 -29
- package/dist/recipes/IsTreeNode.js +5 -5
- package/dist/recipes/LinkerIterator.d.ts +18 -18
- package/dist/recipes/LinkerIterator.js +33 -33
- package/dist/recipes/Runnable.d.ts +55 -55
- package/dist/recipes/Runnable.js +69 -69
- package/dist/recipes/TreeLinkerIterator.d.ts +20 -20
- package/dist/recipes/TreeLinkerIterator.js +1 -1
- package/dist/recipes/recipes.d.ts +15 -15
- package/dist/recipes/recipes.js +2 -2
- package/dist/services/parseTree.d.ts +9 -9
- package/dist/services/parseTree.js +1 -1
- package/dist/services/parseTreeNext.d.ts +17 -17
- package/dist/services/parseTreeNext.js +42 -42
- package/dist/services/services.d.ts +13 -13
- package/dist/services/services.js +2 -2
- package/package.json +2 -2
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file linked list item.
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.1.0
|
|
5
|
-
* @memberOf module:collect-your-stuff
|
|
6
|
-
*/
|
|
7
|
-
import { IsElement } from '../../recipes/IsElement';
|
|
8
|
-
/**
|
|
9
|
-
* Element represents a node in an Arrayable.
|
|
10
|
-
*/
|
|
11
|
-
export declare class ArrayElement implements IsElement {
|
|
12
|
-
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
13
|
-
readonly classType: typeof ArrayElement;
|
|
14
|
-
/** The data stored in this element. */
|
|
15
|
-
data: any;
|
|
16
|
-
/**
|
|
17
|
-
* Create the new Element instance, provide the data and optionally configure the type of Element.
|
|
18
|
-
* @param {*} [data=null] The data to be stored in this element.
|
|
19
|
-
*/
|
|
20
|
-
constructor(data?: any);
|
|
21
|
-
/**
|
|
22
|
-
* Make a new Element from the data given if it is not already a valid Element.
|
|
23
|
-
* @param {ArrayElement|*} element Return a valid ArrayElement instance from given data, or even an already valid one.
|
|
24
|
-
* @param {IsElement} [classType=ArrayElement] Provide the type of IsElement to use.
|
|
25
|
-
* @return {ArrayElement}
|
|
26
|
-
*/
|
|
27
|
-
static make: (element: ArrayElement | any, classType?: any) => IsElement | any;
|
|
28
|
-
/**
|
|
29
|
-
* Convert an array into Element instances, return the head and tail Elements.
|
|
30
|
-
* @param {Array<IsElement>} [values=[]] Provide an array of data that will be converted to array of elements.
|
|
31
|
-
* @param {IsElement} [classType=ArrayElement] Provide the type of IsElement to use.
|
|
32
|
-
* @returns {{head: ArrayElement[], tail: ArrayElement}}
|
|
33
|
-
*/
|
|
34
|
-
static fromArray: (values?: Array<IsElement>, classType?: any) => {
|
|
35
|
-
head: Array<ArrayElement>;
|
|
36
|
-
tail: ArrayElement;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @file linked list item.
|
|
3
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
+
* @version 1.1.0
|
|
5
|
+
* @memberOf module:collect-your-stuff
|
|
6
|
+
*/
|
|
7
|
+
import { IsElement } from '../../recipes/IsElement';
|
|
8
|
+
/**
|
|
9
|
+
* Element represents a node in an Arrayable.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ArrayElement implements IsElement {
|
|
12
|
+
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
13
|
+
readonly classType: typeof ArrayElement;
|
|
14
|
+
/** The data stored in this element. */
|
|
15
|
+
data: any;
|
|
16
|
+
/**
|
|
17
|
+
* Create the new Element instance, provide the data and optionally configure the type of Element.
|
|
18
|
+
* @param {*} [data=null] The data to be stored in this element.
|
|
19
|
+
*/
|
|
20
|
+
constructor(data?: any);
|
|
21
|
+
/**
|
|
22
|
+
* Make a new Element from the data given if it is not already a valid Element.
|
|
23
|
+
* @param {ArrayElement|*} element Return a valid ArrayElement instance from given data, or even an already valid one.
|
|
24
|
+
* @param {IsElement} [classType=ArrayElement] Provide the type of IsElement to use.
|
|
25
|
+
* @return {ArrayElement}
|
|
26
|
+
*/
|
|
27
|
+
static make: (element: ArrayElement | any, classType?: any) => IsElement | any;
|
|
28
|
+
/**
|
|
29
|
+
* Convert an array into Element instances, return the head and tail Elements.
|
|
30
|
+
* @param {Array<IsElement>} [values=[]] Provide an array of data that will be converted to array of elements.
|
|
31
|
+
* @param {IsElement} [classType=ArrayElement] Provide the type of IsElement to use.
|
|
32
|
+
* @returns {{head: ArrayElement[], tail: ArrayElement}}
|
|
33
|
+
*/
|
|
34
|
+
static fromArray: (values?: Array<IsElement>, classType?: any) => {
|
|
35
|
+
head: Array<ArrayElement>;
|
|
36
|
+
tail: ArrayElement;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.ArrayElement = void 0
|
|
7
|
-
require('core-js/modules/esnext.iterator.constructor.js')
|
|
8
|
-
require('core-js/modules/esnext.iterator.reduce.js')
|
|
9
|
-
/**
|
|
10
|
-
* Element represents a node in an Arrayable.
|
|
11
|
-
*/
|
|
12
|
-
class ArrayElement {
|
|
13
|
-
/**
|
|
14
|
-
* Create the new Element instance, provide the data and optionally configure the type of Element.
|
|
15
|
-
* @param {*} [data=null] The data to be stored in this element.
|
|
16
|
-
*/
|
|
17
|
-
constructor (data = null) {
|
|
18
|
-
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
19
|
-
this.classType = ArrayElement
|
|
20
|
-
/** The data stored in this element. */
|
|
21
|
-
this.data = null
|
|
22
|
-
this.data = data
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Make a new Element from the data given if it is not already a valid Element.
|
|
27
|
-
* @param {ArrayElement|*} element Return a valid ArrayElement instance from given data, or even an already valid one.
|
|
28
|
-
* @param {IsElement} [classType=ArrayElement] Provide the type of IsElement to use.
|
|
29
|
-
* @return {ArrayElement}
|
|
30
|
-
*/
|
|
31
|
-
exports.ArrayElement = ArrayElement
|
|
32
|
-
ArrayElement.make = (element, classType = ArrayElement) => {
|
|
33
|
-
if (element === null || typeof element !== 'object') {
|
|
34
|
-
// It is not an object (or it is null), so instantiate the Element with element as the data
|
|
35
|
-
return new classType(element)
|
|
36
|
-
}
|
|
37
|
-
if (element.classType) {
|
|
38
|
-
// Already valid Element, return as-is
|
|
39
|
-
return element
|
|
40
|
-
}
|
|
41
|
-
// Create the new node as the configured #classType
|
|
42
|
-
return new classType(element)
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Convert an array into Element instances, return the head and tail Elements.
|
|
46
|
-
* @param {Array<IsElement>} [values=[]] Provide an array of data that will be converted to array of elements.
|
|
47
|
-
* @param {IsElement} [classType=ArrayElement] Provide the type of IsElement to use.
|
|
48
|
-
* @returns {{head: ArrayElement[], tail: ArrayElement}}
|
|
49
|
-
*/
|
|
50
|
-
ArrayElement.fromArray = (values = [], classType = ArrayElement) => values.reduce((references, element) => {
|
|
51
|
-
const newElement = classType.make(element, classType)
|
|
52
|
-
if (!references.head.length) {
|
|
53
|
-
// Initialize the head and tail with the new node
|
|
54
|
-
return {
|
|
55
|
-
head: [newElement],
|
|
56
|
-
tail: newElement
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
// Only update the tail once head has been set, tail is always the most recent node
|
|
60
|
-
references.head.push(newElement)
|
|
61
|
-
references.tail = newElement
|
|
62
|
-
return references
|
|
63
|
-
}, {
|
|
64
|
-
head: [],
|
|
65
|
-
tail: null
|
|
66
|
-
})
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.ArrayElement = void 0
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js')
|
|
8
|
+
require('core-js/modules/esnext.iterator.reduce.js')
|
|
9
|
+
/**
|
|
10
|
+
* Element represents a node in an Arrayable.
|
|
11
|
+
*/
|
|
12
|
+
class ArrayElement {
|
|
13
|
+
/**
|
|
14
|
+
* Create the new Element instance, provide the data and optionally configure the type of Element.
|
|
15
|
+
* @param {*} [data=null] The data to be stored in this element.
|
|
16
|
+
*/
|
|
17
|
+
constructor (data = null) {
|
|
18
|
+
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
19
|
+
this.classType = ArrayElement
|
|
20
|
+
/** The data stored in this element. */
|
|
21
|
+
this.data = null
|
|
22
|
+
this.data = data
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Make a new Element from the data given if it is not already a valid Element.
|
|
27
|
+
* @param {ArrayElement|*} element Return a valid ArrayElement instance from given data, or even an already valid one.
|
|
28
|
+
* @param {IsElement} [classType=ArrayElement] Provide the type of IsElement to use.
|
|
29
|
+
* @return {ArrayElement}
|
|
30
|
+
*/
|
|
31
|
+
exports.ArrayElement = ArrayElement
|
|
32
|
+
ArrayElement.make = (element, classType = ArrayElement) => {
|
|
33
|
+
if (element === null || typeof element !== 'object') {
|
|
34
|
+
// It is not an object (or it is null), so instantiate the Element with element as the data
|
|
35
|
+
return new classType(element)
|
|
36
|
+
}
|
|
37
|
+
if (element.classType) {
|
|
38
|
+
// Already valid Element, return as-is
|
|
39
|
+
return element
|
|
40
|
+
}
|
|
41
|
+
// Create the new node as the configured #classType
|
|
42
|
+
return new classType(element)
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Convert an array into Element instances, return the head and tail Elements.
|
|
46
|
+
* @param {Array<IsElement>} [values=[]] Provide an array of data that will be converted to array of elements.
|
|
47
|
+
* @param {IsElement} [classType=ArrayElement] Provide the type of IsElement to use.
|
|
48
|
+
* @returns {{head: ArrayElement[], tail: ArrayElement}}
|
|
49
|
+
*/
|
|
50
|
+
ArrayElement.fromArray = (values = [], classType = ArrayElement) => values.reduce((references, element) => {
|
|
51
|
+
const newElement = classType.make(element, classType)
|
|
52
|
+
if (!references.head.length) {
|
|
53
|
+
// Initialize the head and tail with the new node
|
|
54
|
+
return {
|
|
55
|
+
head: [newElement],
|
|
56
|
+
tail: newElement
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Only update the tail once head has been set, tail is always the most recent node
|
|
60
|
+
references.head.push(newElement)
|
|
61
|
+
references.tail = newElement
|
|
62
|
+
return references
|
|
63
|
+
}, {
|
|
64
|
+
head: [],
|
|
65
|
+
tail: null
|
|
66
|
+
})
|
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file arrayable list.
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.1.0
|
|
5
|
-
* @memberOf module:collect-your-stuff
|
|
6
|
-
*/
|
|
7
|
-
import { ArrayElement } from './ArrayElement';
|
|
8
|
-
import { forEachCallback, IsArrayable } from '../../recipes/IsArrayable';
|
|
9
|
-
import { IsElement } from '../../recipes/IsElement';
|
|
10
|
-
/**
|
|
11
|
-
* Arrayable represents a collection stored as an array.
|
|
12
|
-
*/
|
|
13
|
-
export declare class Arrayable implements IsArrayable<ArrayElement>, Iterable<ArrayElement> {
|
|
14
|
-
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
15
|
-
readonly classType: typeof Arrayable;
|
|
16
|
-
/** The array which stores the elements of this Arrayable. */
|
|
17
|
-
innerList: Array<ArrayElement>;
|
|
18
|
-
/** Whether the inner list has been initialized (it can only be initialized once). */
|
|
19
|
-
initialized: boolean;
|
|
20
|
-
/** The class used to wrap the data given to this Arrayable as elements. */
|
|
21
|
-
elementClass: typeof ArrayElement;
|
|
22
|
-
/**
|
|
23
|
-
* Create the new Arrayable instance, configure the Arrayable class.
|
|
24
|
-
* @param {ArrayElement} [elementClass=ArrayElement] The class used to wrap given data as elements.
|
|
25
|
-
*/
|
|
26
|
-
constructor(elementClass?: typeof ArrayElement);
|
|
27
|
-
/**
|
|
28
|
-
* Find the position of an element which must be in this list.
|
|
29
|
-
* @param {ArrayElement} node The element to find
|
|
30
|
-
* @returns {number}
|
|
31
|
-
* @throws {Error} When the element is not in this list
|
|
32
|
-
*/
|
|
33
|
-
private indexOfElement;
|
|
34
|
-
/**
|
|
35
|
-
* Initialize the inner list, should only run once.
|
|
36
|
-
* @param {Array<ArrayElement>} initialList Give the array of elements to start in this Arrayable.
|
|
37
|
-
* @return {Arrayable}
|
|
38
|
-
*/
|
|
39
|
-
initialize(initialList: Array<ArrayElement>): Arrayable;
|
|
40
|
-
/**
|
|
41
|
-
* Retrieve the innerList used (the list itself, not a copy).
|
|
42
|
-
* @returns {Array<ArrayElement>}
|
|
43
|
-
*/
|
|
44
|
-
get list(): Array<ArrayElement>;
|
|
45
|
-
/**
|
|
46
|
-
* Retrieve the first Element from the Arrayable
|
|
47
|
-
* @returns {ArrayElement|null} The first element, or null when the Arrayable is empty
|
|
48
|
-
*/
|
|
49
|
-
get first(): ArrayElement | null;
|
|
50
|
-
/**
|
|
51
|
-
* Retrieve the last Element from the Arrayable
|
|
52
|
-
* @returns {ArrayElement|null} The last element, or null when the Arrayable is empty
|
|
53
|
-
*/
|
|
54
|
-
get last(): ArrayElement | null;
|
|
55
|
-
/**
|
|
56
|
-
* Return the length of the list.
|
|
57
|
-
* @returns {number}
|
|
58
|
-
*/
|
|
59
|
-
get length(): number;
|
|
60
|
-
/**
|
|
61
|
-
* Insert a new node (or data) after a node.
|
|
62
|
-
* @param {ArrayElement|null} node The existing node as reference, or null to insert at the start of the list
|
|
63
|
-
* @param {ArrayElement|*} newNode The new node to go after the existing node
|
|
64
|
-
* @returns {Arrayable}
|
|
65
|
-
* @throws {Error} When the reference node is not in this list
|
|
66
|
-
*/
|
|
67
|
-
insertAfter(node: ArrayElement | null, newNode: ArrayElement | any): Arrayable;
|
|
68
|
-
/**
|
|
69
|
-
* Insert a new node (or data) before a node.
|
|
70
|
-
* @param {ArrayElement|null} node The existing node as reference, or null to insert at the end of the list
|
|
71
|
-
* @param {ArrayElement|*} newNode The new node to go before the existing node
|
|
72
|
-
* @returns {Arrayable}
|
|
73
|
-
* @throws {Error} When the reference node is not in this list
|
|
74
|
-
*/
|
|
75
|
-
insertBefore(node: ArrayElement | null, newNode: ArrayElement | any): Arrayable;
|
|
76
|
-
/**
|
|
77
|
-
* Add a node (or data) after the given (or last) node in the list.
|
|
78
|
-
* @param {ArrayElement|*} node The new node to add to the end of the list
|
|
79
|
-
* @param {ArrayElement} after The existing last node
|
|
80
|
-
* @returns {Arrayable}
|
|
81
|
-
*/
|
|
82
|
-
append(node: ArrayElement | any, after?: ArrayElement | null): Arrayable;
|
|
83
|
-
/**
|
|
84
|
-
* Add a node (or data) before the given (or first) node in the list.
|
|
85
|
-
* @param {ArrayElement|*} node The new node to add to the start of the list
|
|
86
|
-
* @param {ArrayElement} before The existing first node
|
|
87
|
-
* @returns {Arrayable}
|
|
88
|
-
*/
|
|
89
|
-
prepend(node: ArrayElement | any, before?: ArrayElement | null): Arrayable;
|
|
90
|
-
/**
|
|
91
|
-
* Remove an element from this arrayable.
|
|
92
|
-
* @param {ArrayElement} node The node we wish to remove (and it will be returned after removal)
|
|
93
|
-
* @return {ArrayElement|null} The removed node, or null when it was not in this list (nothing is removed)
|
|
94
|
-
*/
|
|
95
|
-
remove(node: ArrayElement): ArrayElement | null;
|
|
96
|
-
/**
|
|
97
|
-
* Retrieve an ArrayElement item from this list by numeric index, otherwise return null.
|
|
98
|
-
* @param {number} index The integer number for retrieving a node by position.
|
|
99
|
-
* @return {ArrayElement|null}
|
|
100
|
-
*/
|
|
101
|
-
item(index: number): ArrayElement | null;
|
|
102
|
-
/**
|
|
103
|
-
* Be able to run forEach on this Arrayable to iterate over the elements.
|
|
104
|
-
* @param {forEachCallback} callback The function to call for-each element
|
|
105
|
-
* @param {Arrayable} thisArg Optional, 'this' reference
|
|
106
|
-
* @returns {Arrayable}
|
|
107
|
-
*/
|
|
108
|
-
forEach(callback: forEachCallback, thisArg?: Arrayable): Arrayable;
|
|
109
|
-
/**
|
|
110
|
-
* Be able to iterate over this class.
|
|
111
|
-
* @returns {Iterator}
|
|
112
|
-
*/
|
|
113
|
-
[Symbol.iterator](): Iterator<ArrayElement>;
|
|
114
|
-
/**
|
|
115
|
-
* Convert an array to an Arrayable.
|
|
116
|
-
* @param {Array} values An array of values which will be converted to elements in this arrayable
|
|
117
|
-
* @param {IsElement} [elementClass=ArrayElement] The class to use for each element
|
|
118
|
-
* @param {IsArrayable<ArrayElement>} [classType=Arrayable] Provide the type of IsArrayable to use.
|
|
119
|
-
* @returns {Arrayable}
|
|
120
|
-
*/
|
|
121
|
-
static fromArray: (values?: Array<any>, elementClass?: typeof ArrayElement, classType?: any) => IsArrayable<IsElement>;
|
|
122
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @file arrayable list.
|
|
3
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
+
* @version 1.1.0
|
|
5
|
+
* @memberOf module:collect-your-stuff
|
|
6
|
+
*/
|
|
7
|
+
import { ArrayElement } from './ArrayElement';
|
|
8
|
+
import { forEachCallback, IsArrayable } from '../../recipes/IsArrayable';
|
|
9
|
+
import { IsElement } from '../../recipes/IsElement';
|
|
10
|
+
/**
|
|
11
|
+
* Arrayable represents a collection stored as an array.
|
|
12
|
+
*/
|
|
13
|
+
export declare class Arrayable implements IsArrayable<ArrayElement>, Iterable<ArrayElement> {
|
|
14
|
+
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
15
|
+
readonly classType: typeof Arrayable;
|
|
16
|
+
/** The array which stores the elements of this Arrayable. */
|
|
17
|
+
innerList: Array<ArrayElement>;
|
|
18
|
+
/** Whether the inner list has been initialized (it can only be initialized once). */
|
|
19
|
+
initialized: boolean;
|
|
20
|
+
/** The class used to wrap the data given to this Arrayable as elements. */
|
|
21
|
+
elementClass: typeof ArrayElement;
|
|
22
|
+
/**
|
|
23
|
+
* Create the new Arrayable instance, configure the Arrayable class.
|
|
24
|
+
* @param {ArrayElement} [elementClass=ArrayElement] The class used to wrap given data as elements.
|
|
25
|
+
*/
|
|
26
|
+
constructor(elementClass?: typeof ArrayElement);
|
|
27
|
+
/**
|
|
28
|
+
* Find the position of an element which must be in this list.
|
|
29
|
+
* @param {ArrayElement} node The element to find
|
|
30
|
+
* @returns {number}
|
|
31
|
+
* @throws {Error} When the element is not in this list
|
|
32
|
+
*/
|
|
33
|
+
private indexOfElement;
|
|
34
|
+
/**
|
|
35
|
+
* Initialize the inner list, should only run once.
|
|
36
|
+
* @param {Array<ArrayElement>} initialList Give the array of elements to start in this Arrayable.
|
|
37
|
+
* @return {Arrayable}
|
|
38
|
+
*/
|
|
39
|
+
initialize(initialList: Array<ArrayElement>): Arrayable;
|
|
40
|
+
/**
|
|
41
|
+
* Retrieve the innerList used (the list itself, not a copy).
|
|
42
|
+
* @returns {Array<ArrayElement>}
|
|
43
|
+
*/
|
|
44
|
+
get list(): Array<ArrayElement>;
|
|
45
|
+
/**
|
|
46
|
+
* Retrieve the first Element from the Arrayable
|
|
47
|
+
* @returns {ArrayElement|null} The first element, or null when the Arrayable is empty
|
|
48
|
+
*/
|
|
49
|
+
get first(): ArrayElement | null;
|
|
50
|
+
/**
|
|
51
|
+
* Retrieve the last Element from the Arrayable
|
|
52
|
+
* @returns {ArrayElement|null} The last element, or null when the Arrayable is empty
|
|
53
|
+
*/
|
|
54
|
+
get last(): ArrayElement | null;
|
|
55
|
+
/**
|
|
56
|
+
* Return the length of the list.
|
|
57
|
+
* @returns {number}
|
|
58
|
+
*/
|
|
59
|
+
get length(): number;
|
|
60
|
+
/**
|
|
61
|
+
* Insert a new node (or data) after a node.
|
|
62
|
+
* @param {ArrayElement|null} node The existing node as reference, or null to insert at the start of the list
|
|
63
|
+
* @param {ArrayElement|*} newNode The new node to go after the existing node
|
|
64
|
+
* @returns {Arrayable}
|
|
65
|
+
* @throws {Error} When the reference node is not in this list
|
|
66
|
+
*/
|
|
67
|
+
insertAfter(node: ArrayElement | null, newNode: ArrayElement | any): Arrayable;
|
|
68
|
+
/**
|
|
69
|
+
* Insert a new node (or data) before a node.
|
|
70
|
+
* @param {ArrayElement|null} node The existing node as reference, or null to insert at the end of the list
|
|
71
|
+
* @param {ArrayElement|*} newNode The new node to go before the existing node
|
|
72
|
+
* @returns {Arrayable}
|
|
73
|
+
* @throws {Error} When the reference node is not in this list
|
|
74
|
+
*/
|
|
75
|
+
insertBefore(node: ArrayElement | null, newNode: ArrayElement | any): Arrayable;
|
|
76
|
+
/**
|
|
77
|
+
* Add a node (or data) after the given (or last) node in the list.
|
|
78
|
+
* @param {ArrayElement|*} node The new node to add to the end of the list
|
|
79
|
+
* @param {ArrayElement} after The existing last node
|
|
80
|
+
* @returns {Arrayable}
|
|
81
|
+
*/
|
|
82
|
+
append(node: ArrayElement | any, after?: ArrayElement | null): Arrayable;
|
|
83
|
+
/**
|
|
84
|
+
* Add a node (or data) before the given (or first) node in the list.
|
|
85
|
+
* @param {ArrayElement|*} node The new node to add to the start of the list
|
|
86
|
+
* @param {ArrayElement} before The existing first node
|
|
87
|
+
* @returns {Arrayable}
|
|
88
|
+
*/
|
|
89
|
+
prepend(node: ArrayElement | any, before?: ArrayElement | null): Arrayable;
|
|
90
|
+
/**
|
|
91
|
+
* Remove an element from this arrayable.
|
|
92
|
+
* @param {ArrayElement} node The node we wish to remove (and it will be returned after removal)
|
|
93
|
+
* @return {ArrayElement|null} The removed node, or null when it was not in this list (nothing is removed)
|
|
94
|
+
*/
|
|
95
|
+
remove(node: ArrayElement): ArrayElement | null;
|
|
96
|
+
/**
|
|
97
|
+
* Retrieve an ArrayElement item from this list by numeric index, otherwise return null.
|
|
98
|
+
* @param {number} index The integer number for retrieving a node by position.
|
|
99
|
+
* @return {ArrayElement|null}
|
|
100
|
+
*/
|
|
101
|
+
item(index: number): ArrayElement | null;
|
|
102
|
+
/**
|
|
103
|
+
* Be able to run forEach on this Arrayable to iterate over the elements.
|
|
104
|
+
* @param {forEachCallback} callback The function to call for-each element
|
|
105
|
+
* @param {Arrayable} thisArg Optional, 'this' reference
|
|
106
|
+
* @returns {Arrayable}
|
|
107
|
+
*/
|
|
108
|
+
forEach(callback: forEachCallback, thisArg?: Arrayable): Arrayable;
|
|
109
|
+
/**
|
|
110
|
+
* Be able to iterate over this class.
|
|
111
|
+
* @returns {Iterator}
|
|
112
|
+
*/
|
|
113
|
+
[Symbol.iterator](): Iterator<ArrayElement>;
|
|
114
|
+
/**
|
|
115
|
+
* Convert an array to an Arrayable.
|
|
116
|
+
* @param {Array} values An array of values which will be converted to elements in this arrayable
|
|
117
|
+
* @param {IsElement} [elementClass=ArrayElement] The class to use for each element
|
|
118
|
+
* @param {IsArrayable<ArrayElement>} [classType=Arrayable] Provide the type of IsArrayable to use.
|
|
119
|
+
* @returns {Arrayable}
|
|
120
|
+
*/
|
|
121
|
+
static fromArray: (values?: Array<any>, elementClass?: typeof ArrayElement, classType?: any) => IsArrayable<IsElement>;
|
|
122
|
+
}
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
4
4
|
value: true
|
|
5
5
|
})
|
|
6
6
|
exports.Arrayable = void 0
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const _ArrayElement = require('./ArrayElement')
|
|
8
|
+
const _ArrayIterator = require('../../recipes/ArrayIterator')
|
|
9
9
|
/**
|
|
10
10
|
* @file arrayable list.
|
|
11
11
|
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file doubly linked list item.
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.1.0
|
|
5
|
-
* @memberOf module:collect-your-stuff
|
|
6
|
-
*/
|
|
7
|
-
import { IsDoubleLinker } from '../../recipes/IsDoubleLinker';
|
|
8
|
-
/**
|
|
9
|
-
* DoubleLinker represents a node in a DoublyLinkedList which is chained by next and prev.
|
|
10
|
-
* @extends Linker
|
|
11
|
-
*/
|
|
12
|
-
export declare class DoubleLinker implements IsDoubleLinker {
|
|
13
|
-
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
14
|
-
readonly classType: typeof DoubleLinker;
|
|
15
|
-
/** The data stored in this linker. */
|
|
16
|
-
data: any;
|
|
17
|
-
/** The linker after this one, or null when this is the last. */
|
|
18
|
-
next: DoubleLinker | null;
|
|
19
|
-
/** The linker before this one, or null when this is the first. */
|
|
20
|
-
prev: DoubleLinker | null;
|
|
21
|
-
/**
|
|
22
|
-
* Create the new DoubleLinker instance, provide the data and optionally the next and prev references.
|
|
23
|
-
* @param {Object} [nodeData={}] The settings for the new linker.
|
|
24
|
-
* @param {*} [nodeData.data=null] The data to be stored in this linker
|
|
25
|
-
* @param {DoubleLinker|null} [nodeData.next=null] The reference to the next linker if any
|
|
26
|
-
* @param {DoubleLinker|null} [nodeData.prev=null] The reference to the previous linker if any
|
|
27
|
-
*/
|
|
28
|
-
constructor({ data, next, prev }?: {
|
|
29
|
-
data?: any;
|
|
30
|
-
next?: DoubleLinker | null;
|
|
31
|
-
prev?: DoubleLinker | null;
|
|
32
|
-
});
|
|
33
|
-
/**
|
|
34
|
-
* Make a new DoubleLinker from the data given if it is not already a valid Linker.
|
|
35
|
-
* @param {DoubleLinker|*} linker Return a valid Linker instance from given data, or even an already valid one.
|
|
36
|
-
* @param {IsDoubleLinker} [classType=DoubleLinker] Provide the type of IsDoubleLinker to use.
|
|
37
|
-
* @return {DoubleLinker}
|
|
38
|
-
*/
|
|
39
|
-
static make: (linker: DoubleLinker | any, classType?: any) => IsDoubleLinker | any;
|
|
40
|
-
/**
|
|
41
|
-
* Convert an array into DoubleLinker instances, return the head and tail DoubleLinkers.
|
|
42
|
-
* @param {Array} [values=[]] Provide an array of data that will be converted to a chain of linkers.
|
|
43
|
-
* @param {IsDoubleLinker} [classType=DoubleLinker] Provide the type of IsDoubleLinker to use.
|
|
44
|
-
* @returns {{head: DoubleLinker, tail: DoubleLinker}}
|
|
45
|
-
*/
|
|
46
|
-
static fromArray: (values?: Array<any>, classType?: any) => {
|
|
47
|
-
head: DoubleLinker | any;
|
|
48
|
-
tail: DoubleLinker | any;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @file doubly linked list item.
|
|
3
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
+
* @version 1.1.0
|
|
5
|
+
* @memberOf module:collect-your-stuff
|
|
6
|
+
*/
|
|
7
|
+
import { IsDoubleLinker } from '../../recipes/IsDoubleLinker';
|
|
8
|
+
/**
|
|
9
|
+
* DoubleLinker represents a node in a DoublyLinkedList which is chained by next and prev.
|
|
10
|
+
* @extends Linker
|
|
11
|
+
*/
|
|
12
|
+
export declare class DoubleLinker implements IsDoubleLinker {
|
|
13
|
+
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
14
|
+
readonly classType: typeof DoubleLinker;
|
|
15
|
+
/** The data stored in this linker. */
|
|
16
|
+
data: any;
|
|
17
|
+
/** The linker after this one, or null when this is the last. */
|
|
18
|
+
next: DoubleLinker | null;
|
|
19
|
+
/** The linker before this one, or null when this is the first. */
|
|
20
|
+
prev: DoubleLinker | null;
|
|
21
|
+
/**
|
|
22
|
+
* Create the new DoubleLinker instance, provide the data and optionally the next and prev references.
|
|
23
|
+
* @param {Object} [nodeData={}] The settings for the new linker.
|
|
24
|
+
* @param {*} [nodeData.data=null] The data to be stored in this linker
|
|
25
|
+
* @param {DoubleLinker|null} [nodeData.next=null] The reference to the next linker if any
|
|
26
|
+
* @param {DoubleLinker|null} [nodeData.prev=null] The reference to the previous linker if any
|
|
27
|
+
*/
|
|
28
|
+
constructor({ data, next, prev }?: {
|
|
29
|
+
data?: any;
|
|
30
|
+
next?: DoubleLinker | null;
|
|
31
|
+
prev?: DoubleLinker | null;
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Make a new DoubleLinker from the data given if it is not already a valid Linker.
|
|
35
|
+
* @param {DoubleLinker|*} linker Return a valid Linker instance from given data, or even an already valid one.
|
|
36
|
+
* @param {IsDoubleLinker} [classType=DoubleLinker] Provide the type of IsDoubleLinker to use.
|
|
37
|
+
* @return {DoubleLinker}
|
|
38
|
+
*/
|
|
39
|
+
static make: (linker: DoubleLinker | any, classType?: any) => IsDoubleLinker | any;
|
|
40
|
+
/**
|
|
41
|
+
* Convert an array into DoubleLinker instances, return the head and tail DoubleLinkers.
|
|
42
|
+
* @param {Array} [values=[]] Provide an array of data that will be converted to a chain of linkers.
|
|
43
|
+
* @param {IsDoubleLinker} [classType=DoubleLinker] Provide the type of IsDoubleLinker to use.
|
|
44
|
+
* @returns {{head: DoubleLinker, tail: DoubleLinker}}
|
|
45
|
+
*/
|
|
46
|
+
static fromArray: (values?: Array<any>, classType?: any) => {
|
|
47
|
+
head: DoubleLinker | any;
|
|
48
|
+
tail: DoubleLinker | any;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
6
6
|
exports.DoubleLinker = void 0
|
|
7
7
|
require('core-js/modules/esnext.iterator.constructor.js')
|
|
8
8
|
require('core-js/modules/esnext.iterator.reduce.js')
|
|
9
|
-
|
|
9
|
+
const _Linker = require('../linked-list/Linker')
|
|
10
10
|
/**
|
|
11
11
|
* DoubleLinker represents a node in a DoublyLinkedList which is chained by next and prev.
|
|
12
12
|
* @extends Linker
|