collect-your-stuff 1.1.0 → 1.1.2

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