collect-your-stuff 1.2.6 → 1.2.7
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.
- package/README.md +39 -39
- package/browser/collect-your-stuff.js +123 -221
- package/browser/collect-your-stuff.min.js +1 -1
- package/dist/collections/arrayable/ArrayElement.js +18 -24
- package/dist/collections/arrayable/ArrayElement.min.js +1 -1
- package/dist/collections/arrayable/Arrayable.js +5 -13
- package/dist/collections/arrayable/Arrayable.min.js +1 -1
- package/dist/collections/doubly-linked-list/DoubleLinker.js +23 -31
- package/dist/collections/doubly-linked-list/DoubleLinker.min.js +1 -1
- package/dist/collections/doubly-linked-list/DoublyLinkedList.js +5 -13
- package/dist/collections/doubly-linked-list/DoublyLinkedList.min.js +1 -1
- package/dist/collections/linked-list/LinkedList.js +5 -13
- package/dist/collections/linked-list/LinkedList.min.js +1 -1
- package/dist/collections/linked-list/Linker.js +21 -27
- package/dist/collections/linked-list/Linker.min.js +1 -1
- package/dist/collections/linked-tree-list/LinkedTreeList.js +6 -15
- package/dist/collections/linked-tree-list/LinkedTreeList.min.js +1 -1
- package/dist/collections/linked-tree-list/TreeLinker.js +11 -24
- package/dist/collections/linked-tree-list/TreeLinker.min.js +1 -1
- package/dist/collections/queue/Queue.js +2 -8
- package/dist/collections/queue/Queue.min.js +1 -1
- package/dist/collections/queue/Queueable.js +12 -22
- package/dist/collections/queue/Queueable.min.js +1 -1
- package/dist/collections/stack/Stack.js +2 -8
- package/dist/collections/stack/Stack.min.js +1 -1
- package/dist/collections/stack/Stackable.js +7 -15
- package/dist/collections/stack/Stackable.min.js +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/recipes/ArrayIterator.js +1 -2
- package/dist/recipes/ArrayIterator.min.js +1 -1
- package/dist/recipes/Runnable.js +1 -2
- package/dist/recipes/Runnable.min.js +1 -1
- package/dist/services/services.d.ts +1 -1
- package/package.json +2 -2
|
@@ -17,14 +17,11 @@ class Queueable {
|
|
|
17
17
|
* @param {Queueable|null} [queueableData.next=null] The reference to the next queueable if any
|
|
18
18
|
* @param {boolean|Function} [queueableData.ready=false] Indicate if the queueable is ready to run
|
|
19
19
|
*/
|
|
20
|
-
constructor (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const next = _ref$next === void 0 ? null : _ref$next
|
|
26
|
-
const _ref$ready = _ref.ready
|
|
27
|
-
const ready = _ref$ready === void 0 ? false : _ref$ready
|
|
20
|
+
constructor ({
|
|
21
|
+
task = null,
|
|
22
|
+
next = null,
|
|
23
|
+
ready = false
|
|
24
|
+
} = {}) {
|
|
28
25
|
this.data = null
|
|
29
26
|
this.next = null
|
|
30
27
|
this.complete = false
|
|
@@ -67,14 +64,11 @@ class Queueable {
|
|
|
67
64
|
* @param {*} [completeResponse.context=null] Provide additional data in the response
|
|
68
65
|
* @return {completeResponse}
|
|
69
66
|
*/
|
|
70
|
-
markCompleted (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const error = _ref2$error === void 0 ? false : _ref2$error
|
|
76
|
-
const _ref2$context = _ref2.context
|
|
77
|
-
const context = _ref2$context === void 0 ? null : _ref2$context
|
|
67
|
+
markCompleted ({
|
|
68
|
+
success = true,
|
|
69
|
+
error = false,
|
|
70
|
+
context = null
|
|
71
|
+
} = {}) {
|
|
78
72
|
this.complete = true
|
|
79
73
|
this.running = false
|
|
80
74
|
return {
|
|
@@ -117,8 +111,7 @@ class Queueable {
|
|
|
117
111
|
* @return {Queueable}
|
|
118
112
|
*/
|
|
119
113
|
exports.Queueable = Queueable
|
|
120
|
-
Queueable.make =
|
|
121
|
-
const classType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Queueable
|
|
114
|
+
Queueable.make = (queueable, classType = Queueable) => {
|
|
122
115
|
if (typeof queueable !== 'object') {
|
|
123
116
|
// It is not an object, so instantiate the Queueable with an element as the data
|
|
124
117
|
return new classType({
|
|
@@ -145,7 +138,4 @@ Queueable.make = function (queueable) {
|
|
|
145
138
|
* @param {IsLinker} [classType=Queueable] Provide the type of IsLinker to use.
|
|
146
139
|
* @returns {{head: Queueable, tail: Queueable}}
|
|
147
140
|
*/
|
|
148
|
-
Queueable.fromArray =
|
|
149
|
-
const classType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Queueable
|
|
150
|
-
return _Linker.Linker.fromArray(values, classType)
|
|
151
|
-
}
|
|
141
|
+
Queueable.fromArray = (values, classType = Queueable) => _Linker.Linker.fromArray(values, classType)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Queueable=void 0;var _Linker=require("../linked-list/Linker");class Queueable{constructor(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Queueable=void 0;var _Linker=require("../linked-list/Linker");class Queueable{constructor({task:e=null,next:t=null,ready:s=!1}={}){this.data=null,this.next=null,this.complete=!1,this.ready=!1,this.running=!1,this.classType=Queueable,this.data=e,this.next=t,this.complete=!1,this.ready=s,this.running=!1}get isReady(){return"function"==typeof this.ready?this.ready():this.ready}get task(){return"function"==typeof this.data?this.data:e=>"function"==typeof e?e({context:this.data}).context:this.data}markCompleted({success:e=!0,error:t=!1,context:s=null}={}){return this.complete=!0,this.running=!1,{success:e,error:t,context:s}}run(){return this.isReady?this.running?{success:!1,error:"Queued task is already running, possible missing 'complete' callback",context:this.data}:(this.running=!0,this.task(this.markCompleted.bind(this))):{success:!1,error:"Task is not ready",context:this.data}}}exports.Queueable=Queueable,Queueable.make=(e,t=Queueable)=>"object"!=typeof e?new t({task:e,ready:!0}):e.classType?e:(e.task||(e={task:e,ready:!0}),new t(e)),Queueable.fromArray=(e,t=Queueable)=>_Linker.Linker.fromArray(e,t);
|
|
@@ -23,10 +23,7 @@ class Stack {
|
|
|
23
23
|
* @param {IsArrayable} listClass
|
|
24
24
|
* @param {Stackable} stackableClass
|
|
25
25
|
*/
|
|
26
|
-
constructor () {
|
|
27
|
-
let stackedList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null
|
|
28
|
-
const listClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _LinkedList.LinkedList
|
|
29
|
-
const stackableClass = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _Stackable.Stackable
|
|
26
|
+
constructor (stackedList = null, listClass = _LinkedList.LinkedList, stackableClass = _Stackable.Stackable) {
|
|
30
27
|
this.listClass = listClass
|
|
31
28
|
this.stackableClass = stackableClass
|
|
32
29
|
if (stackedList === null) {
|
|
@@ -102,10 +99,7 @@ class Stack {
|
|
|
102
99
|
* @returns {Stack}
|
|
103
100
|
*/
|
|
104
101
|
exports.Stack = Stack
|
|
105
|
-
Stack.fromArray =
|
|
106
|
-
const values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []
|
|
107
|
-
const stackableClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _Stackable.Stackable
|
|
108
|
-
const listClass = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _LinkedList.LinkedList
|
|
102
|
+
Stack.fromArray = (values = [], stackableClass = _Stackable.Stackable, listClass = _LinkedList.LinkedList) => {
|
|
109
103
|
const list = new listClass(stackableClass)
|
|
110
104
|
list.initialize(stackableClass.fromArray(values, stackableClass).head)
|
|
111
105
|
return new Stack(list)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Stack=void 0;var _Stackable=require("./Stackable"),_LinkedList=require("../linked-list/LinkedList");class Stack{constructor(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Stack=void 0;var _Stackable=require("./Stackable"),_LinkedList=require("../linked-list/LinkedList");class Stack{constructor(t=null,e=_LinkedList.LinkedList,s=_Stackable.Stackable){this.listClass=e,this.stackableClass=s,null===t&&(t=new e(s)),this.stackedList=t}empty(){return this.size()<=0}top(){return this.stackedList.first}pop(){const t=this.remove();return t?t.run():{success:"No more stackable tasks in the stack",error:!1,context:this.stackedList}}push(t){this.stackedList.prepend(t)}remove(){return this.empty()?null:this.stackedList.remove(this.stackedList.first)}size(){return this.stackedList.length}}exports.Stack=Stack,Stack.fromArray=(t=[],e=_Stackable.Stackable,s=_LinkedList.LinkedList)=>{const i=new s(e);return i.initialize(e.fromArray(t,e).head),new Stack(i)};
|
|
@@ -17,14 +17,11 @@ class Stackable {
|
|
|
17
17
|
* @param {Stackable|null} [stackData.next=null] The reference to the next stackable if any
|
|
18
18
|
* @param {boolean|Function} [stackData.ready=false] Indicate if the stackable is ready to run
|
|
19
19
|
*/
|
|
20
|
-
constructor (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const next = _ref$next === void 0 ? null : _ref$next
|
|
26
|
-
const _ref$ready = _ref.ready
|
|
27
|
-
const ready = _ref$ready === void 0 ? false : _ref$ready
|
|
20
|
+
constructor ({
|
|
21
|
+
task = null,
|
|
22
|
+
next = null,
|
|
23
|
+
ready = false
|
|
24
|
+
} = {}) {
|
|
28
25
|
this.data = null
|
|
29
26
|
this.next = null
|
|
30
27
|
this.classType = Stackable
|
|
@@ -58,8 +55,7 @@ class Stackable {
|
|
|
58
55
|
* @return {Stackable}
|
|
59
56
|
*/
|
|
60
57
|
exports.Stackable = Stackable
|
|
61
|
-
Stackable.make =
|
|
62
|
-
const classType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Stackable
|
|
58
|
+
Stackable.make = (stackable, classType = Stackable) => {
|
|
63
59
|
if (typeof stackable !== 'object') {
|
|
64
60
|
// It is not an object, so instantiate the Stackable with stackable as the data
|
|
65
61
|
return new classType({
|
|
@@ -84,8 +80,4 @@ Stackable.make = function (stackable) {
|
|
|
84
80
|
* @param {IsLinker} [classType=Stackable] Provide the type of IsLinker to use.
|
|
85
81
|
* @returns {{head: Stackable, tail: Stackable}}
|
|
86
82
|
*/
|
|
87
|
-
Stackable.fromArray =
|
|
88
|
-
const values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []
|
|
89
|
-
const classType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Stackable
|
|
90
|
-
return _Linker.Linker.fromArray(values, classType)
|
|
91
|
-
}
|
|
83
|
+
Stackable.fromArray = (values = [], classType = Stackable) => _Linker.Linker.fromArray(values, classType)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Stackable=void 0;var _Linker=require("../linked-list/Linker");class Stackable{constructor(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Stackable=void 0;var _Linker=require("../linked-list/Linker");class Stackable{constructor({task:t=null,next:a=null,ready:e=!1}={}){this.data=null,this.next=null,this.classType=Stackable,this.data=t,this.next=a}get task(){return"function"==typeof this.data?this.data:()=>this.data}run(){return this.task()}}exports.Stackable=Stackable,Stackable.make=(t,a=Stackable)=>"object"!=typeof t?new a({task:t}):t.classType?t:(t.task||(t={task:t}),new Stackable(t)),Stackable.fromArray=(t=[],a=Stackable)=>_Linker.Linker.fromArray(t,a);
|
package/dist/main.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ declare const collectYourStuff: {
|
|
|
34
34
|
};
|
|
35
35
|
services: {
|
|
36
36
|
parseTree: (tree: import("./recipes/IsTree").IsTree, callback: import("./recipes/IsArrayable").forEachCallback) => import("./recipes/IsTree").IsTree;
|
|
37
|
-
parseTreeNext: (treeNode: import("./recipes/IsTreeNode").IsTreeNode) => import("./recipes/IsTreeNode").IsTreeNode;
|
|
37
|
+
parseTreeNext: (treeNode: import("./recipes/IsTreeNode").IsTreeNode) => import("./recipes/IsTreeNode").IsTreeNode | null;
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
export default collectYourStuff;
|
|
@@ -8,8 +8,7 @@ exports.ArrayIterator = void 0
|
|
|
8
8
|
* Class ArrayIterator returns the next value when using elements of array type list.
|
|
9
9
|
*/
|
|
10
10
|
class ArrayIterator {
|
|
11
|
-
constructor (innerList) {
|
|
12
|
-
const index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0
|
|
11
|
+
constructor (innerList, index = 0) {
|
|
13
12
|
this.innerList = innerList
|
|
14
13
|
this.index = index
|
|
15
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ArrayIterator=void 0;class ArrayIterator{constructor(t){
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ArrayIterator=void 0;class ArrayIterator{constructor(r,t=0){this.innerList=r,this.index=t}next(r){return this.index<this.innerList.length?{value:this.innerList[this.index++],done:!1}:{value:void 0,done:!0}}}exports.ArrayIterator=ArrayIterator;
|
package/dist/recipes/Runnable.js
CHANGED
|
@@ -18,8 +18,7 @@ class Runnable {
|
|
|
18
18
|
* Instantiate a Runnable class.
|
|
19
19
|
* @param {*} data
|
|
20
20
|
*/
|
|
21
|
-
constructor () {
|
|
22
|
-
const data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null
|
|
21
|
+
constructor (data = null) {
|
|
23
22
|
this.data = null
|
|
24
23
|
this.data = data
|
|
25
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Runnable=void 0;class Runnable{constructor(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Runnable=void 0;class Runnable{constructor(t=null){this.data=null,this.data=t}get task(){return"function"==typeof this.data?this.data:()=>this.data}run(){return this.task()}static isRunnable(t){return void 0===t?this instanceof Runnable:"object"==typeof t&&("function"==typeof t.task&&"function"==typeof t.run)}}exports.Runnable=Runnable;
|
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const services: {
|
|
11
11
|
parseTree: (tree: import("../recipes/IsTree").IsTree, callback: import("../recipes/IsArrayable").forEachCallback) => import("../recipes/IsTree").IsTree;
|
|
12
|
-
parseTreeNext: (treeNode: import("../recipes/IsTreeNode").IsTreeNode) => import("../recipes/IsTreeNode").IsTreeNode;
|
|
12
|
+
parseTreeNext: (treeNode: import("../recipes/IsTreeNode").IsTreeNode) => import("../recipes/IsTreeNode").IsTreeNode | null;
|
|
13
13
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "collect-your-stuff",
|
|
3
3
|
"description": "Use a variety of collections to collect your stuff when building code.",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.7",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"types": "dist/main.d.ts",
|
|
7
7
|
"author": "Joshua Heagle",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"watch:test": "gulp watchTest"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"js-build-tools": "^4.
|
|
27
|
+
"js-build-tools": "^4.1.1"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|