collect-your-stuff 1.1.0 → 1.1.2

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 (67) hide show
  1. package/README.md +1492 -1488
  2. package/browser/collect-your-stuff.js +19292 -19268
  3. package/browser/collect-your-stuff.min.js +1 -1
  4. package/dist/collections/arrayable/ArrayElement.d.ts +37 -37
  5. package/dist/collections/arrayable/ArrayElement.js +71 -71
  6. package/dist/collections/arrayable/Arrayable.d.ts +109 -108
  7. package/dist/collections/arrayable/Arrayable.js +196 -195
  8. package/dist/collections/arrayable/Arrayable.min.js +1 -1
  9. package/dist/collections/doubly-linked-list/DoubleLinker.d.ts +47 -47
  10. package/dist/collections/doubly-linked-list/DoubleLinker.js +77 -77
  11. package/dist/collections/doubly-linked-list/DoublyLinkedList.d.ts +114 -113
  12. package/dist/collections/doubly-linked-list/DoublyLinkedList.js +275 -257
  13. package/dist/collections/doubly-linked-list/DoublyLinkedList.min.js +1 -1
  14. package/dist/collections/linked-list/LinkedList.d.ts +110 -109
  15. package/dist/collections/linked-list/LinkedList.js +241 -232
  16. package/dist/collections/linked-list/LinkedList.min.js +1 -1
  17. package/dist/collections/linked-list/Linker.d.ts +44 -44
  18. package/dist/collections/linked-list/Linker.js +87 -87
  19. package/dist/collections/linked-tree-list/LinkedTreeList.d.ts +136 -135
  20. package/dist/collections/linked-tree-list/LinkedTreeList.js +261 -256
  21. package/dist/collections/linked-tree-list/LinkedTreeList.min.js +1 -1
  22. package/dist/collections/linked-tree-list/TreeLinker.d.ts +62 -62
  23. package/dist/collections/linked-tree-list/TreeLinker.js +85 -85
  24. package/dist/collections/queue/Queue.d.ts +64 -60
  25. package/dist/collections/queue/Queue.js +137 -125
  26. package/dist/collections/queue/Queue.min.js +1 -1
  27. package/dist/collections/queue/Queueable.d.ts +78 -78
  28. package/dist/collections/queue/Queueable.js +148 -146
  29. package/dist/collections/queue/Queueable.min.js +1 -1
  30. package/dist/collections/stack/Stack.d.ts +64 -60
  31. package/dist/collections/stack/Stack.js +113 -103
  32. package/dist/collections/stack/Stack.min.js +1 -1
  33. package/dist/collections/stack/Stackable.d.ts +57 -57
  34. package/dist/collections/stack/Stackable.js +90 -90
  35. package/dist/main.d.ts +40 -40
  36. package/dist/main.js +51 -51
  37. package/dist/recipes/ArrayIterator.d.ts +11 -11
  38. package/dist/recipes/ArrayIterator.js +30 -30
  39. package/dist/recipes/DoubleLinkerIterator.d.ts +10 -10
  40. package/dist/recipes/DoubleLinkerIterator.js +24 -24
  41. package/dist/recipes/IsArrayable.d.ts +105 -105
  42. package/dist/recipes/IsArrayable.js +5 -5
  43. package/dist/recipes/IsDoubleLinker.d.ts +14 -14
  44. package/dist/recipes/IsDoubleLinker.js +5 -5
  45. package/dist/recipes/IsElement.d.ts +14 -14
  46. package/dist/recipes/IsElement.js +5 -5
  47. package/dist/recipes/IsLinker.d.ts +10 -10
  48. package/dist/recipes/IsLinker.js +5 -5
  49. package/dist/recipes/IsTree.d.ts +11 -11
  50. package/dist/recipes/IsTree.js +5 -5
  51. package/dist/recipes/IsTreeNode.d.ts +29 -29
  52. package/dist/recipes/IsTreeNode.js +5 -5
  53. package/dist/recipes/LinkerIterator.d.ts +10 -10
  54. package/dist/recipes/LinkerIterator.js +24 -24
  55. package/dist/recipes/Runnable.d.ts +54 -54
  56. package/dist/recipes/Runnable.js +69 -69
  57. package/dist/recipes/TreeLinkerIterator.d.ts +10 -10
  58. package/dist/recipes/TreeLinkerIterator.js +26 -26
  59. package/dist/recipes/recipes.d.ts +16 -16
  60. package/dist/recipes/recipes.js +24 -24
  61. package/dist/services/parseTree.d.ts +10 -10
  62. package/dist/services/parseTree.js +25 -25
  63. package/dist/services/parseTreeNext.d.ts +15 -15
  64. package/dist/services/parseTreeNext.js +47 -47
  65. package/dist/services/services.d.ts +14 -14
  66. package/dist/services/services.js +24 -24
  67. package/package.json +3 -2
@@ -1,37 +1,37 @@
1
- /**
2
- * @file linked list item.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.1.0
5
- * @memberOf module:collect-your-stuff
6
- */
7
- import IsElement from '../../recipes/IsElement';
8
- /**
9
- * Element represents a node in an Arrayable.
10
- */
11
- declare class ArrayElement implements IsElement {
12
- readonly classType: typeof ArrayElement;
13
- data: any;
14
- /**
15
- * Create the new Element instance, provide the data and optionally configure the type of Element.
16
- * @param {*} [data=null] The data to be stored in this element.
17
- */
18
- constructor(data?: any);
19
- /**
20
- * Make a new Element from the data given if it is not already a valid Element.
21
- * @param {ArrayElement|*} element Return a valid ArrayElement instance from given data, or even an already valid one.
22
- * @param {IsElement} [classType=ArrayElement] Provide the type of IsElement to use.
23
- * @return {ArrayElement}
24
- */
25
- static make: (element: ArrayElement | any, classType?: any) => IsElement | any;
26
- /**
27
- * Convert an array into Element instances, return the head and tail Elements.
28
- * @param {Array<IsElement>} [values=[]] Provide an array of data that will be converted to array of elements.
29
- * @param {IsElement} [classType=ArrayElement] Provide the type of IsElement to use.
30
- * @returns {{head: ArrayElement[], tail: ArrayElement}}
31
- */
32
- static fromArray: (values?: Array<IsElement>, classType?: any) => {
33
- head: Array<ArrayElement>;
34
- tail: ArrayElement;
35
- };
36
- }
37
- export default ArrayElement;
1
+ /**
2
+ * @file linked list item.
3
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
4
+ * @version 1.1.0
5
+ * @memberOf module:collect-your-stuff
6
+ */
7
+ import IsElement from '../../recipes/IsElement';
8
+ /**
9
+ * Element represents a node in an Arrayable.
10
+ */
11
+ declare class ArrayElement implements IsElement {
12
+ readonly classType: typeof ArrayElement;
13
+ data: any;
14
+ /**
15
+ * Create the new Element instance, provide the data and optionally configure the type of Element.
16
+ * @param {*} [data=null] The data to be stored in this element.
17
+ */
18
+ constructor(data?: any);
19
+ /**
20
+ * Make a new Element from the data given if it is not already a valid Element.
21
+ * @param {ArrayElement|*} element Return a valid ArrayElement instance from given data, or even an already valid one.
22
+ * @param {IsElement} [classType=ArrayElement] Provide the type of IsElement to use.
23
+ * @return {ArrayElement}
24
+ */
25
+ static make: (element: ArrayElement | any, classType?: any) => IsElement | any;
26
+ /**
27
+ * Convert an array into Element instances, return the head and tail Elements.
28
+ * @param {Array<IsElement>} [values=[]] Provide an array of data that will be converted to array of elements.
29
+ * @param {IsElement} [classType=ArrayElement] Provide the type of IsElement to use.
30
+ * @returns {{head: ArrayElement[], tail: ArrayElement}}
31
+ */
32
+ static fromArray: (values?: Array<IsElement>, classType?: any) => {
33
+ head: Array<ArrayElement>;
34
+ tail: ArrayElement;
35
+ };
36
+ }
37
+ export default ArrayElement;
@@ -1,71 +1,71 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.default = void 0
7
- require('core-js/modules/esnext.async-iterator.reduce.js')
8
- require('core-js/modules/esnext.iterator.constructor.js')
9
- require('core-js/modules/esnext.iterator.reduce.js')
10
- /**
11
- * Element represents a node in an Arrayable.
12
- */
13
- class ArrayElement {
14
- /**
15
- * Create the new Element instance, provide the data and optionally configure the type of Element.
16
- * @param {*} [data=null] The data to be stored in this element.
17
- */
18
- constructor () {
19
- const data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null
20
- this.classType = ArrayElement
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
- ArrayElement.make = function (element) {
32
- const classType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ArrayElement
33
- if (typeof element !== 'object') {
34
- // It is not an object, 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 = function () {
51
- const values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []
52
- const classType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ArrayElement
53
- return values.reduce((references, element) => {
54
- const newElement = classType.make(element, classType)
55
- if (!references.head.length) {
56
- // Initialize the head and tail with the new node
57
- return {
58
- head: [newElement],
59
- tail: newElement
60
- }
61
- }
62
- // Only update the tail once head has been set, tail is always the most recent node
63
- references.head.push(newElement)
64
- references.tail = newElement
65
- return references
66
- }, {
67
- head: [],
68
- tail: null
69
- })
70
- }
71
- var _default = exports.default = ArrayElement
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.default = void 0
7
+ require('core-js/modules/esnext.async-iterator.reduce.js')
8
+ require('core-js/modules/esnext.iterator.constructor.js')
9
+ require('core-js/modules/esnext.iterator.reduce.js')
10
+ /**
11
+ * Element represents a node in an Arrayable.
12
+ */
13
+ class ArrayElement {
14
+ /**
15
+ * Create the new Element instance, provide the data and optionally configure the type of Element.
16
+ * @param {*} [data=null] The data to be stored in this element.
17
+ */
18
+ constructor () {
19
+ const data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null
20
+ this.classType = ArrayElement
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
+ ArrayElement.make = function (element) {
32
+ const classType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ArrayElement
33
+ if (typeof element !== 'object') {
34
+ // It is not an object, 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 = function () {
51
+ const values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []
52
+ const classType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ArrayElement
53
+ return values.reduce((references, element) => {
54
+ const newElement = classType.make(element, classType)
55
+ if (!references.head.length) {
56
+ // Initialize the head and tail with the new node
57
+ return {
58
+ head: [newElement],
59
+ tail: newElement
60
+ }
61
+ }
62
+ // Only update the tail once head has been set, tail is always the most recent node
63
+ references.head.push(newElement)
64
+ references.tail = newElement
65
+ return references
66
+ }, {
67
+ head: [],
68
+ tail: null
69
+ })
70
+ }
71
+ var _default = exports.default = ArrayElement
@@ -1,108 +1,109 @@
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 IsArrayable, { forEachCallback } from '../../recipes/IsArrayable';
9
- import IsElement from '../../recipes/IsElement';
10
- /**
11
- * Arrayable represents a collection stored as an array.
12
- */
13
- declare class Arrayable implements IsArrayable<ArrayElement>, Iterable<ArrayElement> {
14
- readonly classType: typeof Arrayable;
15
- innerList: Array<ArrayElement>;
16
- initialized: boolean;
17
- /**
18
- * Create the new Arrayable instance, configure the Arrayable class.
19
- */
20
- constructor();
21
- /**
22
- * Initialize the inner list, should only run once.
23
- * @param {Array<ArrayElement>} initialList Give the array of elements to start in this Arrayable.
24
- * @return {Arrayable}
25
- */
26
- initialize(initialList: Array<ArrayElement>): Arrayable;
27
- /**
28
- * Retrieve a copy of the innerList used.
29
- * @returns {Array<ArrayElement>}
30
- */
31
- get list(): Array<ArrayElement>;
32
- /**
33
- * Retrieve the first Element from the Arrayable
34
- * @returns {ArrayElement}
35
- */
36
- get first(): ArrayElement;
37
- /**
38
- * Retrieve the last Element from the Arrayable
39
- * @returns {ArrayElement}
40
- */
41
- get last(): ArrayElement;
42
- /**
43
- * Return the length of the list.
44
- * @returns {number}
45
- */
46
- get length(): number;
47
- /**
48
- * Insert a new node (or data) after a node.
49
- * @param {ArrayElement|*} node The existing node as reference
50
- * @param {ArrayElement|*} newNode The new node to go after the existing node
51
- * @returns {Arrayable}
52
- */
53
- insertAfter(node: ArrayElement, newNode: ArrayElement | any): Arrayable;
54
- /**
55
- * Insert a new node (or data) before a node.
56
- * @param {ArrayElement|*} node The existing node as reference
57
- * @param {ArrayElement|*} newNode The new node to go before the existing node
58
- * @returns {Arrayable}
59
- */
60
- insertBefore(node: ArrayElement, newNode: ArrayElement | any): Arrayable;
61
- /**
62
- * Add a node (or data) after the given (or last) node in the list.
63
- * @param {ArrayElement|*} node The new node to add to the end of the list
64
- * @param {ArrayElement} after The existing last node
65
- * @returns {Arrayable}
66
- */
67
- append(node: ArrayElement | any, after?: ArrayElement): Arrayable;
68
- /**
69
- * Add a node (or data) before the given (or first) node in the list.
70
- * @param {ArrayElement|*} node The new node to add to the start of the list
71
- * @param {ArrayElement} before The existing first node
72
- * @returns {Arrayable}
73
- */
74
- prepend(node: ArrayElement | any, before?: ArrayElement): Arrayable;
75
- /**
76
- * Remove an element from this arrayable.
77
- * @param {ArrayElement} node The node we wish to remove (and it will be returned after removal)
78
- * @return {ArrayElement}
79
- */
80
- remove(node: ArrayElement): ArrayElement;
81
- /**
82
- * Retrieve an ArrayElement item from this list by numeric index, otherwise return null.
83
- * @param {number} index The integer number for retrieving a node by position.
84
- * @return {ArrayElement|null}
85
- */
86
- item(index: number): ArrayElement | null;
87
- /**
88
- * Be able to run forEach on this Arrayable to iterate over the elements.
89
- * @param {forEachCallback} callback The function to call for-each element
90
- * @param {Arrayable} thisArg Optional, 'this' reference
91
- * @returns {Arrayable}
92
- */
93
- forEach(callback: forEachCallback, thisArg?: Arrayable): Arrayable;
94
- /**
95
- * Be able to iterate over this class.
96
- * @returns {Iterator}
97
- */
98
- [Symbol.iterator](): Iterator<ArrayElement>;
99
- /**
100
- * Convert an array to an Arrayable.
101
- * @param {Array} values An array of values which will be converted to elements in this arrayable
102
- * @param {IsElement} [elementClass=ArrayElement] The class to use for each element
103
- * @param {IsArrayable<ArrayElement>} [classType=Arrayable] Provide the type of IsArrayable to use.
104
- * @returns {Arrayable}
105
- */
106
- static fromArray: (values?: Array<any>, elementClass?: typeof ArrayElement, classType?: any) => IsArrayable<IsElement>;
107
- }
108
- export default Arrayable;
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 IsArrayable, { forEachCallback } from '../../recipes/IsArrayable';
9
+ import IsElement from '../../recipes/IsElement';
10
+ /**
11
+ * Arrayable represents a collection stored as an array.
12
+ */
13
+ declare class Arrayable implements IsArrayable<ArrayElement>, Iterable<ArrayElement> {
14
+ readonly classType: typeof Arrayable;
15
+ innerList: Array<ArrayElement>;
16
+ initialized: boolean;
17
+ elementClass: typeof ArrayElement;
18
+ /**
19
+ * Create the new Arrayable instance, configure the Arrayable class.
20
+ */
21
+ constructor(elementClass?: typeof ArrayElement);
22
+ /**
23
+ * Initialize the inner list, should only run once.
24
+ * @param {Array<ArrayElement>} initialList Give the array of elements to start in this Arrayable.
25
+ * @return {Arrayable}
26
+ */
27
+ initialize(initialList: Array<ArrayElement>): Arrayable;
28
+ /**
29
+ * Retrieve a copy of the innerList used.
30
+ * @returns {Array<ArrayElement>}
31
+ */
32
+ get list(): Array<ArrayElement>;
33
+ /**
34
+ * Retrieve the first Element from the Arrayable
35
+ * @returns {ArrayElement}
36
+ */
37
+ get first(): ArrayElement;
38
+ /**
39
+ * Retrieve the last Element from the Arrayable
40
+ * @returns {ArrayElement}
41
+ */
42
+ get last(): ArrayElement;
43
+ /**
44
+ * Return the length of the list.
45
+ * @returns {number}
46
+ */
47
+ get length(): number;
48
+ /**
49
+ * Insert a new node (or data) after a node.
50
+ * @param {ArrayElement|*} node The existing node as reference
51
+ * @param {ArrayElement|*} newNode The new node to go after the existing node
52
+ * @returns {Arrayable}
53
+ */
54
+ insertAfter(node: ArrayElement, newNode: ArrayElement | any): Arrayable;
55
+ /**
56
+ * Insert a new node (or data) before a node.
57
+ * @param {ArrayElement|*} node The existing node as reference
58
+ * @param {ArrayElement|*} newNode The new node to go before the existing node
59
+ * @returns {Arrayable}
60
+ */
61
+ insertBefore(node: ArrayElement, newNode: ArrayElement | any): Arrayable;
62
+ /**
63
+ * Add a node (or data) after the given (or last) node in the list.
64
+ * @param {ArrayElement|*} node The new node to add to the end of the list
65
+ * @param {ArrayElement} after The existing last node
66
+ * @returns {Arrayable}
67
+ */
68
+ append(node: ArrayElement | any, after?: ArrayElement): Arrayable;
69
+ /**
70
+ * Add a node (or data) before the given (or first) node in the list.
71
+ * @param {ArrayElement|*} node The new node to add to the start of the list
72
+ * @param {ArrayElement} before The existing first node
73
+ * @returns {Arrayable}
74
+ */
75
+ prepend(node: ArrayElement | any, before?: ArrayElement): Arrayable;
76
+ /**
77
+ * Remove an element from this arrayable.
78
+ * @param {ArrayElement} node The node we wish to remove (and it will be returned after removal)
79
+ * @return {ArrayElement}
80
+ */
81
+ remove(node: ArrayElement): ArrayElement;
82
+ /**
83
+ * Retrieve an ArrayElement item from this list by numeric index, otherwise return null.
84
+ * @param {number} index The integer number for retrieving a node by position.
85
+ * @return {ArrayElement|null}
86
+ */
87
+ item(index: number): ArrayElement | null;
88
+ /**
89
+ * Be able to run forEach on this Arrayable to iterate over the elements.
90
+ * @param {forEachCallback} callback The function to call for-each element
91
+ * @param {Arrayable} thisArg Optional, 'this' reference
92
+ * @returns {Arrayable}
93
+ */
94
+ forEach(callback: forEachCallback, thisArg?: Arrayable): Arrayable;
95
+ /**
96
+ * Be able to iterate over this class.
97
+ * @returns {Iterator}
98
+ */
99
+ [Symbol.iterator](): Iterator<ArrayElement>;
100
+ /**
101
+ * Convert an array to an Arrayable.
102
+ * @param {Array} values An array of values which will be converted to elements in this arrayable
103
+ * @param {IsElement} [elementClass=ArrayElement] The class to use for each element
104
+ * @param {IsArrayable<ArrayElement>} [classType=Arrayable] Provide the type of IsArrayable to use.
105
+ * @returns {Arrayable}
106
+ */
107
+ static fromArray: (values?: Array<any>, elementClass?: typeof ArrayElement, classType?: any) => IsArrayable<IsElement>;
108
+ }
109
+ export default Arrayable;