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.
Files changed (75) hide show
  1. package/README.md +32 -3241
  2. package/browser/collect-your-stuff.js +1585 -1193
  3. package/browser/collect-your-stuff.min.js +1 -1
  4. package/dist/collections/arrayable/ArrayElement.d.ts +33 -38
  5. package/dist/collections/arrayable/ArrayElement.js +64 -66
  6. package/dist/collections/arrayable/Arrayable.d.ts +107 -122
  7. package/dist/collections/arrayable/Arrayable.js +208 -223
  8. package/dist/collections/doubly-linked-list/DoubleLinker.d.ts +45 -50
  9. package/dist/collections/doubly-linked-list/DoubleLinker.js +71 -73
  10. package/dist/collections/doubly-linked-list/DoublyLinkedList.d.ts +108 -125
  11. package/dist/collections/doubly-linked-list/DoublyLinkedList.js +310 -327
  12. package/dist/collections/linked-list/LinkedList.d.ts +110 -126
  13. package/dist/collections/linked-list/LinkedList.js +283 -296
  14. package/dist/collections/linked-list/Linker.d.ts +41 -46
  15. package/dist/collections/linked-list/Linker.js +82 -84
  16. package/dist/collections/linked-tree-list/LinkedTreeList.d.ts +140 -159
  17. package/dist/collections/linked-tree-list/LinkedTreeList.js +274 -294
  18. package/dist/collections/linked-tree-list/TreeLinker.d.ts +65 -71
  19. package/dist/collections/linked-tree-list/TreeLinker.js +91 -94
  20. package/dist/collections/queue/Queue.d.ts +55 -59
  21. package/dist/collections/queue/Queue.js +114 -119
  22. package/dist/collections/queue/Queueable.d.ts +74 -83
  23. package/dist/collections/queue/Queueable.js +142 -146
  24. package/dist/collections/queue/TaskQueue.d.ts +59 -68
  25. package/dist/collections/queue/TaskQueue.js +128 -137
  26. package/dist/collections/scoped-collection/ScopedCollection.d.ts +42 -0
  27. package/dist/collections/scoped-collection/ScopedCollection.js +81 -0
  28. package/dist/collections/scoped-collection/ScopedCollection.min.js +1 -0
  29. package/dist/collections/stack/Stack.d.ts +60 -64
  30. package/dist/collections/stack/Stack.js +122 -127
  31. package/dist/collections/stack/Stackable.d.ts +52 -59
  32. package/dist/collections/stack/Stackable.js +81 -85
  33. package/dist/collections/stack/TaskStack.d.ts +56 -65
  34. package/dist/collections/stack/TaskStack.js +98 -107
  35. package/dist/main.d.ts +4 -5
  36. package/dist/main.js +9 -5
  37. package/dist/main.min.js +1 -1
  38. package/dist/recipes/ArrayIterator.d.ts +20 -20
  39. package/dist/recipes/ArrayIterator.js +39 -39
  40. package/dist/recipes/DoubleLinkerIterator.d.ts +18 -18
  41. package/dist/recipes/DoubleLinkerIterator.js +33 -33
  42. package/dist/recipes/IsArrayable.d.ts +85 -105
  43. package/dist/recipes/IsArrayable.js +5 -5
  44. package/dist/recipes/IsDoubleLinker.d.ts +14 -14
  45. package/dist/recipes/IsDoubleLinker.js +5 -5
  46. package/dist/recipes/IsElement.d.ts +14 -14
  47. package/dist/recipes/IsElement.js +5 -5
  48. package/dist/recipes/IsLinker.d.ts +10 -10
  49. package/dist/recipes/IsLinker.js +5 -5
  50. package/dist/recipes/IsQueue.d.ts +32 -37
  51. package/dist/recipes/IsQueue.js +5 -5
  52. package/dist/recipes/IsScopedCollection.d.ts +27 -0
  53. package/dist/recipes/IsScopedCollection.js +5 -0
  54. package/dist/recipes/IsScopedCollection.min.js +1 -0
  55. package/dist/recipes/IsStack.d.ts +31 -36
  56. package/dist/recipes/IsStack.js +5 -5
  57. package/dist/recipes/IsTree.d.ts +11 -11
  58. package/dist/recipes/IsTree.js +5 -5
  59. package/dist/recipes/IsTreeNode.d.ts +29 -29
  60. package/dist/recipes/IsTreeNode.js +5 -5
  61. package/dist/recipes/LinkerIterator.d.ts +18 -18
  62. package/dist/recipes/LinkerIterator.js +33 -33
  63. package/dist/recipes/Runnable.d.ts +42 -55
  64. package/dist/recipes/Runnable.js +63 -69
  65. package/dist/recipes/TreeLinkerIterator.d.ts +20 -20
  66. package/dist/recipes/TreeLinkerIterator.js +36 -36
  67. package/dist/recipes/recipes.d.ts +12 -15
  68. package/dist/recipes/recipes.js +19 -22
  69. package/dist/services/parseTree.d.ts +8 -9
  70. package/dist/services/parseTree.js +23 -24
  71. package/dist/services/parseTreeNext.d.ts +16 -17
  72. package/dist/services/parseTreeNext.js +41 -42
  73. package/dist/services/services.d.ts +10 -13
  74. package/dist/services/services.js +19 -22
  75. package/package.json +4 -4
@@ -1,137 +1,128 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.TaskQueue = void 0
7
- var _Queueable = require('./Queueable')
8
- var _LinkedList = require('../linked-list/LinkedList')
9
- /**
10
- * @file task 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 tasks (Queueables): dequeue() takes the next task from the front and RUNS it, giving each
18
- * task in turn a chance to run (a task which is not ready, or which has not finished, is placed at the back again).
19
- * This is a task scheduler, for a plain first-in-first-out collection of items use Queue.
20
- */
21
- class TaskQueue {
22
- /**
23
- * Instantiate the queue with the given queue list.
24
- * @param {Iterable|LinkedList} queuedList Give the list of queueables to start in this queue.
25
- * @param {IsArrayable} [listClass=LinkedList] The type of list to create when no queued list is given.
26
- * @param {Queueable} [queueableClass=Queueable] The class used to wrap queued items.
27
- */
28
- constructor (queuedList = null, listClass = _LinkedList.LinkedList, queueableClass = _Queueable.Queueable) {
29
- this.listClass = listClass
30
- this.queueableClass = queueableClass
31
- if (queuedList === null) {
32
- queuedList = new listClass(queueableClass)
33
- }
34
- this.queuedList = queuedList
35
- }
36
-
37
- /**
38
- * Take a queued task from the front of the queue and run it if ready. A task which is not ready yet is kept in the
39
- * queue (never dropped), a task which is still running is reported as blocking and left to finish on its own, and
40
- * completed tasks are discarded.
41
- * @return {completeResponse|*}
42
- */
43
- dequeue () {
44
- let next = this.remove()
45
- // Tasks which already completed are discarded when they reach the front of the queue
46
- while (next && next.complete) {
47
- next = this.remove()
48
- }
49
- if (!next) {
50
- return {
51
- success: 'No more queueable tasks in the queue',
52
- error: false,
53
- context: this.queuedList
54
- }
55
- }
56
- if (next.running) {
57
- // The unfinished task reports back through its own complete callback, so it is not kept in the queue
58
- return {
59
- success: false,
60
- error: 'The queue has been blocked by an unfinished task.',
61
- context: next
62
- }
63
- }
64
- if (!next.isReady) {
65
- // Keep the task (at the back, so the next dequeue can try the other tasks) rather than losing it
66
- this.enqueue(next)
67
- // 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
68
- // Also, we want the loop handled externally
69
- return {
70
- success: false,
71
- error: 'Unable to find ready task.',
72
- context: next
73
- }
74
- }
75
- if (!this.empty()) {
76
- // Place back in queue to be checked once again next time, only if the queue will not be empty
77
- this.enqueue(next)
78
- }
79
- return next.run.call(next)
80
- }
81
-
82
- /**
83
- * Return true if the queue is empty (there are no tasks in the queue list)
84
- * @return {boolean}
85
- */
86
- empty () {
87
- return this.size() <= 0
88
- }
89
-
90
- /**
91
- * Add a queued task to the end of the queue
92
- * @param {Queueable} queueable Add a new queueable to the end of the queue
93
- */
94
- enqueue (queueable) {
95
- this.queuedList.append(queueable)
96
- }
97
-
98
- /**
99
- * Take a look at the next queued task
100
- * @return {Queueable}
101
- */
102
- peek () {
103
- return this.queuedList.first
104
- }
105
-
106
- /**
107
- * Remove the next queued item and return it.
108
- * @return {Queueable|null}
109
- */
110
- remove () {
111
- if (this.empty()) {
112
- return null
113
- }
114
- return this.queuedList.remove(this.queuedList.first)
115
- }
116
-
117
- /**
118
- * Get the length of the current queue.
119
- * @return {number}
120
- */
121
- size () {
122
- return this.queuedList.length
123
- }
124
- }
125
- /**
126
- * Convert an array to a TaskQueue.
127
- * @param {Array} values An array of values which will be converted to queueables in this queue
128
- * @param {Queueable} queueableClass The class to use for each queueable
129
- * @param {TaskQueue|Iterable} listClass The class to use to manage the queueables
130
- * @returns {TaskQueue}
131
- */
132
- exports.TaskQueue = TaskQueue
133
- TaskQueue.fromArray = (values = [], queueableClass = _Queueable.Queueable, listClass = _LinkedList.LinkedList) => {
134
- const list = new listClass(queueableClass)
135
- list.initialize(queueableClass.fromArray(values, queueableClass).head)
136
- return new TaskQueue(list, listClass, queueableClass)
137
- }
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.TaskQueue = void 0
7
+ const _Queueable = require('./Queueable')
8
+ const _LinkedList = require('../linked-list/LinkedList')
9
+ /**
10
+ * task queue
11
+ */
12
+
13
+ /**
14
+ * Maintain a series of queued tasks (Queueables): dequeue() takes the next task from the front and RUNS it, giving each
15
+ * task in turn a chance to run (a task which is not ready, or which has not finished, is placed at the back again).
16
+ * This is a task scheduler, for a plain first-in-first-out collection of items use Queue.
17
+ */
18
+ class TaskQueue {
19
+ /**
20
+ * Instantiate the queue with the given queue list.
21
+ * @param queuedList Give the list of queueables to start in this queue.
22
+ * @param listClass The type of list to create when no queued list is given.
23
+ * @param queueableClass The class used to wrap queued items.
24
+ */
25
+ constructor (queuedList = null, listClass = _LinkedList.LinkedList, queueableClass = _Queueable.Queueable) {
26
+ this.listClass = listClass
27
+ this.queueableClass = queueableClass
28
+ if (queuedList === null) {
29
+ queuedList = new listClass(queueableClass)
30
+ }
31
+ this.queuedList = queuedList
32
+ }
33
+
34
+ /**
35
+ * Take a queued task from the front of the queue and run it if ready. A task which is not ready yet is kept in the
36
+ * queue (never dropped), a task which is still running is reported as blocking and left to finish on its own, and
37
+ * completed tasks are discarded.
38
+ */
39
+ dequeue () {
40
+ let next = this.remove()
41
+ // Tasks which already completed are discarded when they reach the front of the queue
42
+ while (next && next.complete) {
43
+ next = this.remove()
44
+ }
45
+ if (!next) {
46
+ return {
47
+ success: 'No more queueable tasks in the queue',
48
+ error: false,
49
+ context: this.queuedList
50
+ }
51
+ }
52
+ if (next.running) {
53
+ // The unfinished task reports back through its own complete callback, so it is not kept in the queue
54
+ return {
55
+ success: false,
56
+ error: 'The queue has been blocked by an unfinished task.',
57
+ context: next
58
+ }
59
+ }
60
+ if (!next.isReady) {
61
+ // Keep the task (at the back, so the next dequeue can try the other tasks) rather than losing it
62
+ this.enqueue(next)
63
+ // 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
64
+ // Also, we want the loop handled externally
65
+ return {
66
+ success: false,
67
+ error: 'Unable to find ready task.',
68
+ context: next
69
+ }
70
+ }
71
+ if (!this.empty()) {
72
+ // Place back in queue to be checked once again next time, only if the queue will not be empty
73
+ this.enqueue(next)
74
+ }
75
+ return next.run.call(next)
76
+ }
77
+
78
+ /**
79
+ * Return true if the queue is empty (there are no tasks in the queue list)
80
+ */
81
+ empty () {
82
+ return this.size() <= 0
83
+ }
84
+
85
+ /**
86
+ * Add a queued task to the end of the queue
87
+ * @param queueable Add a new queueable to the end of the queue
88
+ */
89
+ enqueue (queueable) {
90
+ this.queuedList.append(queueable)
91
+ }
92
+
93
+ /**
94
+ * Take a look at the next queued task
95
+ */
96
+ peek () {
97
+ return this.queuedList.first
98
+ }
99
+
100
+ /**
101
+ * Remove the next queued item and return it.
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
+ */
113
+ size () {
114
+ return this.queuedList.length
115
+ }
116
+ }
117
+ /**
118
+ * Convert an array to a TaskQueue.
119
+ * @param values An array of values which will be converted to queueables in this queue
120
+ * @param queueableClass The class to use for each queueable
121
+ * @param listClass The class to use to manage the queueables
122
+ */
123
+ exports.TaskQueue = TaskQueue
124
+ TaskQueue.fromArray = (values = [], queueableClass = _Queueable.Queueable, listClass = _LinkedList.LinkedList) => {
125
+ const list = new listClass(queueableClass)
126
+ list.initialize(queueableClass.fromArray(values, queueableClass).head)
127
+ return new TaskQueue(list, listClass, queueableClass)
128
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * scoped collection
3
+ */
4
+ import { IsScopedCollection } from '../../recipes/IsScopedCollection';
5
+ /**
6
+ * A keyed collection, partitioned by an arbitrary scope object: values are stored and looked up by key, with a
7
+ * separate key space per scope. Scopes are held by a WeakMap, so a scope that nothing else references any more
8
+ * takes its whole key space with it - useful anywhere state needs to be tracked per instance of something (a
9
+ * tree's root, a session) without that something needing to hold the state itself.
10
+ */
11
+ export declare class ScopedCollection<Scope extends object = object, Key = any, Value = any> implements IsScopedCollection<Scope, Key, Value> {
12
+ private readonly scopes;
13
+ constructor();
14
+ /**
15
+ * Remove a key from a scope's key space.
16
+ * @param scope The scope to remove the key from
17
+ * @param key The key to remove
18
+ * @returns Whether a value was actually removed
19
+ */
20
+ delete(scope: Scope, key: Key): boolean;
21
+ /**
22
+ * Look up a value by key within a scope.
23
+ * @param scope The scope to look within
24
+ * @param key The key to look up
25
+ * @returns The value, or undefined when the scope or key is not present
26
+ */
27
+ get(scope: Scope, key: Key): Value | undefined;
28
+ /**
29
+ * Check whether a key exists within a scope.
30
+ * @param scope The scope to look within
31
+ * @param key The key to check
32
+ */
33
+ has(scope: Scope, key: Key): boolean;
34
+ /**
35
+ * Store a value under a key within a scope.
36
+ * @param scope The scope to store the key within
37
+ * @param key The key to store the value under
38
+ * @param value The value to store
39
+ * @returns This collection, so that setting can be chained
40
+ */
41
+ set(scope: Scope, key: Key, value: Value): this;
42
+ }
@@ -0,0 +1,81 @@
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.ScopedCollection = void 0
7
+ require('core-js/modules/esnext.map.delete-all.js')
8
+ require('core-js/modules/esnext.map.every.js')
9
+ require('core-js/modules/esnext.map.filter.js')
10
+ require('core-js/modules/esnext.map.find.js')
11
+ require('core-js/modules/esnext.map.find-key.js')
12
+ require('core-js/modules/esnext.map.includes.js')
13
+ require('core-js/modules/esnext.map.key-of.js')
14
+ require('core-js/modules/esnext.map.map-keys.js')
15
+ require('core-js/modules/esnext.map.map-values.js')
16
+ require('core-js/modules/esnext.map.merge.js')
17
+ require('core-js/modules/esnext.map.reduce.js')
18
+ require('core-js/modules/esnext.map.some.js')
19
+ require('core-js/modules/esnext.map.update.js')
20
+ require('core-js/modules/esnext.weak-map.delete-all.js')
21
+ /**
22
+ * A keyed collection, partitioned by an arbitrary scope object: values are stored and looked up by key, with a
23
+ * separate key space per scope. Scopes are held by a WeakMap, so a scope that nothing else references any more
24
+ * takes its whole key space with it - useful anywhere state needs to be tracked per instance of something (a
25
+ * tree's root, a session) without that something needing to hold the state itself.
26
+ */
27
+ class ScopedCollection {
28
+ constructor () {
29
+ this.scopes = new WeakMap()
30
+ }
31
+
32
+ /**
33
+ * Remove a key from a scope's key space.
34
+ * @param scope The scope to remove the key from
35
+ * @param key The key to remove
36
+ * @returns Whether a value was actually removed
37
+ */
38
+ delete (scope, key) {
39
+ const keyedValues = this.scopes.get(scope)
40
+ return typeof keyedValues === 'undefined' ? false : keyedValues.delete(key)
41
+ }
42
+
43
+ /**
44
+ * Look up a value by key within a scope.
45
+ * @param scope The scope to look within
46
+ * @param key The key to look up
47
+ * @returns The value, or undefined when the scope or key is not present
48
+ */
49
+ get (scope, key) {
50
+ let _a
51
+ return (_a = this.scopes.get(scope)) === null || _a === void 0 ? void 0 : _a.get(key)
52
+ }
53
+
54
+ /**
55
+ * Check whether a key exists within a scope.
56
+ * @param scope The scope to look within
57
+ * @param key The key to check
58
+ */
59
+ has (scope, key) {
60
+ let _a, _b
61
+ return (_b = (_a = this.scopes.get(scope)) === null || _a === void 0 ? void 0 : _a.has(key)) !== null && _b !== void 0 ? _b : false
62
+ }
63
+
64
+ /**
65
+ * Store a value under a key within a scope.
66
+ * @param scope The scope to store the key within
67
+ * @param key The key to store the value under
68
+ * @param value The value to store
69
+ * @returns This collection, so that setting can be chained
70
+ */
71
+ set (scope, key, value) {
72
+ let keyedValues = this.scopes.get(scope)
73
+ if (typeof keyedValues === 'undefined') {
74
+ keyedValues = new Map()
75
+ this.scopes.set(scope, keyedValues)
76
+ }
77
+ keyedValues.set(key, value)
78
+ return this
79
+ }
80
+ }
81
+ exports.ScopedCollection = ScopedCollection
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ScopedCollection=void 0,require("core-js/modules/esnext.map.delete-all.js"),require("core-js/modules/esnext.map.every.js"),require("core-js/modules/esnext.map.filter.js"),require("core-js/modules/esnext.map.find.js"),require("core-js/modules/esnext.map.find-key.js"),require("core-js/modules/esnext.map.includes.js"),require("core-js/modules/esnext.map.key-of.js"),require("core-js/modules/esnext.map.map-keys.js"),require("core-js/modules/esnext.map.map-values.js"),require("core-js/modules/esnext.map.merge.js"),require("core-js/modules/esnext.map.reduce.js"),require("core-js/modules/esnext.map.some.js"),require("core-js/modules/esnext.map.update.js"),require("core-js/modules/esnext.weak-map.delete-all.js");class ScopedCollection{constructor(){this.scopes=new WeakMap}delete(e,s){const o=this.scopes.get(e);return void 0!==o&&o.delete(s)}get(e,s){var o;return null===(o=this.scopes.get(e))||void 0===o?void 0:o.get(s)}has(e,s){var o,r;return null!==(r=null===(o=this.scopes.get(e))||void 0===o?void 0:o.has(s))&&void 0!==r&&r}set(e,s,o){let r=this.scopes.get(e);return void 0===r&&(r=new Map,this.scopes.set(e,r)),r.set(s,o),this}}exports.ScopedCollection=ScopedCollection;
@@ -1,64 +1,60 @@
1
- import { Linker } from '../linked-list/Linker';
2
- import { IsArrayable } from '../../recipes/IsArrayable';
3
- import { IsStack } from '../../recipes/IsStack';
4
- /**
5
- * A last-in-first-out collection: items are added to the top with push and taken from the top with pop. Any value can
6
- * be stacked (it is stored as it is, whether it is a function, an object or null), and adding and taking are constant
7
- * time. To stack tasks which are run as they are taken use TaskStack.
8
- */
9
- export declare class Stack<T = any> implements IsStack<T>, Iterable<T> {
10
- /** The list which stores the stacked items, the first is the top of the stack. */
11
- stackedList: IsArrayable<any>;
12
- private readonly linkerClass;
13
- /**
14
- * Instantiate the stack, optionally with a list of items to start from.
15
- * @param {IsArrayable|null} [stackedList=null] The list of linkers to start in this stack (the first is the top)
16
- * @param {IsArrayable} [listClass=LinkedList] The type of list to create when no stacked list is given
17
- * @param {Linker} [linkerClass=Linker] The class used to hold each stacked item
18
- */
19
- constructor(stackedList?: IsArrayable<any> | null, listClass?: any, linkerClass?: typeof Linker);
20
- /**
21
- * Check whether the stack has no items.
22
- * @return {boolean}
23
- */
24
- empty(): boolean;
25
- /**
26
- * Look at the item on the top of the stack, without removing it.
27
- * @return {*|null} The item, or null when the stack is empty
28
- */
29
- peek(): T | null;
30
- /**
31
- * Take the item from the top of the stack.
32
- * @return {*|null} The item, or null when the stack is empty
33
- */
34
- pop(): T | null;
35
- /**
36
- * Add an item to the top of the stack.
37
- * @param {*} data The item to add
38
- * @return {Stack} This stack, so that adding can be chained
39
- */
40
- push(data: T): this;
41
- /**
42
- * Count the items in the stack.
43
- * @return {number}
44
- */
45
- size(): number;
46
- /**
47
- * The item on the top of the stack (the same as peek).
48
- * @return {*|null} The item, or null when the stack is empty
49
- */
50
- top(): T | null;
51
- /**
52
- * Iterate over the items from the top of the stack to the bottom, without removing them.
53
- * @return {Iterator}
54
- */
55
- [Symbol.iterator](): Iterator<T>;
56
- /**
57
- * Convert an array to a Stack by pushing each value in turn, so the last value is on the top.
58
- * @param {Array} [values=[]] The items to stack
59
- * @param {IsArrayable} [listClass=LinkedList] The type of list used to store the items
60
- * @param {Linker} [linkerClass=Linker] The class used to hold each stacked item
61
- * @returns {Stack}
62
- */
63
- static fromArray: <T_1 = any>(values?: Array<T_1>, listClass?: any, linkerClass?: typeof Linker) => Stack<T_1>;
64
- }
1
+ import { Linker } from '../linked-list/Linker';
2
+ import { IsArrayable } from '../../recipes/IsArrayable';
3
+ import { IsStack } from '../../recipes/IsStack';
4
+ /**
5
+ * A last-in-first-out collection: items are added to the top with push and taken from the top with pop. Any value can
6
+ * be stacked (it is stored as it is, whether it is a function, an object or null), and adding and taking are constant
7
+ * time. To stack tasks which are run as they are taken use TaskStack.
8
+ */
9
+ export declare class Stack<T = any> implements IsStack<T>, Iterable<T> {
10
+ /** The list which stores the stacked items, the first is the top of the stack. */
11
+ stackedList: IsArrayable<any>;
12
+ private readonly linkerClass;
13
+ /**
14
+ * Instantiate the stack, optionally with a list of items to start from.
15
+ * @param stackedList The list of linkers to start in this stack (the first is the top)
16
+ * @param listClass The type of list to create when no stacked list is given
17
+ * @param linkerClass The class used to hold each stacked item
18
+ */
19
+ constructor(stackedList?: IsArrayable<any> | null, listClass?: any, linkerClass?: typeof Linker);
20
+ /**
21
+ * Check whether the stack has no items.
22
+ */
23
+ empty(): boolean;
24
+ /**
25
+ * Look at the item on the top of the stack, without removing it.
26
+ * @returns The item, or null when the stack is empty
27
+ */
28
+ peek(): T | null;
29
+ /**
30
+ * Take the item from the top of the stack.
31
+ * @returns The item, or null when the stack is empty
32
+ */
33
+ pop(): T | null;
34
+ /**
35
+ * Add an item to the top of the stack.
36
+ * @param data The item to add
37
+ * @returns This stack, so that adding can be chained
38
+ */
39
+ push(data: T): this;
40
+ /**
41
+ * Count the items in the stack.
42
+ */
43
+ size(): number;
44
+ /**
45
+ * The item on the top of the stack (the same as peek).
46
+ * @returns The item, or null when the stack is empty
47
+ */
48
+ top(): T | null;
49
+ /**
50
+ * Iterate over the items from the top of the stack to the bottom, without removing them.
51
+ */
52
+ [Symbol.iterator](): Iterator<T>;
53
+ /**
54
+ * Convert an array to a Stack by pushing each value in turn, so the last value is on the top.
55
+ * @param values The items to stack
56
+ * @param listClass The type of list used to store the items
57
+ * @param linkerClass The class used to hold each stacked item
58
+ */
59
+ static fromArray: <T_1 = any>(values?: Array<T_1>, listClass?: any, linkerClass?: typeof Linker) => Stack<T_1>;
60
+ }