collect-your-stuff 1.2.6 → 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 (74) hide show
  1. package/README.md +2525 -2525
  2. package/browser/collect-your-stuff.js +22766 -22859
  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 -70
  6. package/dist/collections/arrayable/ArrayElement.min.js +1 -1
  7. package/dist/collections/arrayable/Arrayable.d.ts +108 -108
  8. package/dist/collections/arrayable/Arrayable.js +188 -196
  9. package/dist/collections/arrayable/Arrayable.min.js +1 -1
  10. package/dist/collections/doubly-linked-list/DoubleLinker.d.ts +46 -46
  11. package/dist/collections/doubly-linked-list/DoubleLinker.js +69 -77
  12. package/dist/collections/doubly-linked-list/DoubleLinker.min.js +1 -1
  13. package/dist/collections/doubly-linked-list/DoublyLinkedList.d.ts +113 -113
  14. package/dist/collections/doubly-linked-list/DoublyLinkedList.js +274 -277
  15. package/dist/collections/doubly-linked-list/DoublyLinkedList.min.js +1 -1
  16. package/dist/collections/linked-list/LinkedList.d.ts +109 -109
  17. package/dist/collections/linked-list/LinkedList.js +233 -241
  18. package/dist/collections/linked-list/LinkedList.min.js +1 -1
  19. package/dist/collections/linked-list/Linker.d.ts +43 -43
  20. package/dist/collections/linked-list/Linker.js +80 -86
  21. package/dist/collections/linked-list/Linker.min.js +1 -1
  22. package/dist/collections/linked-tree-list/LinkedTreeList.d.ts +135 -135
  23. package/dist/collections/linked-tree-list/LinkedTreeList.js +252 -261
  24. package/dist/collections/linked-tree-list/LinkedTreeList.min.js +1 -1
  25. package/dist/collections/linked-tree-list/TreeLinker.d.ts +63 -63
  26. package/dist/collections/linked-tree-list/TreeLinker.js +79 -92
  27. package/dist/collections/linked-tree-list/TreeLinker.min.js +1 -1
  28. package/dist/collections/queue/Queue.d.ts +63 -63
  29. package/dist/collections/queue/Queue.js +130 -136
  30. package/dist/collections/queue/Queue.min.js +1 -1
  31. package/dist/collections/queue/Queueable.d.ts +77 -77
  32. package/dist/collections/queue/Queueable.js +141 -151
  33. package/dist/collections/queue/Queueable.min.js +1 -1
  34. package/dist/collections/stack/Stack.d.ts +63 -63
  35. package/dist/collections/stack/Stack.js +106 -112
  36. package/dist/collections/stack/Stack.min.js +1 -1
  37. package/dist/collections/stack/Stackable.d.ts +56 -56
  38. package/dist/collections/stack/Stackable.js +83 -91
  39. package/dist/collections/stack/Stackable.min.js +1 -1
  40. package/dist/main.d.ts +40 -40
  41. package/dist/main.js +50 -50
  42. package/dist/recipes/ArrayIterator.d.ts +10 -10
  43. package/dist/recipes/ArrayIterator.js +29 -30
  44. package/dist/recipes/ArrayIterator.min.js +1 -1
  45. package/dist/recipes/DoubleLinkerIterator.d.ts +9 -9
  46. package/dist/recipes/DoubleLinkerIterator.js +24 -24
  47. package/dist/recipes/IsArrayable.d.ts +105 -105
  48. package/dist/recipes/IsArrayable.js +5 -5
  49. package/dist/recipes/IsDoubleLinker.d.ts +14 -14
  50. package/dist/recipes/IsDoubleLinker.js +5 -5
  51. package/dist/recipes/IsElement.d.ts +14 -14
  52. package/dist/recipes/IsElement.js +5 -5
  53. package/dist/recipes/IsLinker.d.ts +10 -10
  54. package/dist/recipes/IsLinker.js +5 -5
  55. package/dist/recipes/IsTree.d.ts +11 -11
  56. package/dist/recipes/IsTree.js +5 -5
  57. package/dist/recipes/IsTreeNode.d.ts +29 -29
  58. package/dist/recipes/IsTreeNode.js +5 -5
  59. package/dist/recipes/LinkerIterator.d.ts +9 -9
  60. package/dist/recipes/LinkerIterator.js +24 -24
  61. package/dist/recipes/Runnable.d.ts +54 -54
  62. package/dist/recipes/Runnable.js +68 -69
  63. package/dist/recipes/Runnable.min.js +1 -1
  64. package/dist/recipes/TreeLinkerIterator.d.ts +9 -9
  65. package/dist/recipes/TreeLinkerIterator.js +25 -25
  66. package/dist/recipes/recipes.d.ts +15 -15
  67. package/dist/recipes/recipes.js +22 -22
  68. package/dist/services/parseTree.d.ts +9 -9
  69. package/dist/services/parseTree.js +24 -24
  70. package/dist/services/parseTreeNext.d.ts +14 -14
  71. package/dist/services/parseTreeNext.js +47 -47
  72. package/dist/services/services.d.ts +13 -13
  73. package/dist/services/services.js +22 -22
  74. package/package.json +2 -2
@@ -1,136 +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 () {
27
- let queuedList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null
28
- const listClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _LinkedList.LinkedList
29
- const queueableClass = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _Queueable.Queueable
30
- this.listClass = listClass
31
- this.queueableClass = queueableClass
32
- if (queuedList === null) {
33
- queuedList = new listClass(queueableClass)
34
- }
35
- this.queuedList = queuedList
36
- }
37
-
38
- /**
39
- * Take a queued task from the front of the queue and run it if ready.
40
- * @return {completeResponse|*}
41
- */
42
- dequeue () {
43
- const next = this.remove()
44
- if (!next) {
45
- return {
46
- success: 'No more queueable tasks in the queue',
47
- error: false,
48
- context: this.queuedList
49
- }
50
- }
51
- if (next.complete) {
52
- // Previously ran queued, run next
53
- return this.dequeue()
54
- }
55
- if (next.running) {
56
- return {
57
- success: false,
58
- error: 'The queue has been blocked by an unfinished task.',
59
- context: next
60
- }
61
- }
62
- if (!this.empty()) {
63
- // Place back in queue to be checked once again next time, only if the queue will not be empty
64
- this.enqueue(next)
65
- }
66
- if (next.isReady) {
67
- return next.run.call(next)
68
- }
69
- // 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
70
- // Also, we want the loop handled externally
71
- return {
72
- success: false,
73
- error: 'Unable to find ready task.',
74
- context: next
75
- }
76
- }
77
-
78
- /**
79
- * Return true if the queue is empty (there are no tasks in the queue list)
80
- * @return {boolean}
81
- */
82
- empty () {
83
- return this.size() <= 0
84
- }
85
-
86
- /**
87
- * Add a queued task to the end of the queue
88
- * @param {Queueable} queueable Add a new queueable to the end of the queue
89
- */
90
- enqueue (queueable) {
91
- this.queuedList.append(queueable)
92
- }
93
-
94
- /**
95
- * Take a look at the next queued task
96
- * @return {Queueable}
97
- */
98
- peek () {
99
- return this.queuedList.first
100
- }
101
-
102
- /**
103
- * Remove the next queued item and return it.
104
- * @return {Queueable|null}
105
- */
106
- remove () {
107
- if (this.empty()) {
108
- return null
109
- }
110
- return this.queuedList.remove(this.queuedList.first)
111
- }
112
-
113
- /**
114
- * Get the length of the current queue.
115
- * @return {number}
116
- */
117
- size () {
118
- return this.queuedList.length
119
- }
120
- }
121
- /**
122
- * Convert an array to a Queue.
123
- * @param {Array} values An array of values which will be converted to queueables in this queue
124
- * @param {Queueable} queueableClass The class to use for each queueable
125
- * @param {Queue|Iterable} listClass The class to use to manage the queueables
126
- * @returns {Queue}
127
- */
128
- exports.Queue = Queue
129
- Queue.fromArray = function () {
130
- const values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []
131
- const queueableClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _Queueable.Queueable
132
- const listClass = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _LinkedList.LinkedList
133
- const list = new listClass(queueableClass)
134
- list.initialize(queueableClass.fromArray(values, queueableClass).head)
135
- return new Queue(list, listClass, queueableClass)
136
- }
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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Queue=void 0;var _Queueable=require("./Queueable"),_LinkedList=require("../linked-list/LinkedList");class Queue{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_LinkedList.LinkedList,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:_Queueable.Queueable;this.listClass=u,this.queueableClass=t,null===e&&(e=new u(t)),this.queuedList=e}dequeue(){const e=this.remove();return e?e.complete?this.dequeue():e.running?{success:!1,error:"The queue has been blocked by an unfinished task.",context:e}:(this.empty()||this.enqueue(e),e.isReady?e.run.call(e):{success:!1,error:"Unable to find ready task.",context:e}):{success:"No more queueable tasks in the queue",error:!1,context:this.queuedList}}empty(){return this.size()<=0}enqueue(e){this.queuedList.append(e)}peek(){return this.queuedList.first}remove(){return this.empty()?null:this.queuedList.remove(this.queuedList.first)}size(){return this.queuedList.length}}exports.Queue=Queue,Queue.fromArray=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_Queueable.Queueable,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:_LinkedList.LinkedList;const s=new t(u);return s.initialize(u.fromArray(e,u).head),new Queue(s,t,u)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Queue=void 0;var _Queueable=require("./Queueable"),_LinkedList=require("../linked-list/LinkedList");class Queue{constructor(e=null,u=_LinkedList.LinkedList,t=_Queueable.Queueable){this.listClass=u,this.queueableClass=t,null===e&&(e=new u(t)),this.queuedList=e}dequeue(){const e=this.remove();return e?e.complete?this.dequeue():e.running?{success:!1,error:"The queue has been blocked by an unfinished task.",context:e}:(this.empty()||this.enqueue(e),e.isReady?e.run.call(e):{success:!1,error:"Unable to find ready task.",context:e}):{success:"No more queueable tasks in the queue",error:!1,context:this.queuedList}}empty(){return this.size()<=0}enqueue(e){this.queuedList.append(e)}peek(){return this.queuedList.first}remove(){return this.empty()?null:this.queuedList.remove(this.queuedList.first)}size(){return this.queuedList.length}}exports.Queue=Queue,Queue.fromArray=(e=[],u=_Queueable.Queueable,t=_LinkedList.LinkedList)=>{const s=new t(u);return s.initialize(u.fromArray(e,u).head),new Queue(s,t,u)};
@@ -1,77 +1,77 @@
1
- /**
2
- * @file queueable item.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.1.0
5
- * @memberOf module:collect-your-stuff
6
- */
7
- import { completeResponse, IsRunnable } from '../../recipes/Runnable';
8
- import { IsLinker } from '../../recipes/IsLinker';
9
- /**
10
- * Queueable represents a runnable entry in a queue.
11
- * @extends Linker
12
- */
13
- export declare class Queueable implements IsLinker, IsRunnable {
14
- readonly classType: typeof Queueable;
15
- data: any;
16
- next: Queueable | null;
17
- complete: boolean;
18
- ready: Function | boolean;
19
- running: boolean;
20
- /**
21
- * Create a queueable item that can be used in a queue.
22
- * @param {Object} [queueableData={}]
23
- * @param {*} [queueableData.task=null] The data to be stored in this queueable
24
- * @param {Queueable|null} [queueableData.next=null] The reference to the next queueable if any
25
- * @param {boolean|Function} [queueableData.ready=false] Indicate if the queueable is ready to run
26
- */
27
- constructor({ task, next, ready }?: {
28
- task?: any;
29
- next?: Queueable | null;
30
- ready?: boolean;
31
- });
32
- /**
33
- * Check ready state.
34
- * @return {boolean}
35
- */
36
- get isReady(): boolean;
37
- /**
38
- * Retrieve the data which should be formed as a task.
39
- * @return {*}
40
- */
41
- get task(): any;
42
- /**
43
- * Set this queueable as completed.
44
- * @param {Object} completeResponse
45
- * @param {*} [completeResponse.success=true] Indicate when the task failed (use false) or give a success message
46
- * @param {*} [completeResponse.error=false] Indicate a task was error-free (use false) or give an error message
47
- * @param {*} [completeResponse.context=null] Provide additional data in the response
48
- * @return {completeResponse}
49
- */
50
- markCompleted({ success, error, context }?: {
51
- success?: any;
52
- error?: any;
53
- context?: any;
54
- }): completeResponse;
55
- /**
56
- * Intend to run the queued task when it is ready. If ready, mark this task as running and run the task.
57
- * @return {completeResponse}
58
- */
59
- run(): completeResponse;
60
- /**
61
- * Make a new Queueable from the data given if it is not already a valid Queueable.
62
- * @param {Queueable|*} queueable Return a valid Queueable instance from given data, or even an already valid one.
63
- * @param {IsLinker} [classType=Queueable] Provide the type of IsLinker to use.
64
- * @return {Queueable}
65
- */
66
- static make: (queueable: Queueable | any, classType?: any) => IsLinker;
67
- /**
68
- * Convert an array into Queueable instances, return the head and tail Queueables.
69
- * @param {Array} values Provide an array of data that will be converted to a chain of queueable linkers.
70
- * @param {IsLinker} [classType=Queueable] Provide the type of IsLinker to use.
71
- * @returns {{head: Queueable, tail: Queueable}}
72
- */
73
- static fromArray: (values: Array<any>, classType?: any) => {
74
- head: IsLinker;
75
- tail: IsLinker;
76
- };
77
- }
1
+ /**
2
+ * @file queueable item.
3
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
4
+ * @version 1.1.0
5
+ * @memberOf module:collect-your-stuff
6
+ */
7
+ import { completeResponse, IsRunnable } from '../../recipes/Runnable';
8
+ import { IsLinker } from '../../recipes/IsLinker';
9
+ /**
10
+ * Queueable represents a runnable entry in a queue.
11
+ * @extends Linker
12
+ */
13
+ export declare class Queueable implements IsLinker, IsRunnable {
14
+ readonly classType: typeof Queueable;
15
+ data: any;
16
+ next: Queueable | null;
17
+ complete: boolean;
18
+ ready: Function | boolean;
19
+ running: boolean;
20
+ /**
21
+ * Create a queueable item that can be used in a queue.
22
+ * @param {Object} [queueableData={}]
23
+ * @param {*} [queueableData.task=null] The data to be stored in this queueable
24
+ * @param {Queueable|null} [queueableData.next=null] The reference to the next queueable if any
25
+ * @param {boolean|Function} [queueableData.ready=false] Indicate if the queueable is ready to run
26
+ */
27
+ constructor({ task, next, ready }?: {
28
+ task?: any;
29
+ next?: Queueable | null;
30
+ ready?: boolean;
31
+ });
32
+ /**
33
+ * Check ready state.
34
+ * @return {boolean}
35
+ */
36
+ get isReady(): boolean;
37
+ /**
38
+ * Retrieve the data which should be formed as a task.
39
+ * @return {*}
40
+ */
41
+ get task(): any;
42
+ /**
43
+ * Set this queueable as completed.
44
+ * @param {Object} completeResponse
45
+ * @param {*} [completeResponse.success=true] Indicate when the task failed (use false) or give a success message
46
+ * @param {*} [completeResponse.error=false] Indicate a task was error-free (use false) or give an error message
47
+ * @param {*} [completeResponse.context=null] Provide additional data in the response
48
+ * @return {completeResponse}
49
+ */
50
+ markCompleted({ success, error, context }?: {
51
+ success?: any;
52
+ error?: any;
53
+ context?: any;
54
+ }): completeResponse;
55
+ /**
56
+ * Intend to run the queued task when it is ready. If ready, mark this task as running and run the task.
57
+ * @return {completeResponse}
58
+ */
59
+ run(): completeResponse;
60
+ /**
61
+ * Make a new Queueable from the data given if it is not already a valid Queueable.
62
+ * @param {Queueable|*} queueable Return a valid Queueable instance from given data, or even an already valid one.
63
+ * @param {IsLinker} [classType=Queueable] Provide the type of IsLinker to use.
64
+ * @return {Queueable}
65
+ */
66
+ static make: (queueable: Queueable | any, classType?: any) => IsLinker;
67
+ /**
68
+ * Convert an array into Queueable instances, return the head and tail Queueables.
69
+ * @param {Array} values Provide an array of data that will be converted to a chain of queueable linkers.
70
+ * @param {IsLinker} [classType=Queueable] Provide the type of IsLinker to use.
71
+ * @returns {{head: Queueable, tail: Queueable}}
72
+ */
73
+ static fromArray: (values: Array<any>, classType?: any) => {
74
+ head: IsLinker;
75
+ tail: IsLinker;
76
+ };
77
+ }