collect-your-stuff 1.2.6 → 1.2.8

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 (74) hide show
  1. package/README.md +2525 -2525
  2. package/browser/collect-your-stuff.js +22766 -22859
  3. package/browser/collect-your-stuff.min.js +1 -1
  4. package/dist/collections/arrayable/ArrayElement.d.ts +36 -36
  5. package/dist/collections/arrayable/ArrayElement.js +64 -70
  6. package/dist/collections/arrayable/ArrayElement.min.js +1 -1
  7. package/dist/collections/arrayable/Arrayable.d.ts +108 -108
  8. package/dist/collections/arrayable/Arrayable.js +188 -196
  9. package/dist/collections/arrayable/Arrayable.min.js +1 -1
  10. package/dist/collections/doubly-linked-list/DoubleLinker.d.ts +46 -46
  11. package/dist/collections/doubly-linked-list/DoubleLinker.js +69 -77
  12. package/dist/collections/doubly-linked-list/DoubleLinker.min.js +1 -1
  13. package/dist/collections/doubly-linked-list/DoublyLinkedList.d.ts +113 -113
  14. package/dist/collections/doubly-linked-list/DoublyLinkedList.js +274 -277
  15. package/dist/collections/doubly-linked-list/DoublyLinkedList.min.js +1 -1
  16. package/dist/collections/linked-list/LinkedList.d.ts +109 -109
  17. package/dist/collections/linked-list/LinkedList.js +233 -241
  18. package/dist/collections/linked-list/LinkedList.min.js +1 -1
  19. package/dist/collections/linked-list/Linker.d.ts +43 -43
  20. package/dist/collections/linked-list/Linker.js +80 -86
  21. package/dist/collections/linked-list/Linker.min.js +1 -1
  22. package/dist/collections/linked-tree-list/LinkedTreeList.d.ts +135 -135
  23. package/dist/collections/linked-tree-list/LinkedTreeList.js +252 -261
  24. package/dist/collections/linked-tree-list/LinkedTreeList.min.js +1 -1
  25. package/dist/collections/linked-tree-list/TreeLinker.d.ts +63 -63
  26. package/dist/collections/linked-tree-list/TreeLinker.js +79 -92
  27. package/dist/collections/linked-tree-list/TreeLinker.min.js +1 -1
  28. package/dist/collections/queue/Queue.d.ts +63 -63
  29. package/dist/collections/queue/Queue.js +130 -136
  30. package/dist/collections/queue/Queue.min.js +1 -1
  31. package/dist/collections/queue/Queueable.d.ts +77 -77
  32. package/dist/collections/queue/Queueable.js +141 -151
  33. package/dist/collections/queue/Queueable.min.js +1 -1
  34. package/dist/collections/stack/Stack.d.ts +63 -63
  35. package/dist/collections/stack/Stack.js +106 -112
  36. package/dist/collections/stack/Stack.min.js +1 -1
  37. package/dist/collections/stack/Stackable.d.ts +56 -56
  38. package/dist/collections/stack/Stackable.js +83 -91
  39. package/dist/collections/stack/Stackable.min.js +1 -1
  40. package/dist/main.d.ts +40 -40
  41. package/dist/main.js +50 -50
  42. package/dist/recipes/ArrayIterator.d.ts +10 -10
  43. package/dist/recipes/ArrayIterator.js +29 -30
  44. package/dist/recipes/ArrayIterator.min.js +1 -1
  45. package/dist/recipes/DoubleLinkerIterator.d.ts +9 -9
  46. package/dist/recipes/DoubleLinkerIterator.js +24 -24
  47. package/dist/recipes/IsArrayable.d.ts +105 -105
  48. package/dist/recipes/IsArrayable.js +5 -5
  49. package/dist/recipes/IsDoubleLinker.d.ts +14 -14
  50. package/dist/recipes/IsDoubleLinker.js +5 -5
  51. package/dist/recipes/IsElement.d.ts +14 -14
  52. package/dist/recipes/IsElement.js +5 -5
  53. package/dist/recipes/IsLinker.d.ts +10 -10
  54. package/dist/recipes/IsLinker.js +5 -5
  55. package/dist/recipes/IsTree.d.ts +11 -11
  56. package/dist/recipes/IsTree.js +5 -5
  57. package/dist/recipes/IsTreeNode.d.ts +29 -29
  58. package/dist/recipes/IsTreeNode.js +5 -5
  59. package/dist/recipes/LinkerIterator.d.ts +9 -9
  60. package/dist/recipes/LinkerIterator.js +24 -24
  61. package/dist/recipes/Runnable.d.ts +54 -54
  62. package/dist/recipes/Runnable.js +68 -69
  63. package/dist/recipes/Runnable.min.js +1 -1
  64. package/dist/recipes/TreeLinkerIterator.d.ts +9 -9
  65. package/dist/recipes/TreeLinkerIterator.js +25 -25
  66. package/dist/recipes/recipes.d.ts +15 -15
  67. package/dist/recipes/recipes.js +22 -22
  68. package/dist/services/parseTree.d.ts +9 -9
  69. package/dist/services/parseTree.js +24 -24
  70. package/dist/services/parseTreeNext.d.ts +14 -14
  71. package/dist/services/parseTreeNext.js +47 -47
  72. package/dist/services/services.d.ts +13 -13
  73. package/dist/services/services.js +22 -22
  74. package/package.json +2 -2
@@ -1,261 +1,252 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.LinkedTreeList = void 0
7
- require('core-js/modules/web.dom-collections.iterator.js')
8
- var _TreeLinker = require('./TreeLinker')
9
- var _TreeLinkerIterator = require('../../recipes/TreeLinkerIterator')
10
- var _DoublyLinkedList = require('../doubly-linked-list/DoublyLinkedList')
11
- /**
12
- * @file doubly linked tree list.
13
- * @author Joshua Heagle <joshuaheagle@gmail.com>
14
- * @version 1.1.0
15
- * @memberOf module:collect-your-stuff
16
- */
17
-
18
- /**
19
- * LinkedTreeList represents a collection stored with a root and spreading in branching (tree) formation.
20
- * @extends DoublyLinkedList
21
- */
22
- class LinkedTreeList {
23
- /**
24
- * Create the new LinkedTreeList instance, configure the list class.
25
- */
26
- constructor () {
27
- const linkerClass = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _TreeLinker.TreeLinker
28
- this.classType = LinkedTreeList
29
- this.innerList = null
30
- this.initialized = false
31
- this.linkerClass = linkerClass
32
- }
33
-
34
- /**
35
- * Initialize the inner list, should only run once.
36
- * @param {TreeLinker} initialList Give the list of tree-linkers to start in this linked-tree-list.
37
- * @return {LinkedTreeList}
38
- */
39
- initialize (initialList) {
40
- if (this.initialized) {
41
- console.warn('Attempt to initialize LinkedTreeList which is not empty.')
42
- return this
43
- }
44
- this.initialized = true
45
- this.innerList = initialList
46
- return this
47
- }
48
-
49
- /**
50
- * Retrieve a copy of the innerList used.
51
- * @returns {TreeLinker}
52
- */
53
- get list () {
54
- return this.innerList
55
- }
56
-
57
- /**
58
- * Retrieve the first TreeLinker in the list.
59
- * @returns {TreeLinker}
60
- */
61
- get first () {
62
- return this.reset()
63
- }
64
-
65
- /**
66
- * Retrieve the last TreeLinker in the list.
67
- * @returns {TreeLinker}
68
- */
69
- get last () {
70
- let tail = this.innerList
71
- if (tail === null) {
72
- return null
73
- }
74
- let next = tail.next
75
- while (next !== null) {
76
- tail = next
77
- next = tail.next
78
- }
79
- return tail
80
- }
81
-
82
- /**
83
- * Return the length of the list.
84
- * @returns {number}
85
- */
86
- get length () {
87
- let current = this.first
88
- let length = 0
89
- while (current !== null) {
90
- ++length
91
- current = current.next
92
- }
93
- return length
94
- }
95
-
96
- /**
97
- * Get the parent of this tree list.
98
- * @return {TreeLinker}
99
- */
100
- get parent () {
101
- const first = this.first
102
- if (first === null) {
103
- return null
104
- }
105
- return this.first.parent
106
- }
107
-
108
- /**
109
- * Set the parent of this tree list
110
- * @param {TreeLinker} parent The new node to use as the parent for this group of children
111
- */
112
- set parent (parent) {
113
- let current = this.first
114
- while (current !== null) {
115
- current.parent = parent
116
- current = current.next
117
- }
118
- if (parent) {
119
- parent.children = this
120
- }
121
- }
122
-
123
- /**
124
- * Return the root parent of the entire tree.
125
- * @return {TreeLinker}
126
- */
127
- get rootParent () {
128
- let current = this.first
129
- if (!current) {
130
- return null
131
- }
132
- let parent = this.first.parent
133
- while (parent !== null) {
134
- current = parent
135
- parent = current.parent
136
- }
137
- return current
138
- }
139
-
140
- /**
141
- * Set the children on a parent item.
142
- * @param {TreeLinker} item The TreeLinker node that will be the parent of the children
143
- * @param {LinkedTreeList} children The LinkedTreeList which has the child nodes to use
144
- */
145
- setChildren (item) {
146
- const children = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null
147
- if (Array.from(this).indexOf(item) < 0) {
148
- console.error('item is not a child of this')
149
- }
150
- children.parent = item
151
- }
152
-
153
- /**
154
- * Insert a new node (or data) after a node.
155
- * @param {TreeLinker|*} node The existing node as reference
156
- * @param {TreeLinker|*} newNode The new node to go after the existing node
157
- * @returns {LinkedTreeList}
158
- */
159
- insertAfter (node, newNode) {
160
- return _DoublyLinkedList.DoublyLinkedList.prototype.insertAfter.call(this, node, newNode)
161
- }
162
-
163
- /**
164
- * Insert a new node (or data) before a node.
165
- * @param {TreeLinker|*} node The existing node as reference
166
- * @param {TreeLinker|*} newNode The new node to go before the existing node
167
- * @returns {LinkedTreeList}
168
- */
169
- insertBefore (node, newNode) {
170
- return _DoublyLinkedList.DoublyLinkedList.prototype.insertBefore.call(this, node, newNode)
171
- }
172
-
173
- /**
174
- * Add a node (or data) after the given (or last) node in the list.
175
- * @param {TreeLinker|*} node The new node to add to the end of the list
176
- * @param {TreeLinker} after The existing last node
177
- * @returns {TreeLinker}
178
- */
179
- append (node) {
180
- const after = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.last
181
- return _DoublyLinkedList.DoublyLinkedList.prototype.append.call(this, node, after)
182
- }
183
-
184
- /**
185
- * Add a node (or data) before the given (or first) node in the list.
186
- * @param {TreeLinker|*} node The new node to add to the start of the list
187
- * @param {TreeLinker} before The existing first node
188
- * @returns {TreeLinker}
189
- */
190
- prepend (node) {
191
- const before = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.first
192
- return _DoublyLinkedList.DoublyLinkedList.prototype.prepend.call(this, node, before)
193
- }
194
-
195
- /**
196
- * Remove a linker from this linked list.
197
- * @param {TreeLinker} node The node we wish to remove (and it will be returned after removal)
198
- * @return {TreeLinker}
199
- */
200
- remove (node) {
201
- return _DoublyLinkedList.DoublyLinkedList.prototype.remove.call(this, node)
202
- }
203
-
204
- /**
205
- * Refresh all references and return head reference.
206
- * @return {TreeLinker}
207
- */
208
- reset () {
209
- return _DoublyLinkedList.DoublyLinkedList.prototype.reset.call(this)
210
- }
211
-
212
- /**
213
- * Retrieve a TreeLinker item from this list by numeric index, otherwise return null.
214
- * @param {number} index The integer number for retrieving a node by position.
215
- * @returns {TreeLinker|null}
216
- */
217
- item (index) {
218
- return _DoublyLinkedList.DoublyLinkedList.prototype.item.call(this, index)
219
- }
220
-
221
- /**
222
- * Be able to run forEach on this LinkedTreeList to iterate over the TreeLinker Items.
223
- * @param {forEachCallback} callback The function to call for-each tree node
224
- * @param {LinkedTreeList} thisArg Optional, 'this' reference
225
- */
226
- forEach (callback) {
227
- const thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this
228
- let index = 0
229
- let current = thisArg.first
230
- while (current !== null) {
231
- callback(current, index, thisArg)
232
- current = current.next
233
- ++index
234
- }
235
- return thisArg
236
- }
237
-
238
- /**
239
- * Be able to iterate over this class.
240
- * @returns {Iterator}
241
- */
242
- [Symbol.iterator] () {
243
- const root = this.rootParent
244
- return new _TreeLinkerIterator.TreeLinkerIterator(root)
245
- }
246
- }
247
- /**
248
- * Convert an array into a LinkedTreeList instance, return the new instance.
249
- * @param {Array} [values=[]] An array of values which will be converted to nodes in this tree-list
250
- * @param {TreeLinker} [linkerClass=TreeLinker] The class to use for each node
251
- * @param {IsArrayable<TreeLinker>} [classType=LinkedTreeList] Provide the type of IsArrayable to use.
252
- * @returns {LinkedTreeList}
253
- */
254
- exports.LinkedTreeList = LinkedTreeList
255
- LinkedTreeList.fromArray = function () {
256
- const values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []
257
- const linkerClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _TreeLinker.TreeLinker
258
- const classType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : LinkedTreeList
259
- const list = new classType(linkerClass)
260
- return list.initialize(linkerClass.fromArray(values).head)
261
- }
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.LinkedTreeList = void 0
7
+ var _TreeLinker = require('./TreeLinker')
8
+ var _TreeLinkerIterator = require('../../recipes/TreeLinkerIterator')
9
+ var _DoublyLinkedList = require('../doubly-linked-list/DoublyLinkedList')
10
+ /**
11
+ * @file doubly linked tree list.
12
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
13
+ * @version 1.1.0
14
+ * @memberOf module:collect-your-stuff
15
+ */
16
+
17
+ /**
18
+ * LinkedTreeList represents a collection stored with a root and spreading in branching (tree) formation.
19
+ * @extends DoublyLinkedList
20
+ */
21
+ class LinkedTreeList {
22
+ /**
23
+ * Create the new LinkedTreeList instance, configure the list class.
24
+ */
25
+ constructor (linkerClass = _TreeLinker.TreeLinker) {
26
+ this.classType = LinkedTreeList
27
+ this.innerList = null
28
+ this.initialized = false
29
+ this.linkerClass = linkerClass
30
+ }
31
+
32
+ /**
33
+ * Initialize the inner list, should only run once.
34
+ * @param {TreeLinker} initialList Give the list of tree-linkers to start in this linked-tree-list.
35
+ * @return {LinkedTreeList}
36
+ */
37
+ initialize (initialList) {
38
+ if (this.initialized) {
39
+ console.warn('Attempt to initialize LinkedTreeList which is not empty.')
40
+ return this
41
+ }
42
+ this.initialized = true
43
+ this.innerList = initialList
44
+ return this
45
+ }
46
+
47
+ /**
48
+ * Retrieve a copy of the innerList used.
49
+ * @returns {TreeLinker}
50
+ */
51
+ get list () {
52
+ return this.innerList
53
+ }
54
+
55
+ /**
56
+ * Retrieve the first TreeLinker in the list.
57
+ * @returns {TreeLinker}
58
+ */
59
+ get first () {
60
+ return this.reset()
61
+ }
62
+
63
+ /**
64
+ * Retrieve the last TreeLinker in the list.
65
+ * @returns {TreeLinker}
66
+ */
67
+ get last () {
68
+ let tail = this.innerList
69
+ if (tail === null) {
70
+ return null
71
+ }
72
+ let next = tail.next
73
+ while (next !== null) {
74
+ tail = next
75
+ next = tail.next
76
+ }
77
+ return tail
78
+ }
79
+
80
+ /**
81
+ * Return the length of the list.
82
+ * @returns {number}
83
+ */
84
+ get length () {
85
+ let current = this.first
86
+ let length = 0
87
+ while (current !== null) {
88
+ ++length
89
+ current = current.next
90
+ }
91
+ return length
92
+ }
93
+
94
+ /**
95
+ * Get the parent of this tree list.
96
+ * @return {TreeLinker}
97
+ */
98
+ get parent () {
99
+ const first = this.first
100
+ if (first === null) {
101
+ return null
102
+ }
103
+ return this.first.parent
104
+ }
105
+
106
+ /**
107
+ * Set the parent of this tree list
108
+ * @param {TreeLinker} parent The new node to use as the parent for this group of children
109
+ */
110
+ set parent (parent) {
111
+ let current = this.first
112
+ while (current !== null) {
113
+ current.parent = parent
114
+ current = current.next
115
+ }
116
+ if (parent) {
117
+ parent.children = this
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Return the root parent of the entire tree.
123
+ * @return {TreeLinker}
124
+ */
125
+ get rootParent () {
126
+ let current = this.first
127
+ if (!current) {
128
+ return null
129
+ }
130
+ let parent = this.first.parent
131
+ while (parent !== null) {
132
+ current = parent
133
+ parent = current.parent
134
+ }
135
+ return current
136
+ }
137
+
138
+ /**
139
+ * Set the children on a parent item.
140
+ * @param {TreeLinker} item The TreeLinker node that will be the parent of the children
141
+ * @param {LinkedTreeList} children The LinkedTreeList which has the child nodes to use
142
+ */
143
+ setChildren (item, children = null) {
144
+ if (Array.from(this).indexOf(item) < 0) {
145
+ console.error('item is not a child of this')
146
+ }
147
+ children.parent = item
148
+ }
149
+
150
+ /**
151
+ * Insert a new node (or data) after a node.
152
+ * @param {TreeLinker|*} node The existing node as reference
153
+ * @param {TreeLinker|*} newNode The new node to go after the existing node
154
+ * @returns {LinkedTreeList}
155
+ */
156
+ insertAfter (node, newNode) {
157
+ return _DoublyLinkedList.DoublyLinkedList.prototype.insertAfter.call(this, node, newNode)
158
+ }
159
+
160
+ /**
161
+ * Insert a new node (or data) before a node.
162
+ * @param {TreeLinker|*} node The existing node as reference
163
+ * @param {TreeLinker|*} newNode The new node to go before the existing node
164
+ * @returns {LinkedTreeList}
165
+ */
166
+ insertBefore (node, newNode) {
167
+ return _DoublyLinkedList.DoublyLinkedList.prototype.insertBefore.call(this, node, newNode)
168
+ }
169
+
170
+ /**
171
+ * Add a node (or data) after the given (or last) node in the list.
172
+ * @param {TreeLinker|*} node The new node to add to the end of the list
173
+ * @param {TreeLinker} after The existing last node
174
+ * @returns {TreeLinker}
175
+ */
176
+ append (node, after = this.last) {
177
+ return _DoublyLinkedList.DoublyLinkedList.prototype.append.call(this, node, after)
178
+ }
179
+
180
+ /**
181
+ * Add a node (or data) before the given (or first) node in the list.
182
+ * @param {TreeLinker|*} node The new node to add to the start of the list
183
+ * @param {TreeLinker} before The existing first node
184
+ * @returns {TreeLinker}
185
+ */
186
+ prepend (node, before = this.first) {
187
+ return _DoublyLinkedList.DoublyLinkedList.prototype.prepend.call(this, node, before)
188
+ }
189
+
190
+ /**
191
+ * Remove a linker from this linked list.
192
+ * @param {TreeLinker} node The node we wish to remove (and it will be returned after removal)
193
+ * @return {TreeLinker}
194
+ */
195
+ remove (node) {
196
+ return _DoublyLinkedList.DoublyLinkedList.prototype.remove.call(this, node)
197
+ }
198
+
199
+ /**
200
+ * Refresh all references and return head reference.
201
+ * @return {TreeLinker}
202
+ */
203
+ reset () {
204
+ return _DoublyLinkedList.DoublyLinkedList.prototype.reset.call(this)
205
+ }
206
+
207
+ /**
208
+ * Retrieve a TreeLinker item from this list by numeric index, otherwise return null.
209
+ * @param {number} index The integer number for retrieving a node by position.
210
+ * @returns {TreeLinker|null}
211
+ */
212
+ item (index) {
213
+ return _DoublyLinkedList.DoublyLinkedList.prototype.item.call(this, index)
214
+ }
215
+
216
+ /**
217
+ * Be able to run forEach on this LinkedTreeList to iterate over the TreeLinker Items.
218
+ * @param {forEachCallback} callback The function to call for-each tree node
219
+ * @param {LinkedTreeList} thisArg Optional, 'this' reference
220
+ */
221
+ forEach (callback, thisArg = this) {
222
+ let index = 0
223
+ let current = thisArg.first
224
+ while (current !== null) {
225
+ callback(current, index, thisArg)
226
+ current = current.next
227
+ ++index
228
+ }
229
+ return thisArg
230
+ }
231
+
232
+ /**
233
+ * Be able to iterate over this class.
234
+ * @returns {Iterator}
235
+ */
236
+ [Symbol.iterator] () {
237
+ const root = this.rootParent
238
+ return new _TreeLinkerIterator.TreeLinkerIterator(root)
239
+ }
240
+ }
241
+ /**
242
+ * Convert an array into a LinkedTreeList instance, return the new instance.
243
+ * @param {Array} [values=[]] An array of values which will be converted to nodes in this tree-list
244
+ * @param {TreeLinker} [linkerClass=TreeLinker] The class to use for each node
245
+ * @param {IsArrayable<TreeLinker>} [classType=LinkedTreeList] Provide the type of IsArrayable to use.
246
+ * @returns {LinkedTreeList}
247
+ */
248
+ exports.LinkedTreeList = LinkedTreeList
249
+ LinkedTreeList.fromArray = (values = [], linkerClass = _TreeLinker.TreeLinker, classType = LinkedTreeList) => {
250
+ const list = new classType(linkerClass)
251
+ return list.initialize(linkerClass.fromArray(values).head)
252
+ }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LinkedTreeList=void 0,require("core-js/modules/web.dom-collections.iterator.js");var _TreeLinker=require("./TreeLinker"),_TreeLinkerIterator=require("../../recipes/TreeLinkerIterator"),_DoublyLinkedList=require("../doubly-linked-list/DoublyLinkedList");class LinkedTreeList{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_TreeLinker.TreeLinker;this.classType=LinkedTreeList,this.innerList=null,this.initialized=!1,this.linkerClass=e}initialize(e){return this.initialized?(console.warn("Attempt to initialize LinkedTreeList which is not empty."),this):(this.initialized=!0,this.innerList=e,this)}get list(){return this.innerList}get first(){return this.reset()}get last(){let e=this.innerList;if(null===e)return null;let t=e.next;for(;null!==t;)e=t,t=e.next;return e}get length(){let e=this.first,t=0;for(;null!==e;)++t,e=e.next;return t}get parent(){return null===this.first?null:this.first.parent}set parent(e){let t=this.first;for(;null!==t;)t.parent=e,t=t.next;e&&(e.children=this)}get rootParent(){let e=this.first;if(!e)return null;let t=this.first.parent;for(;null!==t;)e=t,t=e.parent;return e}setChildren(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;Array.from(this).indexOf(e)<0&&console.error("item is not a child of this"),t.parent=e}insertAfter(e,t){return _DoublyLinkedList.DoublyLinkedList.prototype.insertAfter.call(this,e,t)}insertBefore(e,t){return _DoublyLinkedList.DoublyLinkedList.prototype.insertBefore.call(this,e,t)}append(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.last;return _DoublyLinkedList.DoublyLinkedList.prototype.append.call(this,e,t)}prepend(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.first;return _DoublyLinkedList.DoublyLinkedList.prototype.prepend.call(this,e,t)}remove(e){return _DoublyLinkedList.DoublyLinkedList.prototype.remove.call(this,e)}reset(){return _DoublyLinkedList.DoublyLinkedList.prototype.reset.call(this)}item(e){return _DoublyLinkedList.DoublyLinkedList.prototype.item.call(this,e)}forEach(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,i=0,r=t.first;for(;null!==r;)e(r,i,t),r=r.next,++i;return t}[Symbol.iterator](){let e=this.rootParent;return new _TreeLinkerIterator.TreeLinkerIterator(e)}}exports.LinkedTreeList=LinkedTreeList,LinkedTreeList.fromArray=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_TreeLinker.TreeLinker;return new(arguments.length>2&&void 0!==arguments[2]?arguments[2]:LinkedTreeList)(t).initialize(t.fromArray(e).head)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LinkedTreeList=void 0;var _TreeLinker=require("./TreeLinker"),_TreeLinkerIterator=require("../../recipes/TreeLinkerIterator"),_DoublyLinkedList=require("../doubly-linked-list/DoublyLinkedList");class LinkedTreeList{constructor(e=_TreeLinker.TreeLinker){this.classType=LinkedTreeList,this.innerList=null,this.initialized=!1,this.linkerClass=e}initialize(e){return this.initialized?(console.warn("Attempt to initialize LinkedTreeList which is not empty."),this):(this.initialized=!0,this.innerList=e,this)}get list(){return this.innerList}get first(){return this.reset()}get last(){let e=this.innerList;if(null===e)return null;let t=e.next;for(;null!==t;)e=t,t=e.next;return e}get length(){let e=this.first,t=0;for(;null!==e;)++t,e=e.next;return t}get parent(){return null===this.first?null:this.first.parent}set parent(e){let t=this.first;for(;null!==t;)t.parent=e,t=t.next;e&&(e.children=this)}get rootParent(){let e=this.first;if(!e)return null;let t=this.first.parent;for(;null!==t;)e=t,t=e.parent;return e}setChildren(e,t=null){Array.from(this).indexOf(e)<0&&console.error("item is not a child of this"),t.parent=e}insertAfter(e,t){return _DoublyLinkedList.DoublyLinkedList.prototype.insertAfter.call(this,e,t)}insertBefore(e,t){return _DoublyLinkedList.DoublyLinkedList.prototype.insertBefore.call(this,e,t)}append(e,t=this.last){return _DoublyLinkedList.DoublyLinkedList.prototype.append.call(this,e,t)}prepend(e,t=this.first){return _DoublyLinkedList.DoublyLinkedList.prototype.prepend.call(this,e,t)}remove(e){return _DoublyLinkedList.DoublyLinkedList.prototype.remove.call(this,e)}reset(){return _DoublyLinkedList.DoublyLinkedList.prototype.reset.call(this)}item(e){return _DoublyLinkedList.DoublyLinkedList.prototype.item.call(this,e)}forEach(e,t=this){let i=0,r=t.first;for(;null!==r;)e(r,i,t),r=r.next,++i;return t}[Symbol.iterator](){let e=this.rootParent;return new _TreeLinkerIterator.TreeLinkerIterator(e)}}exports.LinkedTreeList=LinkedTreeList,LinkedTreeList.fromArray=(e=[],t=_TreeLinker.TreeLinker,i=LinkedTreeList)=>new i(t).initialize(t.fromArray(e).head);