collect-your-stuff 2.1.2 → 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 -3926
- package/browser/collect-your-stuff.js +912 -549
- package/browser/collect-your-stuff.min.js +1 -1
- package/dist/collections/arrayable/ArrayElement.d.ts +6 -11
- package/dist/collections/arrayable/ArrayElement.js +5 -7
- package/dist/collections/arrayable/Arrayable.d.ts +22 -37
- package/dist/collections/arrayable/Arrayable.js +208 -223
- package/dist/collections/doubly-linked-list/DoubleLinker.d.ts +9 -14
- package/dist/collections/doubly-linked-list/DoubleLinker.js +71 -73
- package/dist/collections/doubly-linked-list/DoublyLinkedList.d.ts +19 -36
- package/dist/collections/doubly-linked-list/DoublyLinkedList.js +310 -327
- package/dist/collections/linked-list/LinkedList.d.ts +20 -36
- package/dist/collections/linked-list/LinkedList.js +283 -296
- package/dist/collections/linked-list/Linker.d.ts +8 -13
- package/dist/collections/linked-list/Linker.js +82 -84
- package/dist/collections/linked-tree-list/LinkedTreeList.d.ts +24 -43
- package/dist/collections/linked-tree-list/LinkedTreeList.js +274 -294
- package/dist/collections/linked-tree-list/TreeLinker.d.ts +14 -20
- package/dist/collections/linked-tree-list/TreeLinker.js +91 -94
- package/dist/collections/queue/Queue.d.ts +10 -14
- package/dist/collections/queue/Queue.js +114 -121
- package/dist/collections/queue/Queueable.d.ts +13 -22
- package/dist/collections/queue/Queueable.js +142 -148
- package/dist/collections/queue/TaskQueue.d.ts +8 -17
- 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 +11 -15
- package/dist/collections/stack/Stack.js +122 -129
- package/dist/collections/stack/Stackable.d.ts +9 -16
- package/dist/collections/stack/Stackable.js +81 -85
- package/dist/collections/stack/TaskStack.d.ts +8 -17
- package/dist/collections/stack/TaskStack.js +98 -107
- package/dist/main.d.ts +67 -68
- package/dist/main.js +8 -4
- package/dist/main.min.js +1 -1
- package/dist/recipes/ArrayIterator.d.ts +4 -4
- package/dist/recipes/ArrayIterator.js +4 -4
- package/dist/recipes/DoubleLinkerIterator.d.ts +3 -3
- package/dist/recipes/DoubleLinkerIterator.js +3 -3
- package/dist/recipes/IsArrayable.d.ts +13 -33
- package/dist/recipes/IsQueue.d.ts +4 -9
- 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 +4 -9
- package/dist/recipes/IsTreeNode.d.ts +1 -1
- package/dist/recipes/LinkerIterator.d.ts +3 -3
- package/dist/recipes/LinkerIterator.js +3 -3
- package/dist/recipes/Runnable.d.ts +3 -16
- package/dist/recipes/Runnable.js +3 -9
- package/dist/recipes/TreeLinkerIterator.d.ts +4 -4
- package/dist/recipes/TreeLinkerIterator.js +36 -36
- package/dist/recipes/recipes.d.ts +1 -4
- package/dist/recipes/recipes.js +19 -22
- package/dist/services/parseTree.d.ts +2 -3
- package/dist/services/parseTree.js +23 -24
- package/dist/services/parseTreeNext.d.ts +2 -3
- package/dist/services/parseTreeNext.js +2 -3
- package/dist/services/services.d.ts +1 -4
- package/dist/services/services.js +19 -22
- package/package.json +4 -4
|
@@ -1,73 +1,71 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.DoubleLinker = void 0
|
|
7
|
-
require('core-js/modules/esnext.iterator.constructor.js')
|
|
8
|
-
require('core-js/modules/esnext.iterator.reduce.js')
|
|
9
|
-
const _Linker = require('../linked-list/Linker')
|
|
10
|
-
/**
|
|
11
|
-
* DoubleLinker represents a node in a DoublyLinkedList which is chained by next and prev.
|
|
12
|
-
* @extends Linker
|
|
13
|
-
*/
|
|
14
|
-
class DoubleLinker {
|
|
15
|
-
/**
|
|
16
|
-
* Create the new DoubleLinker instance, provide the data and optionally the next and prev references.
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
*/
|
|
22
|
-
constructor ({
|
|
23
|
-
data = null,
|
|
24
|
-
next = null,
|
|
25
|
-
prev = null
|
|
26
|
-
} = {}) {
|
|
27
|
-
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
28
|
-
this.classType = DoubleLinker
|
|
29
|
-
/** The data stored in this linker. */
|
|
30
|
-
this.data = null
|
|
31
|
-
/** The linker after this one, or null when this is the last. */
|
|
32
|
-
this.next = null
|
|
33
|
-
/** The linker before this one, or null when this is the first. */
|
|
34
|
-
this.prev = null
|
|
35
|
-
this.data = data
|
|
36
|
-
this.next = next
|
|
37
|
-
this.prev = prev
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Make a new DoubleLinker from the data given if it is not already a valid Linker.
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*
|
|
52
|
-
* @param
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
references
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
tail: null
|
|
73
|
-
})
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.DoubleLinker = void 0
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js')
|
|
8
|
+
require('core-js/modules/esnext.iterator.reduce.js')
|
|
9
|
+
const _Linker = require('../linked-list/Linker')
|
|
10
|
+
/**
|
|
11
|
+
* DoubleLinker represents a node in a DoublyLinkedList which is chained by next and prev.
|
|
12
|
+
* @extends Linker
|
|
13
|
+
*/
|
|
14
|
+
class DoubleLinker {
|
|
15
|
+
/**
|
|
16
|
+
* Create the new DoubleLinker instance, provide the data and optionally the next and prev references.
|
|
17
|
+
* @param nodeData The settings for the new linker.
|
|
18
|
+
* @param nodeData.data The data to be stored in this linker
|
|
19
|
+
* @param nodeData.next The reference to the next linker if any
|
|
20
|
+
* @param nodeData.prev The reference to the previous linker if any
|
|
21
|
+
*/
|
|
22
|
+
constructor ({
|
|
23
|
+
data = null,
|
|
24
|
+
next = null,
|
|
25
|
+
prev = null
|
|
26
|
+
} = {}) {
|
|
27
|
+
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
28
|
+
this.classType = DoubleLinker
|
|
29
|
+
/** The data stored in this linker. */
|
|
30
|
+
this.data = null
|
|
31
|
+
/** The linker after this one, or null when this is the last. */
|
|
32
|
+
this.next = null
|
|
33
|
+
/** The linker before this one, or null when this is the first. */
|
|
34
|
+
this.prev = null
|
|
35
|
+
this.data = data
|
|
36
|
+
this.next = next
|
|
37
|
+
this.prev = prev
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Make a new DoubleLinker from the data given if it is not already a valid Linker.
|
|
42
|
+
* @param linker Return a valid Linker instance from given data, or even an already valid one.
|
|
43
|
+
* @param classType Provide the type of IsDoubleLinker to use.
|
|
44
|
+
*/
|
|
45
|
+
exports.DoubleLinker = DoubleLinker
|
|
46
|
+
DoubleLinker.make = (linker, classType = DoubleLinker) => {
|
|
47
|
+
return _Linker.Linker.make(linker, classType)
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Convert an array into DoubleLinker instances, return the head and tail DoubleLinkers.
|
|
51
|
+
* @param values Provide an array of data that will be converted to a chain of linkers.
|
|
52
|
+
* @param classType Provide the type of IsDoubleLinker to use.
|
|
53
|
+
*/
|
|
54
|
+
DoubleLinker.fromArray = (values = [], classType = DoubleLinker) => values.reduce((references, linker) => {
|
|
55
|
+
const newLinker = classType.make(linker, classType)
|
|
56
|
+
if (references.head === null) {
|
|
57
|
+
// Initialize the head and tail with the new node
|
|
58
|
+
return {
|
|
59
|
+
head: newLinker,
|
|
60
|
+
tail: newLinker
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
newLinker.prev = references.tail
|
|
64
|
+
// Only update the tail once head has been set, tail is always the most recent node
|
|
65
|
+
references.tail.next = newLinker
|
|
66
|
+
references.tail = newLinker
|
|
67
|
+
return references
|
|
68
|
+
}, {
|
|
69
|
+
head: null,
|
|
70
|
+
tail: null
|
|
71
|
+
})
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.1.0
|
|
5
|
-
* @memberOf module:collect-your-stuff
|
|
2
|
+
* doubly linked list.
|
|
6
3
|
*/
|
|
7
4
|
import { DoubleLinker } from './DoubleLinker';
|
|
8
5
|
import { forEachCallback, IsArrayable } from '../../recipes/IsArrayable';
|
|
@@ -26,100 +23,86 @@ export declare class DoublyLinkedList implements IsArrayable<DoubleLinker>, Iter
|
|
|
26
23
|
private countCache;
|
|
27
24
|
/**
|
|
28
25
|
* Create the new DoublyLinkedList instance.
|
|
29
|
-
* @param
|
|
26
|
+
* @param linkerClass The class used to wrap given data as linkers.
|
|
30
27
|
*/
|
|
31
28
|
constructor(linkerClass?: typeof DoubleLinker);
|
|
32
29
|
/**
|
|
33
30
|
* Initialize the inner list, should only run once.
|
|
34
|
-
* @param
|
|
35
|
-
* @return {DoublyLinkedList}
|
|
31
|
+
* @param initialList Give the list of double-linkers to start in this doubly linked-list.
|
|
36
32
|
*/
|
|
37
33
|
initialize(initialList: DoubleLinker): DoublyLinkedList;
|
|
38
34
|
/**
|
|
39
35
|
* Retrieve the innerList used (the list itself, not a copy).
|
|
40
|
-
* @returns {DoubleLinker}
|
|
41
36
|
*/
|
|
42
37
|
get list(): DoubleLinker;
|
|
43
38
|
/**
|
|
44
39
|
* Retrieve the first DoubleLinker in the list.
|
|
45
|
-
* @returns {DoubleLinker}
|
|
46
40
|
*/
|
|
47
41
|
get first(): DoubleLinker | null;
|
|
48
42
|
/**
|
|
49
43
|
* Retrieve the last DoubleLinker in the list. The end is remembered, so this does not walk the list.
|
|
50
|
-
* @returns {DoubleLinker}
|
|
51
44
|
*/
|
|
52
45
|
get last(): DoubleLinker | null;
|
|
53
46
|
/**
|
|
54
47
|
* Return the length of the list. It is kept up to date by the list's own methods, so this does not walk the list
|
|
55
48
|
* (call reset() after linkers were changed directly).
|
|
56
|
-
* @returns {number}
|
|
57
49
|
*/
|
|
58
50
|
get length(): number;
|
|
59
51
|
/**
|
|
60
52
|
* Insert a new node (or data) after a node.
|
|
61
|
-
* @param
|
|
62
|
-
* @param
|
|
63
|
-
* @returns {DoublyLinkedList}
|
|
53
|
+
* @param node The existing node as reference (which must be in this list, this is not checked), or null to insert at the start of the list
|
|
54
|
+
* @param newNode The new node to go after the existing node
|
|
64
55
|
*/
|
|
65
56
|
insertAfter(node: DoubleLinker | null, newNode: DoubleLinker | any): DoublyLinkedList;
|
|
66
57
|
/**
|
|
67
58
|
* Insert a new node (or data) before a node.
|
|
68
|
-
* @param
|
|
69
|
-
* @param
|
|
70
|
-
* @returns {DoublyLinkedList}
|
|
59
|
+
* @param node The existing node as reference (which must be in this list, this is not checked), or null to insert at the end of the list
|
|
60
|
+
* @param newNode The new node to go before the existing node
|
|
71
61
|
*/
|
|
72
62
|
insertBefore(node: DoubleLinker | null, newNode: DoubleLinker | any): DoublyLinkedList;
|
|
73
63
|
/**
|
|
74
64
|
* Add a node (or data) after the given (or last) node in the list.
|
|
75
|
-
* @param
|
|
76
|
-
* @param
|
|
77
|
-
* @returns {DoubleLinker}
|
|
65
|
+
* @param node The new node to add to the end of the list
|
|
66
|
+
* @param after The existing last node
|
|
78
67
|
*/
|
|
79
68
|
append(node: DoubleLinker | any, after?: DoubleLinker): DoublyLinkedList;
|
|
80
69
|
/**
|
|
81
70
|
* Add a node (or data) before the given (or first) node in the list.
|
|
82
|
-
* @param
|
|
83
|
-
* @param
|
|
84
|
-
* @returns {DoubleLinker}
|
|
71
|
+
* @param node The new node to add to the start of the list
|
|
72
|
+
* @param before The existing first node
|
|
85
73
|
*/
|
|
86
74
|
prepend(node: DoubleLinker | any, before?: DoubleLinker): DoublyLinkedList;
|
|
87
75
|
/**
|
|
88
76
|
* Remove a linker from this linked list.
|
|
89
|
-
* @param
|
|
90
|
-
* @return {DoubleLinker}
|
|
77
|
+
* @param node The node we wish to remove (and it will be returned after removal)
|
|
91
78
|
*/
|
|
92
79
|
remove(node: DoubleLinker | null): DoubleLinker | null;
|
|
93
80
|
/**
|
|
94
81
|
* Refresh all references (the head, the end and the length) by walking the list once, and return the head. The list's
|
|
95
82
|
* own methods keep these up to date, so this is only needed after linkers were changed directly.
|
|
96
|
-
* @return {DoubleLinker|null}
|
|
97
83
|
*/
|
|
98
84
|
reset(): DoubleLinker | null;
|
|
99
85
|
/**
|
|
100
86
|
* Retrieve a DoubleLinker item from this list by numeric index, otherwise return null.
|
|
101
|
-
* @param
|
|
102
|
-
* @returns {DoubleLinker|null}
|
|
87
|
+
* @param index The integer number for retrieving a node by position.
|
|
103
88
|
*/
|
|
104
89
|
item(index: number): DoubleLinker;
|
|
105
90
|
/**
|
|
106
91
|
* Be able to run forEach on this DoublyLinkedList to iterate over the DoubleLinker Items.
|
|
107
|
-
* @param
|
|
108
|
-
* @param
|
|
109
|
-
* @
|
|
92
|
+
* @param callback The function to call for-each double linker
|
|
93
|
+
* @param thisArg Optional, 'this' reference
|
|
94
|
+
* @returns The list which was iterated.
|
|
110
95
|
*/
|
|
111
96
|
forEach(callback: forEachCallback, thisArg?: DoublyLinkedList): DoublyLinkedList;
|
|
112
97
|
/**
|
|
113
98
|
* Be able to iterate over this class.
|
|
114
|
-
* @returns {Iterator}
|
|
115
99
|
*/
|
|
116
100
|
[Symbol.iterator](): Iterator<DoubleLinker>;
|
|
117
101
|
/**
|
|
118
102
|
* Convert an array into a DoublyLinkedList instance, return the new instance.
|
|
119
|
-
* @param
|
|
120
|
-
* @param
|
|
121
|
-
* @param
|
|
122
|
-
* @returns {DoublyLinkedList}
|
|
103
|
+
* @param values An array of values which will be converted to linkers in this doubly-linked-list
|
|
104
|
+
* @param linkerClass The class to use for each linker
|
|
105
|
+
* @param classType Provide the type of IsArrayable to use.
|
|
123
106
|
*/
|
|
124
107
|
static fromArray: (values?: Array<any>, linkerClass?: typeof DoubleLinker, classType?: any) => IsArrayable<IsDoubleLinker> | any;
|
|
125
108
|
}
|