collect-your-stuff 1.2.7 → 1.2.8

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 (61) hide show
  1. package/README.md +2525 -2525
  2. package/browser/collect-your-stuff.js +22766 -22761
  3. package/browser/collect-your-stuff.min.js +1 -1
  4. package/dist/collections/arrayable/ArrayElement.d.ts +36 -36
  5. package/dist/collections/arrayable/ArrayElement.js +64 -64
  6. package/dist/collections/arrayable/Arrayable.d.ts +108 -108
  7. package/dist/collections/arrayable/Arrayable.js +188 -188
  8. package/dist/collections/doubly-linked-list/DoubleLinker.d.ts +46 -46
  9. package/dist/collections/doubly-linked-list/DoubleLinker.js +69 -69
  10. package/dist/collections/doubly-linked-list/DoublyLinkedList.d.ts +113 -113
  11. package/dist/collections/doubly-linked-list/DoublyLinkedList.js +274 -269
  12. package/dist/collections/doubly-linked-list/DoublyLinkedList.min.js +1 -1
  13. package/dist/collections/linked-list/LinkedList.d.ts +109 -109
  14. package/dist/collections/linked-list/LinkedList.js +233 -233
  15. package/dist/collections/linked-list/Linker.d.ts +43 -43
  16. package/dist/collections/linked-list/Linker.js +80 -80
  17. package/dist/collections/linked-tree-list/LinkedTreeList.d.ts +135 -135
  18. package/dist/collections/linked-tree-list/LinkedTreeList.js +252 -252
  19. package/dist/collections/linked-tree-list/TreeLinker.d.ts +63 -63
  20. package/dist/collections/linked-tree-list/TreeLinker.js +79 -79
  21. package/dist/collections/queue/Queue.d.ts +63 -63
  22. package/dist/collections/queue/Queue.js +130 -130
  23. package/dist/collections/queue/Queueable.d.ts +77 -77
  24. package/dist/collections/queue/Queueable.js +141 -141
  25. package/dist/collections/stack/Stack.d.ts +63 -63
  26. package/dist/collections/stack/Stack.js +106 -106
  27. package/dist/collections/stack/Stackable.d.ts +56 -56
  28. package/dist/collections/stack/Stackable.js +83 -83
  29. package/dist/main.d.ts +40 -40
  30. package/dist/main.js +50 -50
  31. package/dist/recipes/ArrayIterator.d.ts +10 -10
  32. package/dist/recipes/ArrayIterator.js +29 -29
  33. package/dist/recipes/DoubleLinkerIterator.d.ts +9 -9
  34. package/dist/recipes/DoubleLinkerIterator.js +24 -24
  35. package/dist/recipes/IsArrayable.d.ts +105 -105
  36. package/dist/recipes/IsArrayable.js +5 -5
  37. package/dist/recipes/IsDoubleLinker.d.ts +14 -14
  38. package/dist/recipes/IsDoubleLinker.js +5 -5
  39. package/dist/recipes/IsElement.d.ts +14 -14
  40. package/dist/recipes/IsElement.js +5 -5
  41. package/dist/recipes/IsLinker.d.ts +10 -10
  42. package/dist/recipes/IsLinker.js +5 -5
  43. package/dist/recipes/IsTree.d.ts +11 -11
  44. package/dist/recipes/IsTree.js +5 -5
  45. package/dist/recipes/IsTreeNode.d.ts +29 -29
  46. package/dist/recipes/IsTreeNode.js +5 -5
  47. package/dist/recipes/LinkerIterator.d.ts +9 -9
  48. package/dist/recipes/LinkerIterator.js +24 -24
  49. package/dist/recipes/Runnable.d.ts +54 -54
  50. package/dist/recipes/Runnable.js +68 -68
  51. package/dist/recipes/TreeLinkerIterator.d.ts +9 -9
  52. package/dist/recipes/TreeLinkerIterator.js +25 -25
  53. package/dist/recipes/recipes.d.ts +15 -15
  54. package/dist/recipes/recipes.js +22 -22
  55. package/dist/services/parseTree.d.ts +9 -9
  56. package/dist/services/parseTree.js +24 -24
  57. package/dist/services/parseTreeNext.d.ts +14 -14
  58. package/dist/services/parseTreeNext.js +47 -47
  59. package/dist/services/services.d.ts +13 -13
  60. package/dist/services/services.js +22 -22
  61. package/package.json +1 -1
@@ -1,79 +1,79 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.TreeLinker = void 0
7
- require('core-js/modules/esnext.iterator.constructor.js')
8
- require('core-js/modules/esnext.iterator.map.js')
9
- var _DoubleLinker = require('../doubly-linked-list/DoubleLinker')
10
- var _LinkedTreeList = require('./LinkedTreeList')
11
- /**
12
- * TreeLinker represents a node in a LinkedTreeList having a parent (or root) and child nodes.
13
- * @extends DoubleLinker
14
- */
15
- class TreeLinker {
16
- /**
17
- * Create the new TreeLinker instance, provide the data and optionally set references for next, prev, parent, or children.
18
- * @param {Object} [settings={}]
19
- * @param {*} [settings.data=null] The data to be stored in this tree node
20
- * @param {TreeLinker} [settings.next=null] The reference to the next linker if any
21
- * @param {TreeLinker} [settings.prev=null] The reference to the previous linker if any
22
- * @param {LinkedTreeList} [settings.children=null] The references to child linkers if any
23
- * @param {TreeLinker} [settings.parent=null] The reference to a parent linker if any
24
- * @param {IsArrayable<IsTreeNode>} listClass Give the type of list to use for storing the children
25
- */
26
- constructor ({
27
- data = null,
28
- next = null,
29
- prev = null,
30
- children = null,
31
- parent = null,
32
- listClass = _LinkedTreeList.LinkedTreeList
33
- } = {}) {
34
- this.classType = TreeLinker
35
- this.data = null
36
- this.next = null
37
- this.prev = null
38
- this.parent = null
39
- this.children = null
40
- this.data = data
41
- this.next = next
42
- this.prev = prev
43
- this.parent = parent
44
- this.children = this.childrenFromArray(children, listClass)
45
- }
46
-
47
- /**
48
- * Create the children for this tree from an array.
49
- * @param {Array|null} children Provide an array of data / linker references to be children of this tree node.
50
- * @param {IsArrayable<IsTreeNode>} listClass Give the type of list to use for storing the children
51
- * @return {LinkedTreeList|null}
52
- */
53
- childrenFromArray (children = null, listClass = _LinkedTreeList.LinkedTreeList) {
54
- if (children === null) {
55
- return null
56
- }
57
- // Creates a linked-tree-list to store the children.
58
- return listClass.fromArray(children.map(child => Object.assign({}, child, {
59
- parent: this
60
- })), this.classType)
61
- }
62
- }
63
- /**
64
- * Make a new DoubleLinker from the data given if it is not already a valid Linker.
65
- * @param {TreeLinker|*} linker Return a valid TreeLinker instance from given data, or even an already valid one.
66
- * @param {IsTreeNode} [classType=TreeLinker] Provide the type of IsTreeNode to use.
67
- * @return {TreeLinker}
68
- */
69
- exports.TreeLinker = TreeLinker
70
- TreeLinker.make = (linker, classType = TreeLinker) => {
71
- return _DoubleLinker.DoubleLinker.make(linker, classType)
72
- }
73
- /**
74
- * Convert an array into DoubleLinker instances, return the head and tail DoubleLinkers.
75
- * @param {Array} [values=[]] Provide an array of data that will be converted to a chain of tree-linkers.
76
- * @param {IsTreeNode} [classType=TreeLinker] Provide the type of IsTreeNode to use.
77
- * @returns {{head: TreeLinker, tail: TreeLinker}}
78
- */
79
- TreeLinker.fromArray = (values = [], classType = TreeLinker) => _DoubleLinker.DoubleLinker.fromArray(values, classType)
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.TreeLinker = void 0
7
+ require('core-js/modules/esnext.iterator.constructor.js')
8
+ require('core-js/modules/esnext.iterator.map.js')
9
+ var _DoubleLinker = require('../doubly-linked-list/DoubleLinker')
10
+ var _LinkedTreeList = require('./LinkedTreeList')
11
+ /**
12
+ * TreeLinker represents a node in a LinkedTreeList having a parent (or root) and child nodes.
13
+ * @extends DoubleLinker
14
+ */
15
+ class TreeLinker {
16
+ /**
17
+ * Create the new TreeLinker instance, provide the data and optionally set references for next, prev, parent, or children.
18
+ * @param {Object} [settings={}]
19
+ * @param {*} [settings.data=null] The data to be stored in this tree node
20
+ * @param {TreeLinker} [settings.next=null] The reference to the next linker if any
21
+ * @param {TreeLinker} [settings.prev=null] The reference to the previous linker if any
22
+ * @param {LinkedTreeList} [settings.children=null] The references to child linkers if any
23
+ * @param {TreeLinker} [settings.parent=null] The reference to a parent linker if any
24
+ * @param {IsArrayable<IsTreeNode>} listClass Give the type of list to use for storing the children
25
+ */
26
+ constructor ({
27
+ data = null,
28
+ next = null,
29
+ prev = null,
30
+ children = null,
31
+ parent = null,
32
+ listClass = _LinkedTreeList.LinkedTreeList
33
+ } = {}) {
34
+ this.classType = TreeLinker
35
+ this.data = null
36
+ this.next = null
37
+ this.prev = null
38
+ this.parent = null
39
+ this.children = null
40
+ this.data = data
41
+ this.next = next
42
+ this.prev = prev
43
+ this.parent = parent
44
+ this.children = this.childrenFromArray(children, listClass)
45
+ }
46
+
47
+ /**
48
+ * Create the children for this tree from an array.
49
+ * @param {Array|null} children Provide an array of data / linker references to be children of this tree node.
50
+ * @param {IsArrayable<IsTreeNode>} listClass Give the type of list to use for storing the children
51
+ * @return {LinkedTreeList|null}
52
+ */
53
+ childrenFromArray (children = null, listClass = _LinkedTreeList.LinkedTreeList) {
54
+ if (children === null) {
55
+ return null
56
+ }
57
+ // Creates a linked-tree-list to store the children.
58
+ return listClass.fromArray(children.map(child => Object.assign({}, child, {
59
+ parent: this
60
+ })), this.classType)
61
+ }
62
+ }
63
+ /**
64
+ * Make a new DoubleLinker from the data given if it is not already a valid Linker.
65
+ * @param {TreeLinker|*} linker Return a valid TreeLinker instance from given data, or even an already valid one.
66
+ * @param {IsTreeNode} [classType=TreeLinker] Provide the type of IsTreeNode to use.
67
+ * @return {TreeLinker}
68
+ */
69
+ exports.TreeLinker = TreeLinker
70
+ TreeLinker.make = (linker, classType = TreeLinker) => {
71
+ return _DoubleLinker.DoubleLinker.make(linker, classType)
72
+ }
73
+ /**
74
+ * Convert an array into DoubleLinker instances, return the head and tail DoubleLinkers.
75
+ * @param {Array} [values=[]] Provide an array of data that will be converted to a chain of tree-linkers.
76
+ * @param {IsTreeNode} [classType=TreeLinker] Provide the type of IsTreeNode to use.
77
+ * @returns {{head: TreeLinker, tail: TreeLinker}}
78
+ */
79
+ TreeLinker.fromArray = (values = [], classType = TreeLinker) => _DoubleLinker.DoubleLinker.fromArray(values, classType)
@@ -1,63 +1,63 @@
1
- /**
2
- * @file queue
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.1.0
5
- * @memberOf module:collect-your-stuff
6
- */
7
- import { Queueable } from './Queueable';
8
- import { IsArrayable } from '../../recipes/IsArrayable';
9
- import { IsLinker } from '../../recipes/IsLinker';
10
- import { completeResponse } from '../../recipes/Runnable';
11
- /**
12
- * Maintain a series of queued items.
13
- */
14
- export declare class Queue {
15
- queuedList: IsArrayable<any>;
16
- private listClass;
17
- private queueableClass;
18
- /**
19
- * Instantiate the queue with the given queue list.
20
- * @param {Iterable|LinkedList} queuedList Give the list of queueables to start in this queue.
21
- * @param {IsArrayable} listClass
22
- * @param {Queueable} queueableClass
23
- */
24
- constructor(queuedList?: IsArrayable<any>, listClass?: any, queueableClass?: typeof Queueable);
25
- /**
26
- * Take a queued task from the front of the queue and run it if ready.
27
- * @return {completeResponse|*}
28
- */
29
- dequeue(): completeResponse | any;
30
- /**
31
- * Return true if the queue is empty (there are no tasks in the queue list)
32
- * @return {boolean}
33
- */
34
- empty(): boolean;
35
- /**
36
- * Add a queued task to the end of the queue
37
- * @param {Queueable} queueable Add a new queueable to the end of the queue
38
- */
39
- enqueue(queueable: Queueable): void;
40
- /**
41
- * Take a look at the next queued task
42
- * @return {Queueable}
43
- */
44
- peek(): IsLinker;
45
- /**
46
- * Remove the next queued item and return it.
47
- * @return {Queueable|null}
48
- */
49
- remove(): Queueable | null;
50
- /**
51
- * Get the length of the current queue.
52
- * @return {number}
53
- */
54
- size(): number;
55
- /**
56
- * Convert an array to a Queue.
57
- * @param {Array} values An array of values which will be converted to queueables in this queue
58
- * @param {Queueable} queueableClass The class to use for each queueable
59
- * @param {Queue|Iterable} listClass The class to use to manage the queueables
60
- * @returns {Queue}
61
- */
62
- static fromArray: (values?: Array<any>, queueableClass?: typeof Queueable, listClass?: any) => Queue;
63
- }
1
+ /**
2
+ * @file queue
3
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
4
+ * @version 1.1.0
5
+ * @memberOf module:collect-your-stuff
6
+ */
7
+ import { Queueable } from './Queueable';
8
+ import { IsArrayable } from '../../recipes/IsArrayable';
9
+ import { IsLinker } from '../../recipes/IsLinker';
10
+ import { completeResponse } from '../../recipes/Runnable';
11
+ /**
12
+ * Maintain a series of queued items.
13
+ */
14
+ export declare class Queue {
15
+ queuedList: IsArrayable<any>;
16
+ private listClass;
17
+ private queueableClass;
18
+ /**
19
+ * Instantiate the queue with the given queue list.
20
+ * @param {Iterable|LinkedList} queuedList Give the list of queueables to start in this queue.
21
+ * @param {IsArrayable} listClass
22
+ * @param {Queueable} queueableClass
23
+ */
24
+ constructor(queuedList?: IsArrayable<any>, listClass?: any, queueableClass?: typeof Queueable);
25
+ /**
26
+ * Take a queued task from the front of the queue and run it if ready.
27
+ * @return {completeResponse|*}
28
+ */
29
+ dequeue(): completeResponse | any;
30
+ /**
31
+ * Return true if the queue is empty (there are no tasks in the queue list)
32
+ * @return {boolean}
33
+ */
34
+ empty(): boolean;
35
+ /**
36
+ * Add a queued task to the end of the queue
37
+ * @param {Queueable} queueable Add a new queueable to the end of the queue
38
+ */
39
+ enqueue(queueable: Queueable): void;
40
+ /**
41
+ * Take a look at the next queued task
42
+ * @return {Queueable}
43
+ */
44
+ peek(): IsLinker;
45
+ /**
46
+ * Remove the next queued item and return it.
47
+ * @return {Queueable|null}
48
+ */
49
+ remove(): Queueable | null;
50
+ /**
51
+ * Get the length of the current queue.
52
+ * @return {number}
53
+ */
54
+ size(): number;
55
+ /**
56
+ * Convert an array to a Queue.
57
+ * @param {Array} values An array of values which will be converted to queueables in this queue
58
+ * @param {Queueable} queueableClass The class to use for each queueable
59
+ * @param {Queue|Iterable} listClass The class to use to manage the queueables
60
+ * @returns {Queue}
61
+ */
62
+ static fromArray: (values?: Array<any>, queueableClass?: typeof Queueable, listClass?: any) => Queue;
63
+ }
@@ -1,130 +1,130 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.Queue = void 0
7
- var _Queueable = require('./Queueable')
8
- var _LinkedList = require('../linked-list/LinkedList')
9
- /**
10
- * @file queue
11
- * @author Joshua Heagle <joshuaheagle@gmail.com>
12
- * @version 1.1.0
13
- * @memberOf module:collect-your-stuff
14
- */
15
-
16
- /**
17
- * Maintain a series of queued items.
18
- */
19
- class Queue {
20
- /**
21
- * Instantiate the queue with the given queue list.
22
- * @param {Iterable|LinkedList} queuedList Give the list of queueables to start in this queue.
23
- * @param {IsArrayable} listClass
24
- * @param {Queueable} queueableClass
25
- */
26
- constructor (queuedList = null, listClass = _LinkedList.LinkedList, queueableClass = _Queueable.Queueable) {
27
- this.listClass = listClass
28
- this.queueableClass = queueableClass
29
- if (queuedList === null) {
30
- queuedList = new listClass(queueableClass)
31
- }
32
- this.queuedList = queuedList
33
- }
34
-
35
- /**
36
- * Take a queued task from the front of the queue and run it if ready.
37
- * @return {completeResponse|*}
38
- */
39
- dequeue () {
40
- const next = this.remove()
41
- if (!next) {
42
- return {
43
- success: 'No more queueable tasks in the queue',
44
- error: false,
45
- context: this.queuedList
46
- }
47
- }
48
- if (next.complete) {
49
- // Previously ran queued, run next
50
- return this.dequeue()
51
- }
52
- if (next.running) {
53
- return {
54
- success: false,
55
- error: 'The queue has been blocked by an unfinished task.',
56
- context: next
57
- }
58
- }
59
- if (!this.empty()) {
60
- // Place back in queue to be checked once again next time, only if the queue will not be empty
61
- this.enqueue(next)
62
- }
63
- if (next.isReady) {
64
- return next.run.call(next)
65
- }
66
- // We could go check the next in queue here but if we end up in a state where nothing is ready it would infinite loop
67
- // Also, we want the loop handled externally
68
- return {
69
- success: false,
70
- error: 'Unable to find ready task.',
71
- context: next
72
- }
73
- }
74
-
75
- /**
76
- * Return true if the queue is empty (there are no tasks in the queue list)
77
- * @return {boolean}
78
- */
79
- empty () {
80
- return this.size() <= 0
81
- }
82
-
83
- /**
84
- * Add a queued task to the end of the queue
85
- * @param {Queueable} queueable Add a new queueable to the end of the queue
86
- */
87
- enqueue (queueable) {
88
- this.queuedList.append(queueable)
89
- }
90
-
91
- /**
92
- * Take a look at the next queued task
93
- * @return {Queueable}
94
- */
95
- peek () {
96
- return this.queuedList.first
97
- }
98
-
99
- /**
100
- * Remove the next queued item and return it.
101
- * @return {Queueable|null}
102
- */
103
- remove () {
104
- if (this.empty()) {
105
- return null
106
- }
107
- return this.queuedList.remove(this.queuedList.first)
108
- }
109
-
110
- /**
111
- * Get the length of the current queue.
112
- * @return {number}
113
- */
114
- size () {
115
- return this.queuedList.length
116
- }
117
- }
118
- /**
119
- * Convert an array to a Queue.
120
- * @param {Array} values An array of values which will be converted to queueables in this queue
121
- * @param {Queueable} queueableClass The class to use for each queueable
122
- * @param {Queue|Iterable} listClass The class to use to manage the queueables
123
- * @returns {Queue}
124
- */
125
- exports.Queue = Queue
126
- Queue.fromArray = (values = [], queueableClass = _Queueable.Queueable, listClass = _LinkedList.LinkedList) => {
127
- const list = new listClass(queueableClass)
128
- list.initialize(queueableClass.fromArray(values, queueableClass).head)
129
- return new Queue(list, listClass, queueableClass)
130
- }
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.Queue = void 0
7
+ var _Queueable = require('./Queueable')
8
+ var _LinkedList = require('../linked-list/LinkedList')
9
+ /**
10
+ * @file queue
11
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
12
+ * @version 1.1.0
13
+ * @memberOf module:collect-your-stuff
14
+ */
15
+
16
+ /**
17
+ * Maintain a series of queued items.
18
+ */
19
+ class Queue {
20
+ /**
21
+ * Instantiate the queue with the given queue list.
22
+ * @param {Iterable|LinkedList} queuedList Give the list of queueables to start in this queue.
23
+ * @param {IsArrayable} listClass
24
+ * @param {Queueable} queueableClass
25
+ */
26
+ constructor (queuedList = null, listClass = _LinkedList.LinkedList, queueableClass = _Queueable.Queueable) {
27
+ this.listClass = listClass
28
+ this.queueableClass = queueableClass
29
+ if (queuedList === null) {
30
+ queuedList = new listClass(queueableClass)
31
+ }
32
+ this.queuedList = queuedList
33
+ }
34
+
35
+ /**
36
+ * Take a queued task from the front of the queue and run it if ready.
37
+ * @return {completeResponse|*}
38
+ */
39
+ dequeue () {
40
+ const next = this.remove()
41
+ if (!next) {
42
+ return {
43
+ success: 'No more queueable tasks in the queue',
44
+ error: false,
45
+ context: this.queuedList
46
+ }
47
+ }
48
+ if (next.complete) {
49
+ // Previously ran queued, run next
50
+ return this.dequeue()
51
+ }
52
+ if (next.running) {
53
+ return {
54
+ success: false,
55
+ error: 'The queue has been blocked by an unfinished task.',
56
+ context: next
57
+ }
58
+ }
59
+ if (!this.empty()) {
60
+ // Place back in queue to be checked once again next time, only if the queue will not be empty
61
+ this.enqueue(next)
62
+ }
63
+ if (next.isReady) {
64
+ return next.run.call(next)
65
+ }
66
+ // We could go check the next in queue here but if we end up in a state where nothing is ready it would infinite loop
67
+ // Also, we want the loop handled externally
68
+ return {
69
+ success: false,
70
+ error: 'Unable to find ready task.',
71
+ context: next
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Return true if the queue is empty (there are no tasks in the queue list)
77
+ * @return {boolean}
78
+ */
79
+ empty () {
80
+ return this.size() <= 0
81
+ }
82
+
83
+ /**
84
+ * Add a queued task to the end of the queue
85
+ * @param {Queueable} queueable Add a new queueable to the end of the queue
86
+ */
87
+ enqueue (queueable) {
88
+ this.queuedList.append(queueable)
89
+ }
90
+
91
+ /**
92
+ * Take a look at the next queued task
93
+ * @return {Queueable}
94
+ */
95
+ peek () {
96
+ return this.queuedList.first
97
+ }
98
+
99
+ /**
100
+ * Remove the next queued item and return it.
101
+ * @return {Queueable|null}
102
+ */
103
+ remove () {
104
+ if (this.empty()) {
105
+ return null
106
+ }
107
+ return this.queuedList.remove(this.queuedList.first)
108
+ }
109
+
110
+ /**
111
+ * Get the length of the current queue.
112
+ * @return {number}
113
+ */
114
+ size () {
115
+ return this.queuedList.length
116
+ }
117
+ }
118
+ /**
119
+ * Convert an array to a Queue.
120
+ * @param {Array} values An array of values which will be converted to queueables in this queue
121
+ * @param {Queueable} queueableClass The class to use for each queueable
122
+ * @param {Queue|Iterable} listClass The class to use to manage the queueables
123
+ * @returns {Queue}
124
+ */
125
+ exports.Queue = Queue
126
+ Queue.fromArray = (values = [], queueableClass = _Queueable.Queueable, listClass = _LinkedList.LinkedList) => {
127
+ const list = new listClass(queueableClass)
128
+ list.initialize(queueableClass.fromArray(values, queueableClass).head)
129
+ return new Queue(list, listClass, queueableClass)
130
+ }