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,195 +1,196 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.default = void 0
7
- var _ArrayElement = _interopRequireDefault(require('./ArrayElement'))
8
- var _ArrayIterator = _interopRequireDefault(require('../../recipes/ArrayIterator'))
9
- function _interopRequireDefault (obj) { return obj && obj.__esModule ? obj : { default: obj } }
10
- /**
11
- * @file arrayable list.
12
- * @author Joshua Heagle <joshuaheagle@gmail.com>
13
- * @version 1.1.0
14
- * @memberOf module:collect-your-stuff
15
- */
16
-
17
- /**
18
- * Arrayable represents a collection stored as an array.
19
- */
20
- class Arrayable {
21
- /**
22
- * Create the new Arrayable instance, configure the Arrayable class.
23
- */
24
- constructor () {
25
- this.classType = Arrayable
26
- this.innerList = []
27
- this.initialized = false
28
- this.initialized = false
29
- }
30
-
31
- /**
32
- * Initialize the inner list, should only run once.
33
- * @param {Array<ArrayElement>} initialList Give the array of elements to start in this Arrayable.
34
- * @return {Arrayable}
35
- */
36
- initialize (initialList) {
37
- if (this.initialized) {
38
- console.warn('Attempt to initialize non-empty list.')
39
- return this
40
- }
41
- this.initialized = true
42
- this.innerList = initialList
43
- return this
44
- }
45
-
46
- /**
47
- * Retrieve a copy of the innerList used.
48
- * @returns {Array<ArrayElement>}
49
- */
50
- get list () {
51
- return this.innerList
52
- }
53
-
54
- /**
55
- * Retrieve the first Element from the Arrayable
56
- * @returns {ArrayElement}
57
- */
58
- get first () {
59
- return this.innerList[0]
60
- }
61
-
62
- /**
63
- * Retrieve the last Element from the Arrayable
64
- * @returns {ArrayElement}
65
- */
66
- get last () {
67
- return this.innerList[this.length - 1]
68
- }
69
-
70
- /**
71
- * Return the length of the list.
72
- * @returns {number}
73
- */
74
- get length () {
75
- return this.innerList.length
76
- }
77
-
78
- /**
79
- * Insert a new node (or data) after a node.
80
- * @param {ArrayElement|*} node The existing node as reference
81
- * @param {ArrayElement|*} newNode The new node to go after the existing node
82
- * @returns {Arrayable}
83
- */
84
- insertAfter (node, newNode) {
85
- const insertAt = this.innerList.indexOf(node)
86
- this.innerList.splice(insertAt + 1, 0, node.classType.make(newNode))
87
- return this
88
- }
89
-
90
- /**
91
- * Insert a new node (or data) before a node.
92
- * @param {ArrayElement|*} node The existing node as reference
93
- * @param {ArrayElement|*} newNode The new node to go before the existing node
94
- * @returns {Arrayable}
95
- */
96
- insertBefore (node, newNode) {
97
- const insertAt = this.innerList.indexOf(node)
98
- this.innerList.splice(insertAt, 0, node.classType.make(newNode))
99
- return this
100
- }
101
-
102
- /**
103
- * Add a node (or data) after the given (or last) node in the list.
104
- * @param {ArrayElement|*} node The new node to add to the end of the list
105
- * @param {ArrayElement} after The existing last node
106
- * @returns {Arrayable}
107
- */
108
- append (node) {
109
- const after = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.last
110
- return this.insertAfter(after, node)
111
- }
112
-
113
- /**
114
- * Add a node (or data) before the given (or first) node in the list.
115
- * @param {ArrayElement|*} node The new node to add to the start of the list
116
- * @param {ArrayElement} before The existing first node
117
- * @returns {Arrayable}
118
- */
119
- prepend (node) {
120
- const before = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.first
121
- return this.insertBefore(before, node)
122
- }
123
-
124
- /**
125
- * Remove an element from this arrayable.
126
- * @param {ArrayElement} node The node we wish to remove (and it will be returned after removal)
127
- * @return {ArrayElement}
128
- */
129
- remove (node) {
130
- const deleteAt = this.innerList.indexOf(node)
131
- this.innerList.splice(deleteAt, 1)
132
- return node
133
- }
134
-
135
- /**
136
- * Retrieve an ArrayElement item from this list by numeric index, otherwise return null.
137
- * @param {number} index The integer number for retrieving a node by position.
138
- * @return {ArrayElement|null}
139
- */
140
- item (index) {
141
- if (index >= this.length) {
142
- // index is beyond array limit
143
- return null
144
- }
145
- if (index >= 0) {
146
- // use the positive index at nth position from the beginning of the array
147
- return this.innerList[index]
148
- }
149
- const calculatedIndex = this.length + index
150
- if (calculatedIndex < 0) {
151
- // negative index is beyond array limit (minus direction)
152
- return null
153
- }
154
- // Return the item at nth position from the end of the array
155
- return this.innerList[calculatedIndex]
156
- }
157
-
158
- /**
159
- * Be able to run forEach on this Arrayable to iterate over the elements.
160
- * @param {forEachCallback} callback The function to call for-each element
161
- * @param {Arrayable} thisArg Optional, 'this' reference
162
- * @returns {Arrayable}
163
- */
164
- forEach (callback) {
165
- const thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this
166
- for (let i = 0; i < thisArg.length; ++i) {
167
- callback(thisArg.item(i), i, thisArg)
168
- }
169
- return thisArg
170
- }
171
-
172
- /**
173
- * Be able to iterate over this class.
174
- * @returns {Iterator}
175
- */
176
- [Symbol.iterator] () {
177
- const index = 0
178
- return new _ArrayIterator.default(this.innerList, index)
179
- }
180
- }
181
- /**
182
- * Convert an array to an Arrayable.
183
- * @param {Array} values An array of values which will be converted to elements in this arrayable
184
- * @param {IsElement} [elementClass=ArrayElement] The class to use for each element
185
- * @param {IsArrayable<ArrayElement>} [classType=Arrayable] Provide the type of IsArrayable to use.
186
- * @returns {Arrayable}
187
- */
188
- Arrayable.fromArray = function () {
189
- const values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []
190
- const elementClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _ArrayElement.default
191
- const classType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Arrayable
192
- const list = new classType()
193
- return list.initialize(elementClass.fromArray(values).head)
194
- }
195
- var _default = exports.default = Arrayable
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.default = void 0
7
+ var _ArrayElement = _interopRequireDefault(require('./ArrayElement'))
8
+ var _ArrayIterator = _interopRequireDefault(require('../../recipes/ArrayIterator'))
9
+ function _interopRequireDefault (obj) { return obj && obj.__esModule ? obj : { default: obj } }
10
+ /**
11
+ * @file arrayable list.
12
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
13
+ * @version 1.1.0
14
+ * @memberOf module:collect-your-stuff
15
+ */
16
+
17
+ /**
18
+ * Arrayable represents a collection stored as an array.
19
+ */
20
+ class Arrayable {
21
+ /**
22
+ * Create the new Arrayable instance, configure the Arrayable class.
23
+ */
24
+ constructor () {
25
+ const elementClass = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _ArrayElement.default
26
+ this.classType = Arrayable
27
+ this.innerList = []
28
+ this.initialized = false
29
+ this.elementClass = elementClass
30
+ }
31
+
32
+ /**
33
+ * Initialize the inner list, should only run once.
34
+ * @param {Array<ArrayElement>} initialList Give the array of elements to start in this Arrayable.
35
+ * @return {Arrayable}
36
+ */
37
+ initialize (initialList) {
38
+ if (this.initialized) {
39
+ console.warn('Attempt to initialize non-empty list.')
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 {Array<ArrayElement>}
50
+ */
51
+ get list () {
52
+ return this.innerList
53
+ }
54
+
55
+ /**
56
+ * Retrieve the first Element from the Arrayable
57
+ * @returns {ArrayElement}
58
+ */
59
+ get first () {
60
+ return this.innerList[0]
61
+ }
62
+
63
+ /**
64
+ * Retrieve the last Element from the Arrayable
65
+ * @returns {ArrayElement}
66
+ */
67
+ get last () {
68
+ return this.innerList[this.length - 1]
69
+ }
70
+
71
+ /**
72
+ * Return the length of the list.
73
+ * @returns {number}
74
+ */
75
+ get length () {
76
+ return this.innerList.length
77
+ }
78
+
79
+ /**
80
+ * Insert a new node (or data) after a node.
81
+ * @param {ArrayElement|*} node The existing node as reference
82
+ * @param {ArrayElement|*} newNode The new node to go after the existing node
83
+ * @returns {Arrayable}
84
+ */
85
+ insertAfter (node, newNode) {
86
+ const insertAt = this.innerList.indexOf(node)
87
+ this.innerList.splice(insertAt + 1, 0, this.elementClass.make(newNode))
88
+ return this
89
+ }
90
+
91
+ /**
92
+ * Insert a new node (or data) before a node.
93
+ * @param {ArrayElement|*} node The existing node as reference
94
+ * @param {ArrayElement|*} newNode The new node to go before the existing node
95
+ * @returns {Arrayable}
96
+ */
97
+ insertBefore (node, newNode) {
98
+ const insertAt = this.innerList.indexOf(node)
99
+ this.innerList.splice(insertAt, 0, this.elementClass.make(newNode))
100
+ return this
101
+ }
102
+
103
+ /**
104
+ * Add a node (or data) after the given (or last) node in the list.
105
+ * @param {ArrayElement|*} node The new node to add to the end of the list
106
+ * @param {ArrayElement} after The existing last node
107
+ * @returns {Arrayable}
108
+ */
109
+ append (node) {
110
+ const after = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.last
111
+ return this.insertAfter(after, node)
112
+ }
113
+
114
+ /**
115
+ * Add a node (or data) before the given (or first) node in the list.
116
+ * @param {ArrayElement|*} node The new node to add to the start of the list
117
+ * @param {ArrayElement} before The existing first node
118
+ * @returns {Arrayable}
119
+ */
120
+ prepend (node) {
121
+ const before = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.first
122
+ return this.insertBefore(before, node)
123
+ }
124
+
125
+ /**
126
+ * Remove an element from this arrayable.
127
+ * @param {ArrayElement} node The node we wish to remove (and it will be returned after removal)
128
+ * @return {ArrayElement}
129
+ */
130
+ remove (node) {
131
+ const deleteAt = this.innerList.indexOf(node)
132
+ this.innerList.splice(deleteAt, 1)
133
+ return node
134
+ }
135
+
136
+ /**
137
+ * Retrieve an ArrayElement item from this list by numeric index, otherwise return null.
138
+ * @param {number} index The integer number for retrieving a node by position.
139
+ * @return {ArrayElement|null}
140
+ */
141
+ item (index) {
142
+ if (index >= this.length) {
143
+ // index is beyond array limit
144
+ return null
145
+ }
146
+ if (index >= 0) {
147
+ // use the positive index at nth position from the beginning of the array
148
+ return this.innerList[index]
149
+ }
150
+ const calculatedIndex = this.length + index
151
+ if (calculatedIndex < 0) {
152
+ // negative index is beyond array limit (minus direction)
153
+ return null
154
+ }
155
+ // Return the item at nth position from the end of the array
156
+ return this.innerList[calculatedIndex]
157
+ }
158
+
159
+ /**
160
+ * Be able to run forEach on this Arrayable to iterate over the elements.
161
+ * @param {forEachCallback} callback The function to call for-each element
162
+ * @param {Arrayable} thisArg Optional, 'this' reference
163
+ * @returns {Arrayable}
164
+ */
165
+ forEach (callback) {
166
+ const thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this
167
+ for (let i = 0; i < thisArg.length; ++i) {
168
+ callback(thisArg.item(i), i, thisArg)
169
+ }
170
+ return thisArg
171
+ }
172
+
173
+ /**
174
+ * Be able to iterate over this class.
175
+ * @returns {Iterator}
176
+ */
177
+ [Symbol.iterator] () {
178
+ const index = 0
179
+ return new _ArrayIterator.default(this.innerList, index)
180
+ }
181
+ }
182
+ /**
183
+ * Convert an array to an Arrayable.
184
+ * @param {Array} values An array of values which will be converted to elements in this arrayable
185
+ * @param {IsElement} [elementClass=ArrayElement] The class to use for each element
186
+ * @param {IsArrayable<ArrayElement>} [classType=Arrayable] Provide the type of IsArrayable to use.
187
+ * @returns {Arrayable}
188
+ */
189
+ Arrayable.fromArray = function () {
190
+ const values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []
191
+ const elementClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _ArrayElement.default
192
+ const classType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Arrayable
193
+ const list = new classType(elementClass)
194
+ return list.initialize(elementClass.fromArray(values).head)
195
+ }
196
+ var _default = exports.default = Arrayable
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _ArrayElement=_interopRequireDefault(require("./ArrayElement")),_ArrayIterator=_interopRequireDefault(require("../../recipes/ArrayIterator"));function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}class Arrayable{constructor(){this.classType=Arrayable,this.innerList=[],this.initialized=!1,this.initialized=!1}initialize(t){return this.initialized?(console.warn("Attempt to initialize non-empty list."),this):(this.initialized=!0,this.innerList=t,this)}get list(){return this.innerList}get first(){return this.innerList[0]}get last(){return this.innerList[this.length-1]}get length(){return this.innerList.length}insertAfter(t,e){const i=this.innerList.indexOf(t);return this.innerList.splice(i+1,0,t.classType.make(e)),this}insertBefore(t,e){const i=this.innerList.indexOf(t);return this.innerList.splice(i,0,t.classType.make(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){const e=this.innerList.indexOf(t);return this.innerList.splice(e,1),t}item(t){if(t>=this.length)return null;if(t>=0)return this.innerList[t];const e=this.length+t;return e<0?null:this.innerList[e]}forEach(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this;for(let i=0;i<e.length;++i)t(e.item(i),i,e);return e}[Symbol.iterator](){return new _ArrayIterator.default(this.innerList,0)}}Arrayable.fromArray=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_ArrayElement.default;return(new(arguments.length>2&&void 0!==arguments[2]?arguments[2]:Arrayable)).initialize(e.fromArray(t).head)};var _default=exports.default=Arrayable;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _ArrayElement=_interopRequireDefault(require("./ArrayElement")),_ArrayIterator=_interopRequireDefault(require("../../recipes/ArrayIterator"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}class Arrayable{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_ArrayElement.default;this.classType=Arrayable,this.innerList=[],this.initialized=!1,this.elementClass=e}initialize(e){return this.initialized?(console.warn("Attempt to initialize non-empty list."),this):(this.initialized=!0,this.innerList=e,this)}get list(){return this.innerList}get first(){return this.innerList[0]}get last(){return this.innerList[this.length-1]}get length(){return this.innerList.length}insertAfter(e,t){const i=this.innerList.indexOf(e);return this.innerList.splice(i+1,0,this.elementClass.make(t)),this}insertBefore(e,t){const i=this.innerList.indexOf(e);return this.innerList.splice(i,0,this.elementClass.make(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){const t=this.innerList.indexOf(e);return this.innerList.splice(t,1),e}item(e){if(e>=this.length)return null;if(e>=0)return this.innerList[e];const t=this.length+e;return t<0?null:this.innerList[t]}forEach(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this;for(let i=0;i<t.length;++i)e(t.item(i),i,t);return t}[Symbol.iterator](){return new _ArrayIterator.default(this.innerList,0)}}Arrayable.fromArray=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_ArrayElement.default;return new(arguments.length>2&&void 0!==arguments[2]?arguments[2]:Arrayable)(t).initialize(t.fromArray(e).head)};var _default=exports.default=Arrayable;
@@ -1,47 +1,47 @@
1
- /**
2
- * @file doubly linked list item.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.1.0
5
- * @memberOf module:collect-your-stuff
6
- */
7
- import IsDoubleLinker from '../../recipes/IsDoubleLinker';
8
- /**
9
- * DoubleLinker represents a node in a DoublyLinkedList which is chained by next and prev.
10
- * @extends Linker
11
- */
12
- declare class DoubleLinker implements IsDoubleLinker {
13
- readonly classType: typeof DoubleLinker;
14
- data: any;
15
- next: DoubleLinker | null;
16
- prev: DoubleLinker | null;
17
- /**
18
- * Create the new DoubleLinker instance, provide the data and optionally the next and prev references.
19
- * @param {Object} [nodeData={}]
20
- * @param {*} [nodeData.data=null] The data to be stored in this linker
21
- * @param {DoubleLinker|null} [nodeData.next=null] The reference to the next linker if any
22
- * @param {DoubleLinker|null} [nodeData.prev=null] The reference to the previous linker if any
23
- */
24
- constructor({ data, next, prev }?: {
25
- data?: any;
26
- next?: DoubleLinker | null;
27
- prev?: DoubleLinker | null;
28
- });
29
- /**
30
- * Make a new DoubleLinker from the data given if it is not already a valid Linker.
31
- * @param {DoubleLinker|*} linker Return a valid Linker instance from given data, or even an already valid one.
32
- * @param {IsDoubleLinker} [classType=DoubleLinker] Provide the type of IsDoubleLinker to use.
33
- * @return {DoubleLinker}
34
- */
35
- static make: (linker: DoubleLinker | any, classType?: any) => IsDoubleLinker | any;
36
- /**
37
- * Convert an array into DoubleLinker instances, return the head and tail DoubleLinkers.
38
- * @param {Array} [values=[]] Provide an array of data that will be converted to a chain of linkers.
39
- * @param {IsDoubleLinker} [classType=DoubleLinker] Provide the type of IsDoubleLinker to use.
40
- * @returns {{head: DoubleLinker, tail: DoubleLinker}}
41
- */
42
- static fromArray: (values?: Array<any>, classType?: any) => {
43
- head: DoubleLinker | any;
44
- tail: DoubleLinker | any;
45
- };
46
- }
47
- export default DoubleLinker;
1
+ /**
2
+ * @file doubly linked list item.
3
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
4
+ * @version 1.1.0
5
+ * @memberOf module:collect-your-stuff
6
+ */
7
+ import IsDoubleLinker from '../../recipes/IsDoubleLinker';
8
+ /**
9
+ * DoubleLinker represents a node in a DoublyLinkedList which is chained by next and prev.
10
+ * @extends Linker
11
+ */
12
+ declare class DoubleLinker implements IsDoubleLinker {
13
+ readonly classType: typeof DoubleLinker;
14
+ data: any;
15
+ next: DoubleLinker | null;
16
+ prev: DoubleLinker | null;
17
+ /**
18
+ * Create the new DoubleLinker instance, provide the data and optionally the next and prev references.
19
+ * @param {Object} [nodeData={}]
20
+ * @param {*} [nodeData.data=null] The data to be stored in this linker
21
+ * @param {DoubleLinker|null} [nodeData.next=null] The reference to the next linker if any
22
+ * @param {DoubleLinker|null} [nodeData.prev=null] The reference to the previous linker if any
23
+ */
24
+ constructor({ data, next, prev }?: {
25
+ data?: any;
26
+ next?: DoubleLinker | null;
27
+ prev?: DoubleLinker | null;
28
+ });
29
+ /**
30
+ * Make a new DoubleLinker from the data given if it is not already a valid Linker.
31
+ * @param {DoubleLinker|*} linker Return a valid Linker instance from given data, or even an already valid one.
32
+ * @param {IsDoubleLinker} [classType=DoubleLinker] Provide the type of IsDoubleLinker to use.
33
+ * @return {DoubleLinker}
34
+ */
35
+ static make: (linker: DoubleLinker | any, classType?: any) => IsDoubleLinker | any;
36
+ /**
37
+ * Convert an array into DoubleLinker instances, return the head and tail DoubleLinkers.
38
+ * @param {Array} [values=[]] Provide an array of data that will be converted to a chain of linkers.
39
+ * @param {IsDoubleLinker} [classType=DoubleLinker] Provide the type of IsDoubleLinker to use.
40
+ * @returns {{head: DoubleLinker, tail: DoubleLinker}}
41
+ */
42
+ static fromArray: (values?: Array<any>, classType?: any) => {
43
+ head: DoubleLinker | any;
44
+ tail: DoubleLinker | any;
45
+ };
46
+ }
47
+ export default DoubleLinker;