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