collect-your-stuff 2.1.1 → 2.2.0
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 +32 -3241
- package/browser/collect-your-stuff.js +1585 -1193
- package/browser/collect-your-stuff.min.js +1 -1
- package/dist/collections/arrayable/ArrayElement.d.ts +33 -38
- package/dist/collections/arrayable/ArrayElement.js +64 -66
- package/dist/collections/arrayable/Arrayable.d.ts +107 -122
- package/dist/collections/arrayable/Arrayable.js +208 -223
- package/dist/collections/doubly-linked-list/DoubleLinker.d.ts +45 -50
- package/dist/collections/doubly-linked-list/DoubleLinker.js +71 -73
- package/dist/collections/doubly-linked-list/DoublyLinkedList.d.ts +108 -125
- package/dist/collections/doubly-linked-list/DoublyLinkedList.js +310 -327
- package/dist/collections/linked-list/LinkedList.d.ts +110 -126
- package/dist/collections/linked-list/LinkedList.js +283 -296
- package/dist/collections/linked-list/Linker.d.ts +41 -46
- package/dist/collections/linked-list/Linker.js +82 -84
- package/dist/collections/linked-tree-list/LinkedTreeList.d.ts +140 -159
- package/dist/collections/linked-tree-list/LinkedTreeList.js +274 -294
- package/dist/collections/linked-tree-list/TreeLinker.d.ts +65 -71
- package/dist/collections/linked-tree-list/TreeLinker.js +91 -94
- package/dist/collections/queue/Queue.d.ts +55 -59
- package/dist/collections/queue/Queue.js +114 -119
- package/dist/collections/queue/Queueable.d.ts +74 -83
- package/dist/collections/queue/Queueable.js +142 -146
- package/dist/collections/queue/TaskQueue.d.ts +59 -68
- package/dist/collections/queue/TaskQueue.js +128 -137
- package/dist/collections/scoped-collection/ScopedCollection.d.ts +42 -0
- package/dist/collections/scoped-collection/ScopedCollection.js +81 -0
- package/dist/collections/scoped-collection/ScopedCollection.min.js +1 -0
- package/dist/collections/stack/Stack.d.ts +60 -64
- package/dist/collections/stack/Stack.js +122 -127
- package/dist/collections/stack/Stackable.d.ts +52 -59
- package/dist/collections/stack/Stackable.js +81 -85
- package/dist/collections/stack/TaskStack.d.ts +56 -65
- package/dist/collections/stack/TaskStack.js +98 -107
- package/dist/main.d.ts +4 -5
- package/dist/main.js +9 -5
- 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 +85 -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 +32 -37
- package/dist/recipes/IsQueue.js +5 -5
- package/dist/recipes/IsScopedCollection.d.ts +27 -0
- package/dist/recipes/IsScopedCollection.js +5 -0
- package/dist/recipes/IsScopedCollection.min.js +1 -0
- package/dist/recipes/IsStack.d.ts +31 -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 +42 -55
- package/dist/recipes/Runnable.js +63 -69
- package/dist/recipes/TreeLinkerIterator.d.ts +20 -20
- package/dist/recipes/TreeLinkerIterator.js +36 -36
- package/dist/recipes/recipes.d.ts +12 -15
- package/dist/recipes/recipes.js +19 -22
- package/dist/services/parseTree.d.ts +8 -9
- package/dist/services/parseTree.js +23 -24
- package/dist/services/parseTreeNext.d.ts +16 -17
- package/dist/services/parseTreeNext.js +41 -42
- package/dist/services/services.d.ts +10 -13
- package/dist/services/services.js +19 -22
- package/package.json +4 -4
|
@@ -1,66 +1,64 @@
|
|
|
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
|
|
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
|
|
28
|
-
* @param
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
*
|
|
46
|
-
* @param
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
references
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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 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 element Return a valid ArrayElement instance from given data, or even an already valid one.
|
|
28
|
+
* @param classType Provide the type of IsElement to use.
|
|
29
|
+
*/
|
|
30
|
+
exports.ArrayElement = ArrayElement
|
|
31
|
+
ArrayElement.make = (element, classType = ArrayElement) => {
|
|
32
|
+
if (element === null || typeof element !== 'object') {
|
|
33
|
+
// It is not an object (or it is null), so instantiate the Element with element as the data
|
|
34
|
+
return new classType(element)
|
|
35
|
+
}
|
|
36
|
+
if (element.classType) {
|
|
37
|
+
// Already valid Element, return as-is
|
|
38
|
+
return element
|
|
39
|
+
}
|
|
40
|
+
// Create the new node as the configured #classType
|
|
41
|
+
return new classType(element)
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Convert an array into Element instances, return the head and tail Elements.
|
|
45
|
+
* @param values Provide an array of data that will be converted to array of elements.
|
|
46
|
+
* @param classType Provide the type of IsElement to use.
|
|
47
|
+
*/
|
|
48
|
+
ArrayElement.fromArray = (values = [], classType = ArrayElement) => values.reduce((references, element) => {
|
|
49
|
+
const newElement = classType.make(element, classType)
|
|
50
|
+
if (!references.head.length) {
|
|
51
|
+
// Initialize the head and tail with the new node
|
|
52
|
+
return {
|
|
53
|
+
head: [newElement],
|
|
54
|
+
tail: newElement
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Only update the tail once head has been set, tail is always the most recent node
|
|
58
|
+
references.head.push(newElement)
|
|
59
|
+
references.tail = newElement
|
|
60
|
+
return references
|
|
61
|
+
}, {
|
|
62
|
+
head: [],
|
|
63
|
+
tail: null
|
|
64
|
+
})
|
|
@@ -1,122 +1,107 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
* @
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Insert a new node (or data)
|
|
62
|
-
* @param
|
|
63
|
-
* @param
|
|
64
|
-
* @
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
*
|
|
70
|
-
* @param
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
*
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
*
|
|
87
|
-
* @
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
*
|
|
92
|
-
* @param
|
|
93
|
-
* @
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
*
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
*
|
|
104
|
-
* @param
|
|
105
|
-
|
|
106
|
-
|
|
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
|
+
* arrayable list.
|
|
3
|
+
*/
|
|
4
|
+
import { ArrayElement } from './ArrayElement';
|
|
5
|
+
import { forEachCallback, IsArrayable } from '../../recipes/IsArrayable';
|
|
6
|
+
import { IsElement } from '../../recipes/IsElement';
|
|
7
|
+
/**
|
|
8
|
+
* Arrayable represents a collection stored as an array.
|
|
9
|
+
*/
|
|
10
|
+
export declare class Arrayable implements IsArrayable<ArrayElement>, Iterable<ArrayElement> {
|
|
11
|
+
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
12
|
+
readonly classType: typeof Arrayable;
|
|
13
|
+
/** The array which stores the elements of this Arrayable. */
|
|
14
|
+
innerList: Array<ArrayElement>;
|
|
15
|
+
/** Whether the inner list has been initialized (it can only be initialized once). */
|
|
16
|
+
initialized: boolean;
|
|
17
|
+
/** The class used to wrap the data given to this Arrayable as elements. */
|
|
18
|
+
elementClass: typeof ArrayElement;
|
|
19
|
+
/**
|
|
20
|
+
* Create the new Arrayable instance, configure the Arrayable class.
|
|
21
|
+
* @param elementClass The class used to wrap given data as elements.
|
|
22
|
+
*/
|
|
23
|
+
constructor(elementClass?: typeof ArrayElement);
|
|
24
|
+
/**
|
|
25
|
+
* Find the position of an element which must be in this list.
|
|
26
|
+
* @param node The element to find
|
|
27
|
+
* @throws {Error} When the element is not in this list
|
|
28
|
+
*/
|
|
29
|
+
private indexOfElement;
|
|
30
|
+
/**
|
|
31
|
+
* Initialize the inner list, should only run once.
|
|
32
|
+
* @param initialList Give the array of elements to start in this Arrayable.
|
|
33
|
+
*/
|
|
34
|
+
initialize(initialList: Array<ArrayElement>): Arrayable;
|
|
35
|
+
/**
|
|
36
|
+
* Retrieve the innerList used (the list itself, not a copy).
|
|
37
|
+
*/
|
|
38
|
+
get list(): Array<ArrayElement>;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieve the first Element from the Arrayable
|
|
41
|
+
* @returns The first element, or null when the Arrayable is empty
|
|
42
|
+
*/
|
|
43
|
+
get first(): ArrayElement | null;
|
|
44
|
+
/**
|
|
45
|
+
* Retrieve the last Element from the Arrayable
|
|
46
|
+
* @returns The last element, or null when the Arrayable is empty
|
|
47
|
+
*/
|
|
48
|
+
get last(): ArrayElement | null;
|
|
49
|
+
/**
|
|
50
|
+
* Return the length of the list.
|
|
51
|
+
*/
|
|
52
|
+
get length(): number;
|
|
53
|
+
/**
|
|
54
|
+
* Insert a new node (or data) after a node.
|
|
55
|
+
* @param node The existing node as reference, or null to insert at the start of the list
|
|
56
|
+
* @param newNode The new node to go after the existing node
|
|
57
|
+
* @throws {Error} When the reference node is not in this list
|
|
58
|
+
*/
|
|
59
|
+
insertAfter(node: ArrayElement | null, newNode: ArrayElement | any): Arrayable;
|
|
60
|
+
/**
|
|
61
|
+
* Insert a new node (or data) before a node.
|
|
62
|
+
* @param node The existing node as reference, or null to insert at the end of the list
|
|
63
|
+
* @param newNode The new node to go before the existing node
|
|
64
|
+
* @throws {Error} When the reference node is not in this list
|
|
65
|
+
*/
|
|
66
|
+
insertBefore(node: ArrayElement | null, newNode: ArrayElement | any): Arrayable;
|
|
67
|
+
/**
|
|
68
|
+
* Add a node (or data) after the given (or last) node in the list.
|
|
69
|
+
* @param node The new node to add to the end of the list
|
|
70
|
+
* @param after The existing last node
|
|
71
|
+
*/
|
|
72
|
+
append(node: ArrayElement | any, after?: ArrayElement | null): Arrayable;
|
|
73
|
+
/**
|
|
74
|
+
* Add a node (or data) before the given (or first) node in the list.
|
|
75
|
+
* @param node The new node to add to the start of the list
|
|
76
|
+
* @param before The existing first node
|
|
77
|
+
*/
|
|
78
|
+
prepend(node: ArrayElement | any, before?: ArrayElement | null): Arrayable;
|
|
79
|
+
/**
|
|
80
|
+
* Remove an element from this arrayable.
|
|
81
|
+
* @param node The node we wish to remove (and it will be returned after removal)
|
|
82
|
+
* @returns The removed node, or null when it was not in this list (nothing is removed)
|
|
83
|
+
*/
|
|
84
|
+
remove(node: ArrayElement): ArrayElement | null;
|
|
85
|
+
/**
|
|
86
|
+
* Retrieve an ArrayElement item from this list by numeric index, otherwise return null.
|
|
87
|
+
* @param index The integer number for retrieving a node by position.
|
|
88
|
+
*/
|
|
89
|
+
item(index: number): ArrayElement | null;
|
|
90
|
+
/**
|
|
91
|
+
* Be able to run forEach on this Arrayable to iterate over the elements.
|
|
92
|
+
* @param callback The function to call for-each element
|
|
93
|
+
* @param thisArg Optional, 'this' reference
|
|
94
|
+
*/
|
|
95
|
+
forEach(callback: forEachCallback, thisArg?: Arrayable): Arrayable;
|
|
96
|
+
/**
|
|
97
|
+
* Be able to iterate over this class.
|
|
98
|
+
*/
|
|
99
|
+
[Symbol.iterator](): Iterator<ArrayElement>;
|
|
100
|
+
/**
|
|
101
|
+
* Convert an array to an Arrayable.
|
|
102
|
+
* @param values An array of values which will be converted to elements in this arrayable
|
|
103
|
+
* @param elementClass The class to use for each element
|
|
104
|
+
* @param classType Provide the type of IsArrayable to use.
|
|
105
|
+
*/
|
|
106
|
+
static fromArray: (values?: Array<any>, elementClass?: typeof ArrayElement, classType?: any) => IsArrayable<IsElement>;
|
|
107
|
+
}
|