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.
Files changed (63) hide show
  1. package/README.md +32 -3926
  2. package/browser/collect-your-stuff.js +912 -549
  3. package/browser/collect-your-stuff.min.js +1 -1
  4. package/dist/collections/arrayable/ArrayElement.d.ts +6 -11
  5. package/dist/collections/arrayable/ArrayElement.js +5 -7
  6. package/dist/collections/arrayable/Arrayable.d.ts +22 -37
  7. package/dist/collections/arrayable/Arrayable.js +208 -223
  8. package/dist/collections/doubly-linked-list/DoubleLinker.d.ts +9 -14
  9. package/dist/collections/doubly-linked-list/DoubleLinker.js +71 -73
  10. package/dist/collections/doubly-linked-list/DoublyLinkedList.d.ts +19 -36
  11. package/dist/collections/doubly-linked-list/DoublyLinkedList.js +310 -327
  12. package/dist/collections/linked-list/LinkedList.d.ts +20 -36
  13. package/dist/collections/linked-list/LinkedList.js +283 -296
  14. package/dist/collections/linked-list/Linker.d.ts +8 -13
  15. package/dist/collections/linked-list/Linker.js +82 -84
  16. package/dist/collections/linked-tree-list/LinkedTreeList.d.ts +24 -43
  17. package/dist/collections/linked-tree-list/LinkedTreeList.js +274 -294
  18. package/dist/collections/linked-tree-list/TreeLinker.d.ts +14 -20
  19. package/dist/collections/linked-tree-list/TreeLinker.js +91 -94
  20. package/dist/collections/queue/Queue.d.ts +10 -14
  21. package/dist/collections/queue/Queue.js +114 -121
  22. package/dist/collections/queue/Queueable.d.ts +13 -22
  23. package/dist/collections/queue/Queueable.js +142 -148
  24. package/dist/collections/queue/TaskQueue.d.ts +8 -17
  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 +11 -15
  30. package/dist/collections/stack/Stack.js +122 -129
  31. package/dist/collections/stack/Stackable.d.ts +9 -16
  32. package/dist/collections/stack/Stackable.js +81 -85
  33. package/dist/collections/stack/TaskStack.d.ts +8 -17
  34. package/dist/collections/stack/TaskStack.js +98 -107
  35. package/dist/main.d.ts +67 -68
  36. package/dist/main.js +8 -4
  37. package/dist/main.min.js +1 -1
  38. package/dist/recipes/ArrayIterator.d.ts +4 -4
  39. package/dist/recipes/ArrayIterator.js +4 -4
  40. package/dist/recipes/DoubleLinkerIterator.d.ts +3 -3
  41. package/dist/recipes/DoubleLinkerIterator.js +3 -3
  42. package/dist/recipes/IsArrayable.d.ts +13 -33
  43. package/dist/recipes/IsQueue.d.ts +4 -9
  44. package/dist/recipes/IsScopedCollection.d.ts +27 -0
  45. package/dist/recipes/IsScopedCollection.js +5 -0
  46. package/dist/recipes/IsScopedCollection.min.js +1 -0
  47. package/dist/recipes/IsStack.d.ts +4 -9
  48. package/dist/recipes/IsTreeNode.d.ts +1 -1
  49. package/dist/recipes/LinkerIterator.d.ts +3 -3
  50. package/dist/recipes/LinkerIterator.js +3 -3
  51. package/dist/recipes/Runnable.d.ts +3 -16
  52. package/dist/recipes/Runnable.js +3 -9
  53. package/dist/recipes/TreeLinkerIterator.d.ts +4 -4
  54. package/dist/recipes/TreeLinkerIterator.js +36 -36
  55. package/dist/recipes/recipes.d.ts +1 -4
  56. package/dist/recipes/recipes.js +19 -22
  57. package/dist/services/parseTree.d.ts +2 -3
  58. package/dist/services/parseTree.js +23 -24
  59. package/dist/services/parseTreeNext.d.ts +2 -3
  60. package/dist/services/parseTreeNext.js +2 -3
  61. package/dist/services/services.d.ts +1 -4
  62. package/dist/services/services.js +19 -22
  63. package/package.json +4 -4
@@ -1,84 +1,82 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.Linker = void 0
7
- require('core-js/modules/esnext.iterator.constructor.js')
8
- require('core-js/modules/esnext.iterator.reduce.js')
9
- const _ArrayElement = require('../arrayable/ArrayElement')
10
- /**
11
- * Linker represents a node in a LinkedList.
12
- * @extends ArrayElement
13
- */
14
- class Linker {
15
- /**
16
- * Create the new Linker instance, provide the data and optionally give the next Linker.
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 {Linker|null} [nodeData.next=null] The reference to the next linker if any
20
- */
21
- constructor ({
22
- data = null,
23
- next = null
24
- } = {}) {
25
- /** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
26
- this.classType = Linker
27
- /** The data stored in this linker. */
28
- this.data = null
29
- /** The linker after this one, or null when this is the last. */
30
- this.next = null
31
- this.data = data
32
- this.next = next
33
- }
34
- }
35
- /**
36
- * Make a new Linker from the data given if it is not already a valid Linker.
37
- * @param {Linker|*} linker Return a valid Linker instance from given data, or even an already valid one.
38
- * @param {IsLinker} [classType=Linker] Provide the type of IsLinker to use.
39
- * @return {Linker}
40
- */
41
- exports.Linker = Linker
42
- Linker.make = (linker, classType = Linker) => {
43
- if (linker === null || typeof linker !== 'object') {
44
- // It is not an object (or it is null), so instantiate the Linker with element as the data
45
- return new classType({
46
- data: linker
47
- })
48
- }
49
- if (linker.classType) {
50
- // Already valid Linker, return as-is
51
- return linker
52
- }
53
- if (!('data' in linker)) {
54
- // Not the settings for a linker (which would have data, even if it is falsy), so it is the data itself
55
- linker = {
56
- data: linker
57
- }
58
- }
59
- // Create the new node as the configured #classType
60
- return _ArrayElement.ArrayElement.make(linker, classType)
61
- }
62
- /**
63
- * Convert an array into Linker instances, return the head and tail Linkers.
64
- * @param {Array} [values=[]] Provide an array of data that will be converted to a chain of linkers.
65
- * @param {IsLinker} [classType=Linker] Provide the type of IsLinker to use.
66
- * @returns {{head: Linker, tail: Linker}}
67
- */
68
- Linker.fromArray = (values = [], classType = Linker) => values.reduce((references, linker) => {
69
- const newLinker = classType.make(linker, classType)
70
- if (references.head === null) {
71
- // Initialize the head and tail with the new node
72
- return {
73
- head: newLinker,
74
- tail: newLinker
75
- }
76
- }
77
- // Only update the tail once head has been set, tail is always the most recent node
78
- references.tail.next = newLinker
79
- references.tail = newLinker
80
- return references
81
- }, {
82
- head: null,
83
- tail: null
84
- })
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.Linker = void 0
7
+ require('core-js/modules/esnext.iterator.constructor.js')
8
+ require('core-js/modules/esnext.iterator.reduce.js')
9
+ const _ArrayElement = require('../arrayable/ArrayElement')
10
+ /**
11
+ * Linker represents a node in a LinkedList.
12
+ * @extends ArrayElement
13
+ */
14
+ class Linker {
15
+ /**
16
+ * Create the new Linker instance, provide the data and optionally give the next Linker.
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
+ */
21
+ constructor ({
22
+ data = null,
23
+ next = null
24
+ } = {}) {
25
+ /** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
26
+ this.classType = Linker
27
+ /** The data stored in this linker. */
28
+ this.data = null
29
+ /** The linker after this one, or null when this is the last. */
30
+ this.next = null
31
+ this.data = data
32
+ this.next = next
33
+ }
34
+ }
35
+ /**
36
+ * Make a new Linker from the data given if it is not already a valid Linker.
37
+ * @param linker Return a valid Linker instance from given data, or even an already valid one.
38
+ * @param classType Provide the type of IsLinker to use.
39
+ */
40
+ exports.Linker = Linker
41
+ Linker.make = (linker, classType = Linker) => {
42
+ if (linker === null || typeof linker !== 'object') {
43
+ // It is not an object (or it is null), so instantiate the Linker with element as the data
44
+ return new classType({
45
+ data: linker
46
+ })
47
+ }
48
+ if (linker.classType) {
49
+ // Already valid Linker, return as-is
50
+ return linker
51
+ }
52
+ if (!('data' in linker)) {
53
+ // Not the settings for a linker (which would have data, even if it is falsy), so it is the data itself
54
+ linker = {
55
+ data: linker
56
+ }
57
+ }
58
+ // Create the new node as the configured #classType
59
+ return _ArrayElement.ArrayElement.make(linker, classType)
60
+ }
61
+ /**
62
+ * Convert an array into Linker instances, return the head and tail Linkers.
63
+ * @param values Provide an array of data that will be converted to a chain of linkers.
64
+ * @param classType Provide the type of IsLinker to use.
65
+ */
66
+ Linker.fromArray = (values = [], classType = Linker) => values.reduce((references, linker) => {
67
+ const newLinker = classType.make(linker, classType)
68
+ if (references.head === null) {
69
+ // Initialize the head and tail with the new node
70
+ return {
71
+ head: newLinker,
72
+ tail: newLinker
73
+ }
74
+ }
75
+ // Only update the tail once head has been set, tail is always the most recent node
76
+ references.tail.next = newLinker
77
+ references.tail = newLinker
78
+ return references
79
+ }, {
80
+ head: null,
81
+ tail: null
82
+ })
@@ -1,8 +1,5 @@
1
1
  /**
2
- * @file doubly linked tree list.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.1.0
5
- * @memberOf module:collect-your-stuff
2
+ * doubly linked tree list.
6
3
  */
7
4
  import { TreeLinker } from './TreeLinker';
8
5
  import { forEachCallback } from '../../recipes/IsArrayable';
@@ -29,131 +26,115 @@ export declare class LinkedTreeList implements IsTree, Iterable<TreeLinker> {
29
26
  private ownerNode;
30
27
  /**
31
28
  * Create the new LinkedTreeList instance, configure the list class.
32
- * @param {TreeLinker} [linkerClass=TreeLinker] The class used to wrap given data as tree linkers.
29
+ * @param linkerClass The class used to wrap given data as tree linkers.
33
30
  */
34
31
  constructor(linkerClass?: typeof TreeLinker);
35
32
  /**
36
33
  * Initialize the inner list, should only run once.
37
- * @param {TreeLinker} initialList Give the list of tree-linkers to start in this linked-tree-list.
38
- * @return {LinkedTreeList}
34
+ * @param initialList Give the list of tree-linkers to start in this linked-tree-list.
39
35
  */
40
36
  initialize(initialList: TreeLinker): LinkedTreeList;
41
37
  /**
42
38
  * Retrieve the innerList used (the list itself, not a copy).
43
- * @returns {TreeLinker}
44
39
  */
45
40
  get list(): TreeLinker;
46
41
  /**
47
42
  * Retrieve the first TreeLinker in the list.
48
- * @returns {TreeLinker}
49
43
  */
50
44
  get first(): TreeLinker;
51
45
  /**
52
46
  * Retrieve the last TreeLinker in the list. The end is remembered, so this does not walk the list.
53
- * @returns {TreeLinker}
54
47
  */
55
48
  get last(): TreeLinker;
56
49
  /**
57
50
  * 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
58
51
  * (call reset() after linkers were changed directly).
59
- * @returns {number}
60
52
  */
61
53
  get length(): number;
62
54
  /**
63
55
  * Get the parent of this tree list: the node these linkers are the children of (remembered even while the list is
64
56
  * empty), or null for the linkers at the top of a tree.
65
- * @return {TreeLinker|null}
66
57
  */
67
58
  get parent(): TreeLinker | null;
68
59
  /**
69
60
  * Set the parent of this tree list: every linker in it gets the node as its parent, and the node gets this list as its
70
61
  * children. Linkers added to the list later get this parent too.
71
- * @param {TreeLinker|null} parent The new node to use as the parent for this group of children
62
+ * @param parent The new node to use as the parent for this group of children
72
63
  */
73
64
  set parent(parent: TreeLinker | null);
74
65
  /**
75
66
  * Return the root parent of the entire tree.
76
- * @return {TreeLinker}
77
67
  */
78
68
  get rootParent(): TreeLinker;
79
69
  /**
80
70
  * Set the children on a parent item.
81
- * @param {TreeLinker} item The TreeLinker node (one of the linkers of this list) that will be the parent of the children
82
- * @param {LinkedTreeList|null} [children=null] The LinkedTreeList which has the child nodes to use, or null to remove the children of the item
71
+ * @param item The TreeLinker node (one of the linkers of this list) that will be the parent of the children
72
+ * @param children The LinkedTreeList which has the child nodes to use, or null to remove the children of the item
83
73
  * @throws {Error} When the item is not one of the linkers of this list
84
74
  */
85
75
  setChildren(item: TreeLinker, children?: LinkedTreeList | null): void;
86
76
  /**
87
77
  * Make a linker of the given node (or data) and make this list's parent its parent.
88
- * @param {TreeLinker|*} newNode The node (or data) which is being added to this list
89
- * @returns {TreeLinker}
78
+ * @param newNode The node (or data) which is being added to this list
90
79
  */
91
80
  private adopt;
92
81
  /**
93
82
  * Insert a new node (or data) after a node. The new node gets the parent of this list.
94
- * @param {TreeLinker|*} node The existing node as reference, or null to insert at the start of the list
95
- * @param {TreeLinker|*} newNode The new node to go after the existing node
96
- * @returns {LinkedTreeList}
83
+ * @param node The existing node as reference, or null to insert at the start of the list
84
+ * @param newNode The new node to go after the existing node
97
85
  */
98
86
  insertAfter(node: TreeLinker | null, newNode: TreeLinker | any): LinkedTreeList;
99
87
  /**
100
88
  * Insert a new node (or data) before a node. The new node gets the parent of this list.
101
- * @param {TreeLinker|*} node The existing node as reference, or null to insert at the end of the list
102
- * @param {TreeLinker|*} newNode The new node to go before the existing node
103
- * @returns {LinkedTreeList}
89
+ * @param node The existing node as reference, or null to insert at the end of the list
90
+ * @param newNode The new node to go before the existing node
104
91
  */
105
92
  insertBefore(node: TreeLinker | null, newNode: TreeLinker | any): LinkedTreeList;
106
93
  /**
107
94
  * Add a node (or data) after the given (or last) node in the list.
108
- * @param {TreeLinker|*} node The new node to add to the end of the list
109
- * @param {TreeLinker} after The existing last node
110
- * @returns {TreeLinker}
95
+ * @param node The new node to add to the end of the list
96
+ * @param after The existing last node
111
97
  */
112
98
  append(node: TreeLinker | any, after?: TreeLinker): LinkedTreeList;
113
99
  /**
114
100
  * Add a node (or data) before the given (or first) node in the list.
115
- * @param {TreeLinker|*} node The new node to add to the start of the list
116
- * @param {TreeLinker} before The existing first node
117
- * @returns {TreeLinker}
101
+ * @param node The new node to add to the start of the list
102
+ * @param before The existing first node
118
103
  */
119
104
  prepend(node: TreeLinker | any, before?: TreeLinker): LinkedTreeList;
120
105
  /**
121
106
  * Remove a linker from this linked list. The removed node no longer has a parent.
122
- * @param {TreeLinker} node The node we wish to remove (and it will be returned after removal)
123
- * @return {TreeLinker|null} The removed node, or null when there was nothing to remove
107
+ * @param node The node we wish to remove (and it will be returned after removal)
108
+ * @returns The removed node, or null when there was nothing to remove
124
109
  */
125
110
  remove(node: TreeLinker): TreeLinker | null;
126
111
  /**
127
112
  * Refresh all references (the head, the end and the length) by walking the list once, and return the head. The
128
113
  * list's own methods keep these up to date, so this is only needed after linkers were changed directly.
129
- * @return {TreeLinker}
130
114
  */
131
115
  reset(): TreeLinker;
132
116
  /**
133
117
  * Retrieve a TreeLinker item from this list by numeric index, otherwise return null.
134
- * @param {number} index The integer number for retrieving a node by position.
135
- * @returns {TreeLinker|null}
118
+ * @param index The integer number for retrieving a node by position.
136
119
  */
137
120
  item(index: number): TreeLinker;
138
121
  /**
139
122
  * Be able to run forEach on this LinkedTreeList to iterate over the TreeLinker Items.
140
- * @param {forEachCallback} callback The function to call for-each tree node
141
- * @param {LinkedTreeList} thisArg Optional, 'this' reference
142
- * @return {LinkedTreeList} The list which was iterated.
123
+ * @param callback The function to call for-each tree node
124
+ * @param thisArg Optional, 'this' reference
125
+ * @returns The list which was iterated.
143
126
  */
144
127
  forEach(callback: forEachCallback, thisArg?: LinkedTreeList): LinkedTreeList;
145
128
  /**
146
129
  * Be able to iterate over this class: the linkers of this list and everything below them (left-first). It stays within
147
130
  * this list (it does not start at, or climb up to, the parents), use the parseTree service to parse a whole tree.
148
- * @returns {Iterator}
149
131
  */
150
132
  [Symbol.iterator](): Iterator<TreeLinker>;
151
133
  /**
152
134
  * Convert an array into a LinkedTreeList instance, return the new instance.
153
- * @param {Array} [values=[]] An array of values which will be converted to nodes in this tree-list
154
- * @param {TreeLinker} [linkerClass=TreeLinker] The class to use for each node
155
- * @param {IsArrayable<TreeLinker>} [classType=LinkedTreeList] Provide the type of IsArrayable to use.
156
- * @returns {LinkedTreeList}
135
+ * @param values An array of values which will be converted to nodes in this tree-list
136
+ * @param linkerClass The class to use for each node
137
+ * @param classType Provide the type of IsArrayable to use.
157
138
  */
158
139
  static fromArray: (values?: Array<any>, linkerClass?: typeof TreeLinker, classType?: any) => IsTree | any;
159
140
  }