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,119 +1,114 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.Queue = 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
|
-
Queue.fromArray = (values = [], listClass = _LinkedList.LinkedList, linkerClass = _Linker.Linker) => {
|
|
116
|
-
const queue = new Queue(null, listClass, linkerClass)
|
|
117
|
-
values.forEach(value => queue.enqueue(value))
|
|
118
|
-
return queue
|
|
119
|
-
}
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.Queue = 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
|
+
* queue
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A first-in-first-out collection: items are added to the back with enqueue and taken from the front with dequeue.
|
|
17
|
+
* Any value can be queued (it is stored as it is, whether it is a function, an object or null), and adding and taking
|
|
18
|
+
* are constant time. To queue tasks which are run as they are taken use TaskQueue.
|
|
19
|
+
*/
|
|
20
|
+
class Queue {
|
|
21
|
+
/**
|
|
22
|
+
* Instantiate the queue, optionally with a list of items to start from.
|
|
23
|
+
* @param queuedList The list of linkers to start in this queue (the first is the front)
|
|
24
|
+
* @param listClass The type of list to create when no queued list is given
|
|
25
|
+
* @param linkerClass The class used to hold each queued item
|
|
26
|
+
*/
|
|
27
|
+
constructor (queuedList = null, listClass = _LinkedList.LinkedList, linkerClass = _Linker.Linker) {
|
|
28
|
+
this.linkerClass = linkerClass
|
|
29
|
+
this.queuedList = queuedList === null ? new listClass(linkerClass) : queuedList
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Take the item from the front of the queue.
|
|
34
|
+
* @returns The item, or null when the queue is empty
|
|
35
|
+
*/
|
|
36
|
+
dequeue () {
|
|
37
|
+
const front = this.queuedList.first
|
|
38
|
+
if (front === null || typeof front === 'undefined') {
|
|
39
|
+
return null
|
|
40
|
+
}
|
|
41
|
+
this.queuedList.remove(front)
|
|
42
|
+
return front.data
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Check whether the queue has no items.
|
|
47
|
+
*/
|
|
48
|
+
empty () {
|
|
49
|
+
return this.size() <= 0
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Add an item to the back of the queue.
|
|
54
|
+
* @param data The item to add
|
|
55
|
+
* @returns This queue, so that adding can be chained
|
|
56
|
+
*/
|
|
57
|
+
enqueue (data) {
|
|
58
|
+
// The item is wrapped here rather than left to the list, since the list treats objects that look like a linker's
|
|
59
|
+
// settings (they have a data property) as such, and a queue must give back exactly what it was given
|
|
60
|
+
this.queuedList.append(new this.linkerClass({
|
|
61
|
+
data
|
|
62
|
+
}))
|
|
63
|
+
return this
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Look at the item at the front of the queue, without removing it.
|
|
68
|
+
* @returns The item, or null when the queue is empty
|
|
69
|
+
*/
|
|
70
|
+
peek () {
|
|
71
|
+
const front = this.queuedList.first
|
|
72
|
+
return front === null || typeof front === 'undefined' ? null : front.data
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Count the items in the queue.
|
|
77
|
+
*/
|
|
78
|
+
size () {
|
|
79
|
+
return this.queuedList.length
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Iterate over the items from the front of the queue to the back, without removing them.
|
|
84
|
+
*/
|
|
85
|
+
[Symbol.iterator] () {
|
|
86
|
+
const linkers = this.queuedList[Symbol.iterator]()
|
|
87
|
+
return {
|
|
88
|
+
next: () => {
|
|
89
|
+
const result = linkers.next()
|
|
90
|
+
return result.done
|
|
91
|
+
? {
|
|
92
|
+
done: true,
|
|
93
|
+
value: undefined
|
|
94
|
+
}
|
|
95
|
+
: {
|
|
96
|
+
done: false,
|
|
97
|
+
value: result.value.data
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Convert an array to a Queue, the first value is at the front.
|
|
105
|
+
* @param values The items to queue
|
|
106
|
+
* @param listClass The type of list used to store the items
|
|
107
|
+
* @param linkerClass The class used to hold each queued item
|
|
108
|
+
*/
|
|
109
|
+
exports.Queue = Queue
|
|
110
|
+
Queue.fromArray = (values = [], listClass = _LinkedList.LinkedList, linkerClass = _Linker.Linker) => {
|
|
111
|
+
const queue = new Queue(null, listClass, linkerClass)
|
|
112
|
+
values.forEach(value => queue.enqueue(value))
|
|
113
|
+
return queue
|
|
114
|
+
}
|
|
@@ -1,83 +1,74 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
* @param
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*
|
|
41
|
-
*/
|
|
42
|
-
get
|
|
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
|
-
* @param
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* @param {Array} values Provide an array of data that will be converted to a chain of queueable linkers.
|
|
76
|
-
* @param {IsLinker} [classType=Queueable] Provide the type of IsLinker to use.
|
|
77
|
-
* @returns {{head: Queueable, tail: Queueable}}
|
|
78
|
-
*/
|
|
79
|
-
static fromArray: (values?: Array<any>, classType?: any) => {
|
|
80
|
-
head: IsLinker;
|
|
81
|
-
tail: IsLinker;
|
|
82
|
-
};
|
|
83
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* queueable item.
|
|
3
|
+
*/
|
|
4
|
+
import { completeResponse, IsRunnable } from '../../recipes/Runnable';
|
|
5
|
+
import { IsLinker } from '../../recipes/IsLinker';
|
|
6
|
+
/**
|
|
7
|
+
* Queueable represents a runnable entry in a queue.
|
|
8
|
+
* @extends Linker
|
|
9
|
+
*/
|
|
10
|
+
export declare class Queueable 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 Queueable;
|
|
13
|
+
/** The task (or data) this queueable holds. */
|
|
14
|
+
data: any;
|
|
15
|
+
/** The queueable after this one, or null when this is the last. */
|
|
16
|
+
next: Queueable | null;
|
|
17
|
+
/** Whether this queueable has been run to completion. */
|
|
18
|
+
complete: boolean;
|
|
19
|
+
/** Whether this queueable may run, or a function which answers that when asked. */
|
|
20
|
+
ready: Function | boolean;
|
|
21
|
+
/** Whether this queueable is running right now. */
|
|
22
|
+
running: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Create a queueable item that can be used in a queue.
|
|
25
|
+
* @param queueableData The settings for the new queueable.
|
|
26
|
+
* @param queueableData.task The data to be stored in this queueable
|
|
27
|
+
* @param queueableData.next The reference to the next queueable if any
|
|
28
|
+
* @param queueableData.ready Indicate if the queueable is ready to run
|
|
29
|
+
*/
|
|
30
|
+
constructor({ task, next, ready }?: {
|
|
31
|
+
task?: any;
|
|
32
|
+
next?: Queueable | null;
|
|
33
|
+
ready?: boolean | Function;
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Check ready state.
|
|
37
|
+
*/
|
|
38
|
+
get isReady(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieve the data which should be formed as a task.
|
|
41
|
+
*/
|
|
42
|
+
get task(): any;
|
|
43
|
+
/**
|
|
44
|
+
* Set this queueable as completed.
|
|
45
|
+
* @param completeResponse The result to report for the task.
|
|
46
|
+
* @param completeResponse.success Indicate when the task failed (use false) or give a success message
|
|
47
|
+
* @param completeResponse.error Indicate a task was error-free (use false) or give an error message
|
|
48
|
+
* @param completeResponse.context Provide additional data in the response
|
|
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
|
+
*/
|
|
58
|
+
run(): completeResponse;
|
|
59
|
+
/**
|
|
60
|
+
* Make a new Queueable from the data given if it is not already a valid Queueable.
|
|
61
|
+
* @param queueable Return a valid Queueable instance from given data, or even an already valid one.
|
|
62
|
+
* @param classType Provide the type of IsLinker to use.
|
|
63
|
+
*/
|
|
64
|
+
static make: (queueable: Queueable | any, classType?: any) => IsLinker;
|
|
65
|
+
/**
|
|
66
|
+
* Convert an array into Queueable instances, return the head and tail Queueables.
|
|
67
|
+
* @param values Provide an array of data that will be converted to a chain of queueable linkers.
|
|
68
|
+
* @param classType Provide the type of IsLinker to use.
|
|
69
|
+
*/
|
|
70
|
+
static fromArray: (values?: Array<any>, classType?: any) => {
|
|
71
|
+
head: IsLinker;
|
|
72
|
+
tail: IsLinker;
|
|
73
|
+
};
|
|
74
|
+
}
|