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.
- package/README.md +32 -3241
- package/browser/collect-your-stuff.js +1585 -1193
- package/browser/collect-your-stuff.min.js +1 -1
- package/dist/collections/arrayable/ArrayElement.d.ts +33 -38
- package/dist/collections/arrayable/ArrayElement.js +64 -66
- package/dist/collections/arrayable/Arrayable.d.ts +107 -122
- package/dist/collections/arrayable/Arrayable.js +208 -223
- package/dist/collections/doubly-linked-list/DoubleLinker.d.ts +45 -50
- package/dist/collections/doubly-linked-list/DoubleLinker.js +71 -73
- package/dist/collections/doubly-linked-list/DoublyLinkedList.d.ts +108 -125
- package/dist/collections/doubly-linked-list/DoublyLinkedList.js +310 -327
- package/dist/collections/linked-list/LinkedList.d.ts +110 -126
- package/dist/collections/linked-list/LinkedList.js +283 -296
- package/dist/collections/linked-list/Linker.d.ts +41 -46
- package/dist/collections/linked-list/Linker.js +82 -84
- package/dist/collections/linked-tree-list/LinkedTreeList.d.ts +140 -159
- package/dist/collections/linked-tree-list/LinkedTreeList.js +274 -294
- package/dist/collections/linked-tree-list/TreeLinker.d.ts +65 -71
- package/dist/collections/linked-tree-list/TreeLinker.js +91 -94
- package/dist/collections/queue/Queue.d.ts +55 -59
- package/dist/collections/queue/Queue.js +114 -119
- package/dist/collections/queue/Queueable.d.ts +74 -83
- package/dist/collections/queue/Queueable.js +142 -146
- package/dist/collections/queue/TaskQueue.d.ts +59 -68
- package/dist/collections/queue/TaskQueue.js +128 -137
- package/dist/collections/scoped-collection/ScopedCollection.d.ts +42 -0
- package/dist/collections/scoped-collection/ScopedCollection.js +81 -0
- package/dist/collections/scoped-collection/ScopedCollection.min.js +1 -0
- package/dist/collections/stack/Stack.d.ts +60 -64
- package/dist/collections/stack/Stack.js +122 -127
- package/dist/collections/stack/Stackable.d.ts +52 -59
- package/dist/collections/stack/Stackable.js +81 -85
- package/dist/collections/stack/TaskStack.d.ts +56 -65
- package/dist/collections/stack/TaskStack.js +98 -107
- package/dist/main.d.ts +4 -5
- package/dist/main.js +9 -5
- package/dist/main.min.js +1 -1
- package/dist/recipes/ArrayIterator.d.ts +20 -20
- package/dist/recipes/ArrayIterator.js +39 -39
- package/dist/recipes/DoubleLinkerIterator.d.ts +18 -18
- package/dist/recipes/DoubleLinkerIterator.js +33 -33
- package/dist/recipes/IsArrayable.d.ts +85 -105
- package/dist/recipes/IsArrayable.js +5 -5
- package/dist/recipes/IsDoubleLinker.d.ts +14 -14
- package/dist/recipes/IsDoubleLinker.js +5 -5
- package/dist/recipes/IsElement.d.ts +14 -14
- package/dist/recipes/IsElement.js +5 -5
- package/dist/recipes/IsLinker.d.ts +10 -10
- package/dist/recipes/IsLinker.js +5 -5
- package/dist/recipes/IsQueue.d.ts +32 -37
- package/dist/recipes/IsQueue.js +5 -5
- package/dist/recipes/IsScopedCollection.d.ts +27 -0
- package/dist/recipes/IsScopedCollection.js +5 -0
- package/dist/recipes/IsScopedCollection.min.js +1 -0
- package/dist/recipes/IsStack.d.ts +31 -36
- package/dist/recipes/IsStack.js +5 -5
- package/dist/recipes/IsTree.d.ts +11 -11
- package/dist/recipes/IsTree.js +5 -5
- package/dist/recipes/IsTreeNode.d.ts +29 -29
- package/dist/recipes/IsTreeNode.js +5 -5
- package/dist/recipes/LinkerIterator.d.ts +18 -18
- package/dist/recipes/LinkerIterator.js +33 -33
- package/dist/recipes/Runnable.d.ts +42 -55
- package/dist/recipes/Runnable.js +63 -69
- package/dist/recipes/TreeLinkerIterator.d.ts +20 -20
- package/dist/recipes/TreeLinkerIterator.js +36 -36
- package/dist/recipes/recipes.d.ts +12 -15
- package/dist/recipes/recipes.js +19 -22
- package/dist/services/parseTree.d.ts +8 -9
- package/dist/services/parseTree.js +23 -24
- package/dist/services/parseTreeNext.d.ts +16 -17
- package/dist/services/parseTreeNext.js +41 -42
- package/dist/services/services.d.ts +10 -13
- package/dist/services/services.js +19 -22
- package/package.json +4 -4
|
@@ -1,127 +1,122 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.Stack = void 0
|
|
7
|
-
require('core-js/modules/esnext.iterator.constructor.js')
|
|
8
|
-
require('core-js/modules/esnext.iterator.for-each.js')
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
Stack.fromArray = (values = [], listClass = _LinkedList.LinkedList, linkerClass = _Linker.Linker) => {
|
|
124
|
-
const stack = new Stack(null, listClass, linkerClass)
|
|
125
|
-
values.forEach(value => stack.push(value))
|
|
126
|
-
return stack
|
|
127
|
-
}
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.Stack = void 0
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js')
|
|
8
|
+
require('core-js/modules/esnext.iterator.for-each.js')
|
|
9
|
+
const _LinkedList = require('../linked-list/LinkedList')
|
|
10
|
+
const _Linker = require('../linked-list/Linker')
|
|
11
|
+
/**
|
|
12
|
+
* stack.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A last-in-first-out collection: items are added to the top with push and taken from the top with pop. Any value can
|
|
17
|
+
* be stacked (it is stored as it is, whether it is a function, an object or null), and adding and taking are constant
|
|
18
|
+
* time. To stack tasks which are run as they are taken use TaskStack.
|
|
19
|
+
*/
|
|
20
|
+
class Stack {
|
|
21
|
+
/**
|
|
22
|
+
* Instantiate the stack, optionally with a list of items to start from.
|
|
23
|
+
* @param stackedList The list of linkers to start in this stack (the first is the top)
|
|
24
|
+
* @param listClass The type of list to create when no stacked list is given
|
|
25
|
+
* @param linkerClass The class used to hold each stacked item
|
|
26
|
+
*/
|
|
27
|
+
constructor (stackedList = null, listClass = _LinkedList.LinkedList, linkerClass = _Linker.Linker) {
|
|
28
|
+
this.linkerClass = linkerClass
|
|
29
|
+
this.stackedList = stackedList === null ? new listClass(linkerClass) : stackedList
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Check whether the stack has no items.
|
|
34
|
+
*/
|
|
35
|
+
empty () {
|
|
36
|
+
return this.size() <= 0
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Look at the item on the top of the stack, without removing it.
|
|
41
|
+
* @returns The item, or null when the stack is empty
|
|
42
|
+
*/
|
|
43
|
+
peek () {
|
|
44
|
+
const top = this.stackedList.first
|
|
45
|
+
return top === null || typeof top === 'undefined' ? null : top.data
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Take the item from the top of the stack.
|
|
50
|
+
* @returns The item, or null when the stack is empty
|
|
51
|
+
*/
|
|
52
|
+
pop () {
|
|
53
|
+
const top = this.stackedList.first
|
|
54
|
+
if (top === null || typeof top === 'undefined') {
|
|
55
|
+
return null
|
|
56
|
+
}
|
|
57
|
+
this.stackedList.remove(top)
|
|
58
|
+
return top.data
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Add an item to the top of the stack.
|
|
63
|
+
* @param data The item to add
|
|
64
|
+
* @returns This stack, so that adding can be chained
|
|
65
|
+
*/
|
|
66
|
+
push (data) {
|
|
67
|
+
// The item is wrapped here rather than left to the list, since the list treats objects that look like a linker's
|
|
68
|
+
// settings (they have a data property) as such, and a stack must give back exactly what it was given
|
|
69
|
+
this.stackedList.prepend(new this.linkerClass({
|
|
70
|
+
data
|
|
71
|
+
}))
|
|
72
|
+
return this
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Count the items in the stack.
|
|
77
|
+
*/
|
|
78
|
+
size () {
|
|
79
|
+
return this.stackedList.length
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The item on the top of the stack (the same as peek).
|
|
84
|
+
* @returns The item, or null when the stack is empty
|
|
85
|
+
*/
|
|
86
|
+
top () {
|
|
87
|
+
return this.peek()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Iterate over the items from the top of the stack to the bottom, without removing them.
|
|
92
|
+
*/
|
|
93
|
+
[Symbol.iterator] () {
|
|
94
|
+
const linkers = this.stackedList[Symbol.iterator]()
|
|
95
|
+
return {
|
|
96
|
+
next: () => {
|
|
97
|
+
const result = linkers.next()
|
|
98
|
+
return result.done
|
|
99
|
+
? {
|
|
100
|
+
done: true,
|
|
101
|
+
value: undefined
|
|
102
|
+
}
|
|
103
|
+
: {
|
|
104
|
+
done: false,
|
|
105
|
+
value: result.value.data
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Convert an array to a Stack by pushing each value in turn, so the last value is on the top.
|
|
113
|
+
* @param values The items to stack
|
|
114
|
+
* @param listClass The type of list used to store the items
|
|
115
|
+
* @param linkerClass The class used to hold each stacked item
|
|
116
|
+
*/
|
|
117
|
+
exports.Stack = Stack
|
|
118
|
+
Stack.fromArray = (values = [], listClass = _LinkedList.LinkedList, linkerClass = _Linker.Linker) => {
|
|
119
|
+
const stack = new Stack(null, listClass, linkerClass)
|
|
120
|
+
values.forEach(value => stack.push(value))
|
|
121
|
+
return stack
|
|
122
|
+
}
|
|
@@ -1,59 +1,52 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
* @param
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
*
|
|
45
|
-
* @param
|
|
46
|
-
* @
|
|
47
|
-
*/
|
|
48
|
-
static
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
* @returns {{head: Stackable, tail: Stackable}}
|
|
54
|
-
*/
|
|
55
|
-
static fromArray: (values?: Array<any>, classType?: any) => {
|
|
56
|
-
head: IsLinker;
|
|
57
|
-
tail: IsLinker;
|
|
58
|
-
};
|
|
59
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* stack.
|
|
3
|
+
*/
|
|
4
|
+
import { IsRunnable } from '../../recipes/Runnable';
|
|
5
|
+
import { IsLinker } from '../../recipes/IsLinker';
|
|
6
|
+
/**
|
|
7
|
+
* Stackable represents a runnable entry in stack.
|
|
8
|
+
* @extends Linker
|
|
9
|
+
*/
|
|
10
|
+
export declare class Stackable implements IsLinker, IsRunnable {
|
|
11
|
+
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
12
|
+
readonly classType: typeof Stackable;
|
|
13
|
+
/** The task (or data) this stackable holds. */
|
|
14
|
+
data: any;
|
|
15
|
+
/** The stackable below this one, or null when this is the bottom. */
|
|
16
|
+
next: Stackable | null;
|
|
17
|
+
/**
|
|
18
|
+
* Create a stackable item that can be used in a stack.
|
|
19
|
+
* @param stackData The settings for the new stackable.
|
|
20
|
+
* @param stackData.task The data to be stored in this stackable
|
|
21
|
+
* @param stackData.next The reference to the next stackable if any
|
|
22
|
+
* @param stackData.ready Indicate if the stackable is ready to run
|
|
23
|
+
*/
|
|
24
|
+
constructor({ task, next, ready }?: {
|
|
25
|
+
task?: any;
|
|
26
|
+
next?: Stackable | null;
|
|
27
|
+
ready?: boolean;
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Retrieve the data which should be formed as a task.
|
|
31
|
+
*/
|
|
32
|
+
get task(): any;
|
|
33
|
+
/**
|
|
34
|
+
* Run the stacked task.
|
|
35
|
+
*/
|
|
36
|
+
run(): any;
|
|
37
|
+
/**
|
|
38
|
+
* Make a new Stackable from the data given if it is not already a valid Stackable.
|
|
39
|
+
* @param stackable Return a valid Stackable instance from given data, or even an already valid one.
|
|
40
|
+
* @param classType Provide the type of IsLinker to use.
|
|
41
|
+
*/
|
|
42
|
+
static make: (stackable: Stackable | any, classType?: any) => Stackable;
|
|
43
|
+
/**
|
|
44
|
+
* Convert an array into Stackable instances, return the head and tail Stackables.
|
|
45
|
+
* @param values Provide an array of data that will be converted to a chain of stackable linkers.
|
|
46
|
+
* @param classType Provide the type of IsLinker to use.
|
|
47
|
+
*/
|
|
48
|
+
static fromArray: (values?: Array<any>, classType?: any) => {
|
|
49
|
+
head: IsLinker;
|
|
50
|
+
tail: IsLinker;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -1,85 +1,81 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.Stackable = void 0
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Stackable represents a runnable entry in stack.
|
|
10
|
-
* @extends Linker
|
|
11
|
-
*/
|
|
12
|
-
class Stackable {
|
|
13
|
-
/**
|
|
14
|
-
* Create a stackable item that can be used in a stack.
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
19
|
-
*/
|
|
20
|
-
constructor ({
|
|
21
|
-
task = null,
|
|
22
|
-
next = null,
|
|
23
|
-
ready = false
|
|
24
|
-
} = {}) {
|
|
25
|
-
/** The task (or data) this stackable holds. */
|
|
26
|
-
this.data = null
|
|
27
|
-
/** The stackable below this one, or null when this is the bottom. */
|
|
28
|
-
this.next = null
|
|
29
|
-
this.classType = Stackable
|
|
30
|
-
this.data = task
|
|
31
|
-
this.next = next
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Retrieve the data which should be formed as a task.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
* @param {IsLinker} [classType=Stackable] Provide the type of IsLinker to use.
|
|
83
|
-
* @returns {{head: Stackable, tail: Stackable}}
|
|
84
|
-
*/
|
|
85
|
-
Stackable.fromArray = (values = [], classType = Stackable) => _Linker.Linker.fromArray(values, classType)
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.Stackable = void 0
|
|
7
|
+
const _Linker = require('../linked-list/Linker')
|
|
8
|
+
/**
|
|
9
|
+
* Stackable represents a runnable entry in stack.
|
|
10
|
+
* @extends Linker
|
|
11
|
+
*/
|
|
12
|
+
class Stackable {
|
|
13
|
+
/**
|
|
14
|
+
* Create a stackable item that can be used in a stack.
|
|
15
|
+
* @param stackData The settings for the new stackable.
|
|
16
|
+
* @param stackData.task The data to be stored in this stackable
|
|
17
|
+
* @param stackData.next The reference to the next stackable if any
|
|
18
|
+
* @param stackData.ready Indicate if the stackable is ready to run
|
|
19
|
+
*/
|
|
20
|
+
constructor ({
|
|
21
|
+
task = null,
|
|
22
|
+
next = null,
|
|
23
|
+
ready = false
|
|
24
|
+
} = {}) {
|
|
25
|
+
/** The task (or data) this stackable holds. */
|
|
26
|
+
this.data = null
|
|
27
|
+
/** The stackable below this one, or null when this is the bottom. */
|
|
28
|
+
this.next = null
|
|
29
|
+
this.classType = Stackable
|
|
30
|
+
this.data = task
|
|
31
|
+
this.next = next
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Retrieve the data which should be formed as a task.
|
|
36
|
+
*/
|
|
37
|
+
get task () {
|
|
38
|
+
if (typeof this.data === 'function') {
|
|
39
|
+
return this.data
|
|
40
|
+
}
|
|
41
|
+
return () => this.data
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Run the stacked task.
|
|
46
|
+
*/
|
|
47
|
+
run () {
|
|
48
|
+
return this.task()
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Make a new Stackable from the data given if it is not already a valid Stackable.
|
|
53
|
+
* @param stackable Return a valid Stackable instance from given data, or even an already valid one.
|
|
54
|
+
* @param classType Provide the type of IsLinker to use.
|
|
55
|
+
*/
|
|
56
|
+
exports.Stackable = Stackable
|
|
57
|
+
Stackable.make = (stackable, classType = Stackable) => {
|
|
58
|
+
if (stackable === null || typeof stackable !== 'object') {
|
|
59
|
+
// It is not an object (or it is null), so instantiate the Stackable with stackable as the data
|
|
60
|
+
return new classType({
|
|
61
|
+
task: stackable
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
if (stackable.classType) {
|
|
65
|
+
// Already valid Stackable, return as-is
|
|
66
|
+
return stackable
|
|
67
|
+
}
|
|
68
|
+
if (!('task' in stackable)) {
|
|
69
|
+
stackable = {
|
|
70
|
+
task: stackable
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Create the new node as the configured stackableClass
|
|
74
|
+
return new classType(stackable)
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Convert an array into Stackable instances, return the head and tail Stackables.
|
|
78
|
+
* @param values Provide an array of data that will be converted to a chain of stackable linkers.
|
|
79
|
+
* @param classType Provide the type of IsLinker to use.
|
|
80
|
+
*/
|
|
81
|
+
Stackable.fromArray = (values = [], classType = Stackable) => _Linker.Linker.fromArray(values, classType)
|