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