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,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 {*} [data=null] 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 {ArrayElement|*} element Return a valid ArrayElement instance from given data, or even an already valid one.
28
- * @param {IsElement} [classType=ArrayElement] Provide the type of IsElement to use.
29
- * @return {ArrayElement}
30
- */
31
- exports.ArrayElement = ArrayElement
32
- ArrayElement.make = (element, classType = ArrayElement) => {
33
- if (element === null || typeof element !== 'object') {
34
- // It is not an object (or it is null), so instantiate the Element with element as the data
35
- return new classType(element)
36
- }
37
- if (element.classType) {
38
- // Already valid Element, return as-is
39
- return element
40
- }
41
- // Create the new node as the configured #classType
42
- return new classType(element)
43
- }
44
- /**
45
- * Convert an array into Element instances, return the head and tail Elements.
46
- * @param {Array<IsElement>} [values=[]] Provide an array of data that will be converted to array of elements.
47
- * @param {IsElement} [classType=ArrayElement] Provide the type of IsElement to use.
48
- * @returns {{head: ArrayElement[], tail: ArrayElement}}
49
- */
50
- ArrayElement.fromArray = (values = [], classType = ArrayElement) => values.reduce((references, element) => {
51
- const newElement = classType.make(element, classType)
52
- if (!references.head.length) {
53
- // Initialize the head and tail with the new node
54
- return {
55
- head: [newElement],
56
- tail: newElement
57
- }
58
- }
59
- // Only update the tail once head has been set, tail is always the most recent node
60
- references.head.push(newElement)
61
- references.tail = newElement
62
- return references
63
- }, {
64
- head: [],
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
- * @file arrayable list.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.1.0
5
- * @memberOf module:collect-your-stuff
6
- */
7
- import { ArrayElement } from './ArrayElement';
8
- import { forEachCallback, IsArrayable } from '../../recipes/IsArrayable';
9
- import { IsElement } from '../../recipes/IsElement';
10
- /**
11
- * Arrayable represents a collection stored as an array.
12
- */
13
- export declare class Arrayable implements IsArrayable<ArrayElement>, Iterable<ArrayElement> {
14
- /** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
15
- readonly classType: typeof Arrayable;
16
- /** The array which stores the elements of this Arrayable. */
17
- innerList: Array<ArrayElement>;
18
- /** Whether the inner list has been initialized (it can only be initialized once). */
19
- initialized: boolean;
20
- /** The class used to wrap the data given to this Arrayable as elements. */
21
- elementClass: typeof ArrayElement;
22
- /**
23
- * Create the new Arrayable instance, configure the Arrayable class.
24
- * @param {ArrayElement} [elementClass=ArrayElement] The class used to wrap given data as elements.
25
- */
26
- constructor(elementClass?: typeof ArrayElement);
27
- /**
28
- * Find the position of an element which must be in this list.
29
- * @param {ArrayElement} node The element to find
30
- * @returns {number}
31
- * @throws {Error} When the element is not in this list
32
- */
33
- private indexOfElement;
34
- /**
35
- * Initialize the inner list, should only run once.
36
- * @param {Array<ArrayElement>} initialList Give the array of elements to start in this Arrayable.
37
- * @return {Arrayable}
38
- */
39
- initialize(initialList: Array<ArrayElement>): Arrayable;
40
- /**
41
- * Retrieve the innerList used (the list itself, not a copy).
42
- * @returns {Array<ArrayElement>}
43
- */
44
- get list(): Array<ArrayElement>;
45
- /**
46
- * Retrieve the first Element from the Arrayable
47
- * @returns {ArrayElement|null} The first element, or null when the Arrayable is empty
48
- */
49
- get first(): ArrayElement | null;
50
- /**
51
- * Retrieve the last Element from the Arrayable
52
- * @returns {ArrayElement|null} The last element, or null when the Arrayable is empty
53
- */
54
- get last(): ArrayElement | null;
55
- /**
56
- * Return the length of the list.
57
- * @returns {number}
58
- */
59
- get length(): number;
60
- /**
61
- * Insert a new node (or data) after a node.
62
- * @param {ArrayElement|null} node The existing node as reference, or null to insert at the start of the list
63
- * @param {ArrayElement|*} newNode The new node to go after the existing node
64
- * @returns {Arrayable}
65
- * @throws {Error} When the reference node is not in this list
66
- */
67
- insertAfter(node: ArrayElement | null, newNode: ArrayElement | any): Arrayable;
68
- /**
69
- * Insert a new node (or data) before a node.
70
- * @param {ArrayElement|null} node The existing node as reference, or null to insert at the end of the list
71
- * @param {ArrayElement|*} newNode The new node to go before the existing node
72
- * @returns {Arrayable}
73
- * @throws {Error} When the reference node is not in this list
74
- */
75
- insertBefore(node: ArrayElement | null, newNode: ArrayElement | any): Arrayable;
76
- /**
77
- * Add a node (or data) after the given (or last) node in the list.
78
- * @param {ArrayElement|*} node The new node to add to the end of the list
79
- * @param {ArrayElement} after The existing last node
80
- * @returns {Arrayable}
81
- */
82
- append(node: ArrayElement | any, after?: ArrayElement | null): Arrayable;
83
- /**
84
- * Add a node (or data) before the given (or first) node in the list.
85
- * @param {ArrayElement|*} node The new node to add to the start of the list
86
- * @param {ArrayElement} before The existing first node
87
- * @returns {Arrayable}
88
- */
89
- prepend(node: ArrayElement | any, before?: ArrayElement | null): Arrayable;
90
- /**
91
- * Remove an element from this arrayable.
92
- * @param {ArrayElement} node The node we wish to remove (and it will be returned after removal)
93
- * @return {ArrayElement|null} The removed node, or null when it was not in this list (nothing is removed)
94
- */
95
- remove(node: ArrayElement): ArrayElement | null;
96
- /**
97
- * Retrieve an ArrayElement item from this list by numeric index, otherwise return null.
98
- * @param {number} index The integer number for retrieving a node by position.
99
- * @return {ArrayElement|null}
100
- */
101
- item(index: number): ArrayElement | null;
102
- /**
103
- * Be able to run forEach on this Arrayable to iterate over the elements.
104
- * @param {forEachCallback} callback The function to call for-each element
105
- * @param {Arrayable} thisArg Optional, 'this' reference
106
- * @returns {Arrayable}
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
+ }