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,46 +1,41 @@
|
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
static fromArray: (values?: Array<any>, classType?: any) => {
|
|
43
|
-
head: IsLinker;
|
|
44
|
-
tail: IsLinker;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* linked list item.
|
|
3
|
+
*/
|
|
4
|
+
import { IsLinker } from '../../recipes/IsLinker';
|
|
5
|
+
/**
|
|
6
|
+
* Linker represents a node in a LinkedList.
|
|
7
|
+
* @extends ArrayElement
|
|
8
|
+
*/
|
|
9
|
+
export declare class Linker implements IsLinker {
|
|
10
|
+
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
11
|
+
readonly classType: typeof Linker;
|
|
12
|
+
/** The data stored in this linker. */
|
|
13
|
+
data: any;
|
|
14
|
+
/** The linker after this one, or null when this is the last. */
|
|
15
|
+
next: Linker | null;
|
|
16
|
+
/**
|
|
17
|
+
* Create the new Linker instance, provide the data and optionally give the next Linker.
|
|
18
|
+
* @param nodeData The settings for the new linker.
|
|
19
|
+
* @param nodeData.data The data to be stored in this linker
|
|
20
|
+
* @param nodeData.next The reference to the next linker if any
|
|
21
|
+
*/
|
|
22
|
+
constructor({ data, next }?: {
|
|
23
|
+
data?: any;
|
|
24
|
+
next?: Linker | null;
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Make a new Linker from the data given if it is not already a valid Linker.
|
|
28
|
+
* @param linker Return a valid Linker instance from given data, or even an already valid one.
|
|
29
|
+
* @param classType Provide the type of IsLinker to use.
|
|
30
|
+
*/
|
|
31
|
+
static make: (linker: Linker | any, classType?: any) => IsLinker | any;
|
|
32
|
+
/**
|
|
33
|
+
* Convert an array into Linker instances, return the head and tail Linkers.
|
|
34
|
+
* @param values Provide an array of data that will be converted to a chain of linkers.
|
|
35
|
+
* @param classType Provide the type of IsLinker to use.
|
|
36
|
+
*/
|
|
37
|
+
static fromArray: (values?: Array<any>, classType?: any) => {
|
|
38
|
+
head: IsLinker;
|
|
39
|
+
tail: IsLinker;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -1,84 +1,82 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.Linker = void 0
|
|
7
|
-
require('core-js/modules/esnext.iterator.constructor.js')
|
|
8
|
-
require('core-js/modules/esnext.iterator.reduce.js')
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Linker represents a node in a LinkedList.
|
|
12
|
-
* @extends ArrayElement
|
|
13
|
-
*/
|
|
14
|
-
class Linker {
|
|
15
|
-
/**
|
|
16
|
-
* Create the new Linker instance, provide the data and optionally give the next Linker.
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
20
|
-
*/
|
|
21
|
-
constructor ({
|
|
22
|
-
data = null,
|
|
23
|
-
next = null
|
|
24
|
-
} = {}) {
|
|
25
|
-
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
26
|
-
this.classType = Linker
|
|
27
|
-
/** The data stored in this linker. */
|
|
28
|
-
this.data = null
|
|
29
|
-
/** The linker after this one, or null when this is the last. */
|
|
30
|
-
this.next = null
|
|
31
|
-
this.data = data
|
|
32
|
-
this.next = next
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Make a new Linker from the data given if it is not already a valid Linker.
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
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
|
-
* @param
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
references
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
tail: null
|
|
84
|
-
})
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.Linker = void 0
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js')
|
|
8
|
+
require('core-js/modules/esnext.iterator.reduce.js')
|
|
9
|
+
const _ArrayElement = require('../arrayable/ArrayElement')
|
|
10
|
+
/**
|
|
11
|
+
* Linker represents a node in a LinkedList.
|
|
12
|
+
* @extends ArrayElement
|
|
13
|
+
*/
|
|
14
|
+
class Linker {
|
|
15
|
+
/**
|
|
16
|
+
* Create the new Linker instance, provide the data and optionally give the next Linker.
|
|
17
|
+
* @param nodeData The settings for the new linker.
|
|
18
|
+
* @param nodeData.data The data to be stored in this linker
|
|
19
|
+
* @param nodeData.next The reference to the next linker if any
|
|
20
|
+
*/
|
|
21
|
+
constructor ({
|
|
22
|
+
data = null,
|
|
23
|
+
next = null
|
|
24
|
+
} = {}) {
|
|
25
|
+
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
26
|
+
this.classType = Linker
|
|
27
|
+
/** The data stored in this linker. */
|
|
28
|
+
this.data = null
|
|
29
|
+
/** The linker after this one, or null when this is the last. */
|
|
30
|
+
this.next = null
|
|
31
|
+
this.data = data
|
|
32
|
+
this.next = next
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Make a new Linker from the data given if it is not already a valid Linker.
|
|
37
|
+
* @param linker Return a valid Linker instance from given data, or even an already valid one.
|
|
38
|
+
* @param classType Provide the type of IsLinker to use.
|
|
39
|
+
*/
|
|
40
|
+
exports.Linker = Linker
|
|
41
|
+
Linker.make = (linker, classType = Linker) => {
|
|
42
|
+
if (linker === null || typeof linker !== 'object') {
|
|
43
|
+
// It is not an object (or it is null), so instantiate the Linker with element as the data
|
|
44
|
+
return new classType({
|
|
45
|
+
data: linker
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
if (linker.classType) {
|
|
49
|
+
// Already valid Linker, return as-is
|
|
50
|
+
return linker
|
|
51
|
+
}
|
|
52
|
+
if (!('data' in linker)) {
|
|
53
|
+
// Not the settings for a linker (which would have data, even if it is falsy), so it is the data itself
|
|
54
|
+
linker = {
|
|
55
|
+
data: linker
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Create the new node as the configured #classType
|
|
59
|
+
return _ArrayElement.ArrayElement.make(linker, classType)
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Convert an array into Linker instances, return the head and tail Linkers.
|
|
63
|
+
* @param values Provide an array of data that will be converted to a chain of linkers.
|
|
64
|
+
* @param classType Provide the type of IsLinker to use.
|
|
65
|
+
*/
|
|
66
|
+
Linker.fromArray = (values = [], classType = Linker) => values.reduce((references, linker) => {
|
|
67
|
+
const newLinker = classType.make(linker, classType)
|
|
68
|
+
if (references.head === null) {
|
|
69
|
+
// Initialize the head and tail with the new node
|
|
70
|
+
return {
|
|
71
|
+
head: newLinker,
|
|
72
|
+
tail: newLinker
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Only update the tail once head has been set, tail is always the most recent node
|
|
76
|
+
references.tail.next = newLinker
|
|
77
|
+
references.tail = newLinker
|
|
78
|
+
return references
|
|
79
|
+
}, {
|
|
80
|
+
head: null,
|
|
81
|
+
tail: null
|
|
82
|
+
})
|
|
@@ -1,159 +1,140 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
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
|
-
* Retrieve the
|
|
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
|
-
* @param
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
*
|
|
83
|
-
* @
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
*
|
|
89
|
-
* @
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*
|
|
95
|
-
* @param
|
|
96
|
-
* @
|
|
97
|
-
*/
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
*
|
|
101
|
-
* @param
|
|
102
|
-
* @param
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
*
|
|
108
|
-
* @
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
*
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
*
|
|
123
|
-
* @
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
*
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
*
|
|
135
|
-
* @
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
* @param {LinkedTreeList} thisArg Optional, 'this' reference
|
|
142
|
-
* @return {LinkedTreeList} The list which was iterated.
|
|
143
|
-
*/
|
|
144
|
-
forEach(callback: forEachCallback, thisArg?: LinkedTreeList): LinkedTreeList;
|
|
145
|
-
/**
|
|
146
|
-
* Be able to iterate over this class: the linkers of this list and everything below them (left-first). It stays within
|
|
147
|
-
* this list (it does not start at, or climb up to, the parents), use the parseTree service to parse a whole tree.
|
|
148
|
-
* @returns {Iterator}
|
|
149
|
-
*/
|
|
150
|
-
[Symbol.iterator](): Iterator<TreeLinker>;
|
|
151
|
-
/**
|
|
152
|
-
* Convert an array into a LinkedTreeList instance, return the new instance.
|
|
153
|
-
* @param {Array} [values=[]] An array of values which will be converted to nodes in this tree-list
|
|
154
|
-
* @param {TreeLinker} [linkerClass=TreeLinker] The class to use for each node
|
|
155
|
-
* @param {IsArrayable<TreeLinker>} [classType=LinkedTreeList] Provide the type of IsArrayable to use.
|
|
156
|
-
* @returns {LinkedTreeList}
|
|
157
|
-
*/
|
|
158
|
-
static fromArray: (values?: Array<any>, linkerClass?: typeof TreeLinker, classType?: any) => IsTree | any;
|
|
159
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* doubly linked tree list.
|
|
3
|
+
*/
|
|
4
|
+
import { TreeLinker } from './TreeLinker';
|
|
5
|
+
import { forEachCallback } from '../../recipes/IsArrayable';
|
|
6
|
+
import { IsTree } from '../../recipes/IsTree';
|
|
7
|
+
import { IsTreeNode } from '../../recipes/IsTreeNode';
|
|
8
|
+
/**
|
|
9
|
+
* LinkedTreeList represents a collection stored with a root and spreading in branching (tree) formation.
|
|
10
|
+
* @extends DoublyLinkedList
|
|
11
|
+
*/
|
|
12
|
+
export declare class LinkedTreeList implements IsTree, Iterable<TreeLinker> {
|
|
13
|
+
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
14
|
+
readonly classType: typeof LinkedTreeList;
|
|
15
|
+
/** A linker of the list (null when the list is empty); the head is found by walking back from it. */
|
|
16
|
+
innerList: IsTreeNode | any;
|
|
17
|
+
/** Whether the inner list has been initialized (it can only be initialized once). */
|
|
18
|
+
initialized: boolean;
|
|
19
|
+
/** The class used to wrap the data given to this list as tree linkers. */
|
|
20
|
+
linkerClass: typeof TreeLinker;
|
|
21
|
+
/** The last linker, remembered so that adding to the end does not need to walk the whole list (null when not known yet). */
|
|
22
|
+
private tailCache;
|
|
23
|
+
/** The number of linkers, kept up to date by the list's own methods so that the length does not need to walk the whole list (null when not known yet). */
|
|
24
|
+
private countCache;
|
|
25
|
+
/** The node these linkers are the children of, remembered so that it is known even while the list is empty (undefined until it is known). */
|
|
26
|
+
private ownerNode;
|
|
27
|
+
/**
|
|
28
|
+
* Create the new LinkedTreeList instance, configure the list class.
|
|
29
|
+
* @param linkerClass The class used to wrap given data as tree linkers.
|
|
30
|
+
*/
|
|
31
|
+
constructor(linkerClass?: typeof TreeLinker);
|
|
32
|
+
/**
|
|
33
|
+
* Initialize the inner list, should only run once.
|
|
34
|
+
* @param initialList Give the list of tree-linkers to start in this linked-tree-list.
|
|
35
|
+
*/
|
|
36
|
+
initialize(initialList: TreeLinker): LinkedTreeList;
|
|
37
|
+
/**
|
|
38
|
+
* Retrieve the innerList used (the list itself, not a copy).
|
|
39
|
+
*/
|
|
40
|
+
get list(): TreeLinker;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieve the first TreeLinker in the list.
|
|
43
|
+
*/
|
|
44
|
+
get first(): TreeLinker;
|
|
45
|
+
/**
|
|
46
|
+
* Retrieve the last TreeLinker in the list. The end is remembered, so this does not walk the list.
|
|
47
|
+
*/
|
|
48
|
+
get last(): TreeLinker;
|
|
49
|
+
/**
|
|
50
|
+
* Return the length of the list. It is kept up to date by the list's own methods, so this does not walk the list
|
|
51
|
+
* (call reset() after linkers were changed directly).
|
|
52
|
+
*/
|
|
53
|
+
get length(): number;
|
|
54
|
+
/**
|
|
55
|
+
* Get the parent of this tree list: the node these linkers are the children of (remembered even while the list is
|
|
56
|
+
* empty), or null for the linkers at the top of a tree.
|
|
57
|
+
*/
|
|
58
|
+
get parent(): TreeLinker | null;
|
|
59
|
+
/**
|
|
60
|
+
* Set the parent of this tree list: every linker in it gets the node as its parent, and the node gets this list as its
|
|
61
|
+
* children. Linkers added to the list later get this parent too.
|
|
62
|
+
* @param parent The new node to use as the parent for this group of children
|
|
63
|
+
*/
|
|
64
|
+
set parent(parent: TreeLinker | null);
|
|
65
|
+
/**
|
|
66
|
+
* Return the root parent of the entire tree.
|
|
67
|
+
*/
|
|
68
|
+
get rootParent(): TreeLinker;
|
|
69
|
+
/**
|
|
70
|
+
* Set the children on a parent item.
|
|
71
|
+
* @param item The TreeLinker node (one of the linkers of this list) that will be the parent of the children
|
|
72
|
+
* @param children The LinkedTreeList which has the child nodes to use, or null to remove the children of the item
|
|
73
|
+
* @throws {Error} When the item is not one of the linkers of this list
|
|
74
|
+
*/
|
|
75
|
+
setChildren(item: TreeLinker, children?: LinkedTreeList | null): void;
|
|
76
|
+
/**
|
|
77
|
+
* Make a linker of the given node (or data) and make this list's parent its parent.
|
|
78
|
+
* @param newNode The node (or data) which is being added to this list
|
|
79
|
+
*/
|
|
80
|
+
private adopt;
|
|
81
|
+
/**
|
|
82
|
+
* Insert a new node (or data) after a node. The new node gets the parent of this list.
|
|
83
|
+
* @param node The existing node as reference, or null to insert at the start of the list
|
|
84
|
+
* @param newNode The new node to go after the existing node
|
|
85
|
+
*/
|
|
86
|
+
insertAfter(node: TreeLinker | null, newNode: TreeLinker | any): LinkedTreeList;
|
|
87
|
+
/**
|
|
88
|
+
* Insert a new node (or data) before a node. The new node gets the parent of this list.
|
|
89
|
+
* @param node The existing node as reference, or null to insert at the end of the list
|
|
90
|
+
* @param newNode The new node to go before the existing node
|
|
91
|
+
*/
|
|
92
|
+
insertBefore(node: TreeLinker | null, newNode: TreeLinker | any): LinkedTreeList;
|
|
93
|
+
/**
|
|
94
|
+
* Add a node (or data) after the given (or last) node in the list.
|
|
95
|
+
* @param node The new node to add to the end of the list
|
|
96
|
+
* @param after The existing last node
|
|
97
|
+
*/
|
|
98
|
+
append(node: TreeLinker | any, after?: TreeLinker): LinkedTreeList;
|
|
99
|
+
/**
|
|
100
|
+
* Add a node (or data) before the given (or first) node in the list.
|
|
101
|
+
* @param node The new node to add to the start of the list
|
|
102
|
+
* @param before The existing first node
|
|
103
|
+
*/
|
|
104
|
+
prepend(node: TreeLinker | any, before?: TreeLinker): LinkedTreeList;
|
|
105
|
+
/**
|
|
106
|
+
* Remove a linker from this linked list. The removed node no longer has a parent.
|
|
107
|
+
* @param node The node we wish to remove (and it will be returned after removal)
|
|
108
|
+
* @returns The removed node, or null when there was nothing to remove
|
|
109
|
+
*/
|
|
110
|
+
remove(node: TreeLinker): TreeLinker | null;
|
|
111
|
+
/**
|
|
112
|
+
* Refresh all references (the head, the end and the length) by walking the list once, and return the head. The
|
|
113
|
+
* list's own methods keep these up to date, so this is only needed after linkers were changed directly.
|
|
114
|
+
*/
|
|
115
|
+
reset(): TreeLinker;
|
|
116
|
+
/**
|
|
117
|
+
* Retrieve a TreeLinker item from this list by numeric index, otherwise return null.
|
|
118
|
+
* @param index The integer number for retrieving a node by position.
|
|
119
|
+
*/
|
|
120
|
+
item(index: number): TreeLinker;
|
|
121
|
+
/**
|
|
122
|
+
* Be able to run forEach on this LinkedTreeList to iterate over the TreeLinker Items.
|
|
123
|
+
* @param callback The function to call for-each tree node
|
|
124
|
+
* @param thisArg Optional, 'this' reference
|
|
125
|
+
* @returns The list which was iterated.
|
|
126
|
+
*/
|
|
127
|
+
forEach(callback: forEachCallback, thisArg?: LinkedTreeList): LinkedTreeList;
|
|
128
|
+
/**
|
|
129
|
+
* Be able to iterate over this class: the linkers of this list and everything below them (left-first). It stays within
|
|
130
|
+
* this list (it does not start at, or climb up to, the parents), use the parseTree service to parse a whole tree.
|
|
131
|
+
*/
|
|
132
|
+
[Symbol.iterator](): Iterator<TreeLinker>;
|
|
133
|
+
/**
|
|
134
|
+
* Convert an array into a LinkedTreeList instance, return the new instance.
|
|
135
|
+
* @param values An array of values which will be converted to nodes in this tree-list
|
|
136
|
+
* @param linkerClass The class to use for each node
|
|
137
|
+
* @param classType Provide the type of IsArrayable to use.
|
|
138
|
+
*/
|
|
139
|
+
static fromArray: (values?: Array<any>, linkerClass?: typeof TreeLinker, classType?: any) => IsTree | any;
|
|
140
|
+
}
|