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,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 {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,8 +1,5 @@
1
1
  /**
2
- * @file doubly linked list.
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 {DoubleLinker} [linkerClass=DoubleLinker] The class used to wrap given data as linkers.
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 {DoubleLinker} initialList Give the list of double-linkers to start in this doubly linked-list.
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 {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}
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 {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}
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 {DoubleLinker|*} node The new node to add to the end of the list
76
- * @param {DoubleLinker} after The existing last node
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 {DoubleLinker|*} node The new node to add to the start of the list
83
- * @param {DoubleLinker} before The existing first node
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 {DoubleLinker} node The node we wish to remove (and it will be returned after removal)
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 {number} index The integer number for retrieving a node by position.
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 {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.
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 {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}
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
  }