collect-your-stuff 2.1.1 → 2.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 (68) hide show
  1. package/README.md +898 -213
  2. package/browser/collect-your-stuff.js +677 -648
  3. package/browser/collect-your-stuff.min.js +1 -1
  4. package/dist/collections/arrayable/ArrayElement.d.ts +38 -38
  5. package/dist/collections/arrayable/ArrayElement.js +66 -66
  6. package/dist/collections/arrayable/Arrayable.d.ts +122 -122
  7. package/dist/collections/arrayable/Arrayable.js +2 -2
  8. package/dist/collections/doubly-linked-list/DoubleLinker.d.ts +50 -50
  9. package/dist/collections/doubly-linked-list/DoubleLinker.js +1 -1
  10. package/dist/collections/doubly-linked-list/DoublyLinkedList.d.ts +125 -125
  11. package/dist/collections/doubly-linked-list/DoublyLinkedList.js +3 -3
  12. package/dist/collections/linked-list/LinkedList.d.ts +126 -126
  13. package/dist/collections/linked-list/LinkedList.js +3 -3
  14. package/dist/collections/linked-list/Linker.d.ts +46 -46
  15. package/dist/collections/linked-list/Linker.js +1 -1
  16. package/dist/collections/linked-tree-list/LinkedTreeList.d.ts +159 -159
  17. package/dist/collections/linked-tree-list/LinkedTreeList.js +3 -3
  18. package/dist/collections/linked-tree-list/TreeLinker.d.ts +71 -71
  19. package/dist/collections/linked-tree-list/TreeLinker.js +2 -2
  20. package/dist/collections/queue/Queue.d.ts +59 -59
  21. package/dist/collections/queue/Queue.js +11 -9
  22. package/dist/collections/queue/Queueable.d.ts +83 -83
  23. package/dist/collections/queue/Queueable.js +9 -7
  24. package/dist/collections/queue/TaskQueue.d.ts +68 -68
  25. package/dist/collections/queue/TaskQueue.js +2 -2
  26. package/dist/collections/stack/Stack.d.ts +64 -64
  27. package/dist/collections/stack/Stack.js +11 -9
  28. package/dist/collections/stack/Stackable.d.ts +59 -59
  29. package/dist/collections/stack/Stackable.js +1 -1
  30. package/dist/collections/stack/TaskStack.d.ts +65 -65
  31. package/dist/collections/stack/TaskStack.js +2 -2
  32. package/dist/main.d.ts +68 -68
  33. package/dist/main.js +1 -1
  34. package/dist/recipes/ArrayIterator.d.ts +20 -20
  35. package/dist/recipes/ArrayIterator.js +39 -39
  36. package/dist/recipes/DoubleLinkerIterator.d.ts +18 -18
  37. package/dist/recipes/DoubleLinkerIterator.js +33 -33
  38. package/dist/recipes/IsArrayable.d.ts +105 -105
  39. package/dist/recipes/IsArrayable.js +5 -5
  40. package/dist/recipes/IsDoubleLinker.d.ts +14 -14
  41. package/dist/recipes/IsDoubleLinker.js +5 -5
  42. package/dist/recipes/IsElement.d.ts +14 -14
  43. package/dist/recipes/IsElement.js +5 -5
  44. package/dist/recipes/IsLinker.d.ts +10 -10
  45. package/dist/recipes/IsLinker.js +5 -5
  46. package/dist/recipes/IsQueue.d.ts +37 -37
  47. package/dist/recipes/IsQueue.js +5 -5
  48. package/dist/recipes/IsStack.d.ts +36 -36
  49. package/dist/recipes/IsStack.js +5 -5
  50. package/dist/recipes/IsTree.d.ts +11 -11
  51. package/dist/recipes/IsTree.js +5 -5
  52. package/dist/recipes/IsTreeNode.d.ts +29 -29
  53. package/dist/recipes/IsTreeNode.js +5 -5
  54. package/dist/recipes/LinkerIterator.d.ts +18 -18
  55. package/dist/recipes/LinkerIterator.js +33 -33
  56. package/dist/recipes/Runnable.d.ts +55 -55
  57. package/dist/recipes/Runnable.js +69 -69
  58. package/dist/recipes/TreeLinkerIterator.d.ts +20 -20
  59. package/dist/recipes/TreeLinkerIterator.js +1 -1
  60. package/dist/recipes/recipes.d.ts +15 -15
  61. package/dist/recipes/recipes.js +2 -2
  62. package/dist/services/parseTree.d.ts +9 -9
  63. package/dist/services/parseTree.js +1 -1
  64. package/dist/services/parseTreeNext.d.ts +17 -17
  65. package/dist/services/parseTreeNext.js +42 -42
  66. package/dist/services/services.d.ts +13 -13
  67. package/dist/services/services.js +2 -2
  68. package/package.json +2 -2
@@ -1,122 +1,122 @@
1
- /**
2
- * @file arrayable list.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.1.0
5
- * @memberOf module:collect-your-stuff
6
- */
7
- import { ArrayElement } from './ArrayElement';
8
- import { forEachCallback, IsArrayable } from '../../recipes/IsArrayable';
9
- import { IsElement } from '../../recipes/IsElement';
10
- /**
11
- * Arrayable represents a collection stored as an array.
12
- */
13
- export declare class Arrayable implements IsArrayable<ArrayElement>, Iterable<ArrayElement> {
14
- /** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
15
- readonly classType: typeof Arrayable;
16
- /** The array which stores the elements of this Arrayable. */
17
- innerList: Array<ArrayElement>;
18
- /** Whether the inner list has been initialized (it can only be initialized once). */
19
- initialized: boolean;
20
- /** The class used to wrap the data given to this Arrayable as elements. */
21
- elementClass: typeof ArrayElement;
22
- /**
23
- * Create the new Arrayable instance, configure the Arrayable class.
24
- * @param {ArrayElement} [elementClass=ArrayElement] The class used to wrap given data as elements.
25
- */
26
- constructor(elementClass?: typeof ArrayElement);
27
- /**
28
- * Find the position of an element which must be in this list.
29
- * @param {ArrayElement} node The element to find
30
- * @returns {number}
31
- * @throws {Error} When the element is not in this list
32
- */
33
- private indexOfElement;
34
- /**
35
- * Initialize the inner list, should only run once.
36
- * @param {Array<ArrayElement>} initialList Give the array of elements to start in this Arrayable.
37
- * @return {Arrayable}
38
- */
39
- initialize(initialList: Array<ArrayElement>): Arrayable;
40
- /**
41
- * Retrieve the innerList used (the list itself, not a copy).
42
- * @returns {Array<ArrayElement>}
43
- */
44
- get list(): Array<ArrayElement>;
45
- /**
46
- * Retrieve the first Element from the Arrayable
47
- * @returns {ArrayElement|null} The first element, or null when the Arrayable is empty
48
- */
49
- get first(): ArrayElement | null;
50
- /**
51
- * Retrieve the last Element from the Arrayable
52
- * @returns {ArrayElement|null} The last element, or null when the Arrayable is empty
53
- */
54
- get last(): ArrayElement | null;
55
- /**
56
- * Return the length of the list.
57
- * @returns {number}
58
- */
59
- get length(): number;
60
- /**
61
- * Insert a new node (or data) after a node.
62
- * @param {ArrayElement|null} node The existing node as reference, or null to insert at the start of the list
63
- * @param {ArrayElement|*} newNode The new node to go after the existing node
64
- * @returns {Arrayable}
65
- * @throws {Error} When the reference node is not in this list
66
- */
67
- insertAfter(node: ArrayElement | null, newNode: ArrayElement | any): Arrayable;
68
- /**
69
- * Insert a new node (or data) before a node.
70
- * @param {ArrayElement|null} node The existing node as reference, or null to insert at the end of the list
71
- * @param {ArrayElement|*} newNode The new node to go before the existing node
72
- * @returns {Arrayable}
73
- * @throws {Error} When the reference node is not in this list
74
- */
75
- insertBefore(node: ArrayElement | null, newNode: ArrayElement | any): Arrayable;
76
- /**
77
- * Add a node (or data) after the given (or last) node in the list.
78
- * @param {ArrayElement|*} node The new node to add to the end of the list
79
- * @param {ArrayElement} after The existing last node
80
- * @returns {Arrayable}
81
- */
82
- append(node: ArrayElement | any, after?: ArrayElement | null): Arrayable;
83
- /**
84
- * Add a node (or data) before the given (or first) node in the list.
85
- * @param {ArrayElement|*} node The new node to add to the start of the list
86
- * @param {ArrayElement} before The existing first node
87
- * @returns {Arrayable}
88
- */
89
- prepend(node: ArrayElement | any, before?: ArrayElement | null): Arrayable;
90
- /**
91
- * Remove an element from this arrayable.
92
- * @param {ArrayElement} node The node we wish to remove (and it will be returned after removal)
93
- * @return {ArrayElement|null} The removed node, or null when it was not in this list (nothing is removed)
94
- */
95
- remove(node: ArrayElement): ArrayElement | null;
96
- /**
97
- * Retrieve an ArrayElement item from this list by numeric index, otherwise return null.
98
- * @param {number} index The integer number for retrieving a node by position.
99
- * @return {ArrayElement|null}
100
- */
101
- item(index: number): ArrayElement | null;
102
- /**
103
- * Be able to run forEach on this Arrayable to iterate over the elements.
104
- * @param {forEachCallback} callback The function to call for-each element
105
- * @param {Arrayable} thisArg Optional, 'this' reference
106
- * @returns {Arrayable}
107
- */
108
- forEach(callback: forEachCallback, thisArg?: Arrayable): Arrayable;
109
- /**
110
- * Be able to iterate over this class.
111
- * @returns {Iterator}
112
- */
113
- [Symbol.iterator](): Iterator<ArrayElement>;
114
- /**
115
- * Convert an array to an Arrayable.
116
- * @param {Array} values An array of values which will be converted to elements in this arrayable
117
- * @param {IsElement} [elementClass=ArrayElement] The class to use for each element
118
- * @param {IsArrayable<ArrayElement>} [classType=Arrayable] Provide the type of IsArrayable to use.
119
- * @returns {Arrayable}
120
- */
121
- static fromArray: (values?: Array<any>, elementClass?: typeof ArrayElement, classType?: any) => IsArrayable<IsElement>;
122
- }
1
+ /**
2
+ * @file arrayable list.
3
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
4
+ * @version 1.1.0
5
+ * @memberOf module:collect-your-stuff
6
+ */
7
+ import { ArrayElement } from './ArrayElement';
8
+ import { forEachCallback, IsArrayable } from '../../recipes/IsArrayable';
9
+ import { IsElement } from '../../recipes/IsElement';
10
+ /**
11
+ * Arrayable represents a collection stored as an array.
12
+ */
13
+ export declare class Arrayable implements IsArrayable<ArrayElement>, Iterable<ArrayElement> {
14
+ /** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
15
+ readonly classType: typeof Arrayable;
16
+ /** The array which stores the elements of this Arrayable. */
17
+ innerList: Array<ArrayElement>;
18
+ /** Whether the inner list has been initialized (it can only be initialized once). */
19
+ initialized: boolean;
20
+ /** The class used to wrap the data given to this Arrayable as elements. */
21
+ elementClass: typeof ArrayElement;
22
+ /**
23
+ * Create the new Arrayable instance, configure the Arrayable class.
24
+ * @param {ArrayElement} [elementClass=ArrayElement] The class used to wrap given data as elements.
25
+ */
26
+ constructor(elementClass?: typeof ArrayElement);
27
+ /**
28
+ * Find the position of an element which must be in this list.
29
+ * @param {ArrayElement} node The element to find
30
+ * @returns {number}
31
+ * @throws {Error} When the element is not in this list
32
+ */
33
+ private indexOfElement;
34
+ /**
35
+ * Initialize the inner list, should only run once.
36
+ * @param {Array<ArrayElement>} initialList Give the array of elements to start in this Arrayable.
37
+ * @return {Arrayable}
38
+ */
39
+ initialize(initialList: Array<ArrayElement>): Arrayable;
40
+ /**
41
+ * Retrieve the innerList used (the list itself, not a copy).
42
+ * @returns {Array<ArrayElement>}
43
+ */
44
+ get list(): Array<ArrayElement>;
45
+ /**
46
+ * Retrieve the first Element from the Arrayable
47
+ * @returns {ArrayElement|null} The first element, or null when the Arrayable is empty
48
+ */
49
+ get first(): ArrayElement | null;
50
+ /**
51
+ * Retrieve the last Element from the Arrayable
52
+ * @returns {ArrayElement|null} The last element, or null when the Arrayable is empty
53
+ */
54
+ get last(): ArrayElement | null;
55
+ /**
56
+ * Return the length of the list.
57
+ * @returns {number}
58
+ */
59
+ get length(): number;
60
+ /**
61
+ * Insert a new node (or data) after a node.
62
+ * @param {ArrayElement|null} node The existing node as reference, or null to insert at the start of the list
63
+ * @param {ArrayElement|*} newNode The new node to go after the existing node
64
+ * @returns {Arrayable}
65
+ * @throws {Error} When the reference node is not in this list
66
+ */
67
+ insertAfter(node: ArrayElement | null, newNode: ArrayElement | any): Arrayable;
68
+ /**
69
+ * Insert a new node (or data) before a node.
70
+ * @param {ArrayElement|null} node The existing node as reference, or null to insert at the end of the list
71
+ * @param {ArrayElement|*} newNode The new node to go before the existing node
72
+ * @returns {Arrayable}
73
+ * @throws {Error} When the reference node is not in this list
74
+ */
75
+ insertBefore(node: ArrayElement | null, newNode: ArrayElement | any): Arrayable;
76
+ /**
77
+ * Add a node (or data) after the given (or last) node in the list.
78
+ * @param {ArrayElement|*} node The new node to add to the end of the list
79
+ * @param {ArrayElement} after The existing last node
80
+ * @returns {Arrayable}
81
+ */
82
+ append(node: ArrayElement | any, after?: ArrayElement | null): Arrayable;
83
+ /**
84
+ * Add a node (or data) before the given (or first) node in the list.
85
+ * @param {ArrayElement|*} node The new node to add to the start of the list
86
+ * @param {ArrayElement} before The existing first node
87
+ * @returns {Arrayable}
88
+ */
89
+ prepend(node: ArrayElement | any, before?: ArrayElement | null): Arrayable;
90
+ /**
91
+ * Remove an element from this arrayable.
92
+ * @param {ArrayElement} node The node we wish to remove (and it will be returned after removal)
93
+ * @return {ArrayElement|null} The removed node, or null when it was not in this list (nothing is removed)
94
+ */
95
+ remove(node: ArrayElement): ArrayElement | null;
96
+ /**
97
+ * Retrieve an ArrayElement item from this list by numeric index, otherwise return null.
98
+ * @param {number} index The integer number for retrieving a node by position.
99
+ * @return {ArrayElement|null}
100
+ */
101
+ item(index: number): ArrayElement | null;
102
+ /**
103
+ * Be able to run forEach on this Arrayable to iterate over the elements.
104
+ * @param {forEachCallback} callback The function to call for-each element
105
+ * @param {Arrayable} thisArg Optional, 'this' reference
106
+ * @returns {Arrayable}
107
+ */
108
+ forEach(callback: forEachCallback, thisArg?: Arrayable): Arrayable;
109
+ /**
110
+ * Be able to iterate over this class.
111
+ * @returns {Iterator}
112
+ */
113
+ [Symbol.iterator](): Iterator<ArrayElement>;
114
+ /**
115
+ * Convert an array to an Arrayable.
116
+ * @param {Array} values An array of values which will be converted to elements in this arrayable
117
+ * @param {IsElement} [elementClass=ArrayElement] The class to use for each element
118
+ * @param {IsArrayable<ArrayElement>} [classType=Arrayable] Provide the type of IsArrayable to use.
119
+ * @returns {Arrayable}
120
+ */
121
+ static fromArray: (values?: Array<any>, elementClass?: typeof ArrayElement, classType?: any) => IsArrayable<IsElement>;
122
+ }
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', {
4
4
  value: true
5
5
  })
6
6
  exports.Arrayable = void 0
7
- var _ArrayElement = require('./ArrayElement')
8
- var _ArrayIterator = require('../../recipes/ArrayIterator')
7
+ const _ArrayElement = require('./ArrayElement')
8
+ const _ArrayIterator = require('../../recipes/ArrayIterator')
9
9
  /**
10
10
  * @file arrayable list.
11
11
  * @author Joshua Heagle <joshuaheagle@gmail.com>
@@ -1,50 +1,50 @@
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
- export declare class DoubleLinker implements IsDoubleLinker {
13
- /** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
14
- readonly classType: typeof DoubleLinker;
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: DoubleLinker | null;
19
- /** The linker before this one, or null when this is the first. */
20
- prev: DoubleLinker | null;
21
- /**
22
- * Create the new DoubleLinker instance, provide the data and optionally the next and prev references.
23
- * @param {Object} [nodeData={}] The settings for the new linker.
24
- * @param {*} [nodeData.data=null] The data to be stored in this linker
25
- * @param {DoubleLinker|null} [nodeData.next=null] The reference to the next linker if any
26
- * @param {DoubleLinker|null} [nodeData.prev=null] The reference to the previous linker if any
27
- */
28
- constructor({ data, next, prev }?: {
29
- data?: any;
30
- next?: DoubleLinker | null;
31
- prev?: DoubleLinker | null;
32
- });
33
- /**
34
- * Make a new DoubleLinker from the data given if it is not already a valid Linker.
35
- * @param {DoubleLinker|*} linker Return a valid Linker instance from given data, or even an already valid one.
36
- * @param {IsDoubleLinker} [classType=DoubleLinker] Provide the type of IsDoubleLinker to use.
37
- * @return {DoubleLinker}
38
- */
39
- static make: (linker: DoubleLinker | any, classType?: any) => IsDoubleLinker | any;
40
- /**
41
- * Convert an array into DoubleLinker instances, return the head and tail DoubleLinkers.
42
- * @param {Array} [values=[]] Provide an array of data that will be converted to a chain of linkers.
43
- * @param {IsDoubleLinker} [classType=DoubleLinker] Provide the type of IsDoubleLinker to use.
44
- * @returns {{head: DoubleLinker, tail: DoubleLinker}}
45
- */
46
- static fromArray: (values?: Array<any>, classType?: any) => {
47
- head: DoubleLinker | any;
48
- tail: DoubleLinker | any;
49
- };
50
- }
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
+ export declare class DoubleLinker implements IsDoubleLinker {
13
+ /** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
14
+ readonly classType: typeof DoubleLinker;
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: DoubleLinker | null;
19
+ /** The linker before this one, or null when this is the first. */
20
+ prev: DoubleLinker | null;
21
+ /**
22
+ * Create the new DoubleLinker instance, provide the data and optionally the next and prev references.
23
+ * @param {Object} [nodeData={}] The settings for the new linker.
24
+ * @param {*} [nodeData.data=null] The data to be stored in this linker
25
+ * @param {DoubleLinker|null} [nodeData.next=null] The reference to the next linker if any
26
+ * @param {DoubleLinker|null} [nodeData.prev=null] The reference to the previous linker if any
27
+ */
28
+ constructor({ data, next, prev }?: {
29
+ data?: any;
30
+ next?: DoubleLinker | null;
31
+ prev?: DoubleLinker | null;
32
+ });
33
+ /**
34
+ * Make a new DoubleLinker from the data given if it is not already a valid Linker.
35
+ * @param {DoubleLinker|*} linker Return a valid Linker instance from given data, or even an already valid one.
36
+ * @param {IsDoubleLinker} [classType=DoubleLinker] Provide the type of IsDoubleLinker to use.
37
+ * @return {DoubleLinker}
38
+ */
39
+ static make: (linker: DoubleLinker | any, classType?: any) => IsDoubleLinker | any;
40
+ /**
41
+ * Convert an array into DoubleLinker instances, return the head and tail DoubleLinkers.
42
+ * @param {Array} [values=[]] Provide an array of data that will be converted to a chain of linkers.
43
+ * @param {IsDoubleLinker} [classType=DoubleLinker] Provide the type of IsDoubleLinker to use.
44
+ * @returns {{head: DoubleLinker, tail: DoubleLinker}}
45
+ */
46
+ static fromArray: (values?: Array<any>, classType?: any) => {
47
+ head: DoubleLinker | any;
48
+ tail: DoubleLinker | any;
49
+ };
50
+ }
@@ -6,7 +6,7 @@ Object.defineProperty(exports, '__esModule', {
6
6
  exports.DoubleLinker = void 0
7
7
  require('core-js/modules/esnext.iterator.constructor.js')
8
8
  require('core-js/modules/esnext.iterator.reduce.js')
9
- var _Linker = require('../linked-list/Linker')
9
+ const _Linker = require('../linked-list/Linker')
10
10
  /**
11
11
  * DoubleLinker represents a node in a DoublyLinkedList which is chained by next and prev.
12
12
  * @extends Linker
@@ -1,125 +1,125 @@
1
- /**
2
- * @file doubly linked list.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.1.0
5
- * @memberOf module:collect-your-stuff
6
- */
7
- import { DoubleLinker } from './DoubleLinker';
8
- import { forEachCallback, IsArrayable } from '../../recipes/IsArrayable';
9
- import { IsDoubleLinker } from '../../recipes/IsDoubleLinker';
10
- /**
11
- * DoublyLinkedList represents a collection stored as a LinkedList with prev and next references.
12
- * @extends LinkedList
13
- */
14
- export declare class DoublyLinkedList implements IsArrayable<DoubleLinker>, Iterable<DoubleLinker> {
15
- /** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
16
- readonly classType: typeof DoublyLinkedList;
17
- /** A linker of the list (null when the list is empty); the head is found by walking back from it. */
18
- innerList: DoubleLinker;
19
- /** Whether the inner list has been initialized (it can only be initialized once). */
20
- initialized: boolean;
21
- /** The class used to wrap the data given to this list as linkers. */
22
- linkerClass: typeof DoubleLinker;
23
- /** The last linker, remembered so that adding to the end does not need to walk the whole list (null when not known yet). */
24
- private tailCache;
25
- /** 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). */
26
- private countCache;
27
- /**
28
- * Create the new DoublyLinkedList instance.
29
- * @param {DoubleLinker} [linkerClass=DoubleLinker] The class used to wrap given data as linkers.
30
- */
31
- constructor(linkerClass?: typeof DoubleLinker);
32
- /**
33
- * Initialize the inner list, should only run once.
34
- * @param {DoubleLinker} initialList Give the list of double-linkers to start in this doubly linked-list.
35
- * @return {DoublyLinkedList}
36
- */
37
- initialize(initialList: DoubleLinker): DoublyLinkedList;
38
- /**
39
- * Retrieve the innerList used (the list itself, not a copy).
40
- * @returns {DoubleLinker}
41
- */
42
- get list(): DoubleLinker;
43
- /**
44
- * Retrieve the first DoubleLinker in the list.
45
- * @returns {DoubleLinker}
46
- */
47
- get first(): DoubleLinker | null;
48
- /**
49
- * Retrieve the last DoubleLinker in the list. The end is remembered, so this does not walk the list.
50
- * @returns {DoubleLinker}
51
- */
52
- get last(): DoubleLinker | null;
53
- /**
54
- * 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
55
- * (call reset() after linkers were changed directly).
56
- * @returns {number}
57
- */
58
- get length(): number;
59
- /**
60
- * Insert a new node (or data) after a node.
61
- * @param {DoubleLinker|*} node The existing node as reference (which must be in this list, this is not checked), or null to insert at the start of the list
62
- * @param {DoubleLinker|*} newNode The new node to go after the existing node
63
- * @returns {DoublyLinkedList}
64
- */
65
- insertAfter(node: DoubleLinker | null, newNode: DoubleLinker | any): DoublyLinkedList;
66
- /**
67
- * Insert a new node (or data) before a node.
68
- * @param {DoubleLinker|*} node The existing node as reference (which must be in this list, this is not checked), or null to insert at the end of the list
69
- * @param {DoubleLinker|*} newNode The new node to go before the existing node
70
- * @returns {DoublyLinkedList}
71
- */
72
- insertBefore(node: DoubleLinker | null, newNode: DoubleLinker | any): DoublyLinkedList;
73
- /**
74
- * Add a node (or data) after the given (or last) node in the list.
75
- * @param {DoubleLinker|*} node The new node to add to the end of the list
76
- * @param {DoubleLinker} after The existing last node
77
- * @returns {DoubleLinker}
78
- */
79
- append(node: DoubleLinker | any, after?: DoubleLinker): DoublyLinkedList;
80
- /**
81
- * Add a node (or data) before the given (or first) node in the list.
82
- * @param {DoubleLinker|*} node The new node to add to the start of the list
83
- * @param {DoubleLinker} before The existing first node
84
- * @returns {DoubleLinker}
85
- */
86
- prepend(node: DoubleLinker | any, before?: DoubleLinker): DoublyLinkedList;
87
- /**
88
- * Remove a linker from this linked list.
89
- * @param {DoubleLinker} node The node we wish to remove (and it will be returned after removal)
90
- * @return {DoubleLinker}
91
- */
92
- remove(node: DoubleLinker | null): DoubleLinker | null;
93
- /**
94
- * Refresh all references (the head, the end and the length) by walking the list once, and return the head. The list's
95
- * own methods keep these up to date, so this is only needed after linkers were changed directly.
96
- * @return {DoubleLinker|null}
97
- */
98
- reset(): DoubleLinker | null;
99
- /**
100
- * Retrieve a DoubleLinker item from this list by numeric index, otherwise return null.
101
- * @param {number} index The integer number for retrieving a node by position.
102
- * @returns {DoubleLinker|null}
103
- */
104
- item(index: number): DoubleLinker;
105
- /**
106
- * Be able to run forEach on this DoublyLinkedList to iterate over the DoubleLinker Items.
107
- * @param {forEachCallback} callback The function to call for-each double linker
108
- * @param {DoublyLinkedList} thisArg Optional, 'this' reference
109
- * @return {DoublyLinkedList} The list which was iterated.
110
- */
111
- forEach(callback: forEachCallback, thisArg?: DoublyLinkedList): DoublyLinkedList;
112
- /**
113
- * Be able to iterate over this class.
114
- * @returns {Iterator}
115
- */
116
- [Symbol.iterator](): Iterator<DoubleLinker>;
117
- /**
118
- * Convert an array into a DoublyLinkedList instance, return the new instance.
119
- * @param {Array} [values=[]] An array of values which will be converted to linkers in this doubly-linked-list
120
- * @param {IsDoubleLinker} [linkerClass=DoubleLinker] The class to use for each linker
121
- * @param {IsArrayable<IsDoubleLinker>} [classType=LinkedList] Provide the type of IsArrayable to use.
122
- * @returns {DoublyLinkedList}
123
- */
124
- static fromArray: (values?: Array<any>, linkerClass?: typeof DoubleLinker, classType?: any) => IsArrayable<IsDoubleLinker> | any;
125
- }
1
+ /**
2
+ * @file doubly linked list.
3
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
4
+ * @version 1.1.0
5
+ * @memberOf module:collect-your-stuff
6
+ */
7
+ import { DoubleLinker } from './DoubleLinker';
8
+ import { forEachCallback, IsArrayable } from '../../recipes/IsArrayable';
9
+ import { IsDoubleLinker } from '../../recipes/IsDoubleLinker';
10
+ /**
11
+ * DoublyLinkedList represents a collection stored as a LinkedList with prev and next references.
12
+ * @extends LinkedList
13
+ */
14
+ export declare class DoublyLinkedList implements IsArrayable<DoubleLinker>, Iterable<DoubleLinker> {
15
+ /** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
16
+ readonly classType: typeof DoublyLinkedList;
17
+ /** A linker of the list (null when the list is empty); the head is found by walking back from it. */
18
+ innerList: DoubleLinker;
19
+ /** Whether the inner list has been initialized (it can only be initialized once). */
20
+ initialized: boolean;
21
+ /** The class used to wrap the data given to this list as linkers. */
22
+ linkerClass: typeof DoubleLinker;
23
+ /** The last linker, remembered so that adding to the end does not need to walk the whole list (null when not known yet). */
24
+ private tailCache;
25
+ /** 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). */
26
+ private countCache;
27
+ /**
28
+ * Create the new DoublyLinkedList instance.
29
+ * @param {DoubleLinker} [linkerClass=DoubleLinker] The class used to wrap given data as linkers.
30
+ */
31
+ constructor(linkerClass?: typeof DoubleLinker);
32
+ /**
33
+ * Initialize the inner list, should only run once.
34
+ * @param {DoubleLinker} initialList Give the list of double-linkers to start in this doubly linked-list.
35
+ * @return {DoublyLinkedList}
36
+ */
37
+ initialize(initialList: DoubleLinker): DoublyLinkedList;
38
+ /**
39
+ * Retrieve the innerList used (the list itself, not a copy).
40
+ * @returns {DoubleLinker}
41
+ */
42
+ get list(): DoubleLinker;
43
+ /**
44
+ * Retrieve the first DoubleLinker in the list.
45
+ * @returns {DoubleLinker}
46
+ */
47
+ get first(): DoubleLinker | null;
48
+ /**
49
+ * Retrieve the last DoubleLinker in the list. The end is remembered, so this does not walk the list.
50
+ * @returns {DoubleLinker}
51
+ */
52
+ get last(): DoubleLinker | null;
53
+ /**
54
+ * 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
55
+ * (call reset() after linkers were changed directly).
56
+ * @returns {number}
57
+ */
58
+ get length(): number;
59
+ /**
60
+ * Insert a new node (or data) after a node.
61
+ * @param {DoubleLinker|*} node The existing node as reference (which must be in this list, this is not checked), or null to insert at the start of the list
62
+ * @param {DoubleLinker|*} newNode The new node to go after the existing node
63
+ * @returns {DoublyLinkedList}
64
+ */
65
+ insertAfter(node: DoubleLinker | null, newNode: DoubleLinker | any): DoublyLinkedList;
66
+ /**
67
+ * Insert a new node (or data) before a node.
68
+ * @param {DoubleLinker|*} node The existing node as reference (which must be in this list, this is not checked), or null to insert at the end of the list
69
+ * @param {DoubleLinker|*} newNode The new node to go before the existing node
70
+ * @returns {DoublyLinkedList}
71
+ */
72
+ insertBefore(node: DoubleLinker | null, newNode: DoubleLinker | any): DoublyLinkedList;
73
+ /**
74
+ * Add a node (or data) after the given (or last) node in the list.
75
+ * @param {DoubleLinker|*} node The new node to add to the end of the list
76
+ * @param {DoubleLinker} after The existing last node
77
+ * @returns {DoubleLinker}
78
+ */
79
+ append(node: DoubleLinker | any, after?: DoubleLinker): DoublyLinkedList;
80
+ /**
81
+ * Add a node (or data) before the given (or first) node in the list.
82
+ * @param {DoubleLinker|*} node The new node to add to the start of the list
83
+ * @param {DoubleLinker} before The existing first node
84
+ * @returns {DoubleLinker}
85
+ */
86
+ prepend(node: DoubleLinker | any, before?: DoubleLinker): DoublyLinkedList;
87
+ /**
88
+ * Remove a linker from this linked list.
89
+ * @param {DoubleLinker} node The node we wish to remove (and it will be returned after removal)
90
+ * @return {DoubleLinker}
91
+ */
92
+ remove(node: DoubleLinker | null): DoubleLinker | null;
93
+ /**
94
+ * Refresh all references (the head, the end and the length) by walking the list once, and return the head. The list's
95
+ * own methods keep these up to date, so this is only needed after linkers were changed directly.
96
+ * @return {DoubleLinker|null}
97
+ */
98
+ reset(): DoubleLinker | null;
99
+ /**
100
+ * Retrieve a DoubleLinker item from this list by numeric index, otherwise return null.
101
+ * @param {number} index The integer number for retrieving a node by position.
102
+ * @returns {DoubleLinker|null}
103
+ */
104
+ item(index: number): DoubleLinker;
105
+ /**
106
+ * Be able to run forEach on this DoublyLinkedList to iterate over the DoubleLinker Items.
107
+ * @param {forEachCallback} callback The function to call for-each double linker
108
+ * @param {DoublyLinkedList} thisArg Optional, 'this' reference
109
+ * @return {DoublyLinkedList} The list which was iterated.
110
+ */
111
+ forEach(callback: forEachCallback, thisArg?: DoublyLinkedList): DoublyLinkedList;
112
+ /**
113
+ * Be able to iterate over this class.
114
+ * @returns {Iterator}
115
+ */
116
+ [Symbol.iterator](): Iterator<DoubleLinker>;
117
+ /**
118
+ * Convert an array into a DoublyLinkedList instance, return the new instance.
119
+ * @param {Array} [values=[]] An array of values which will be converted to linkers in this doubly-linked-list
120
+ * @param {IsDoubleLinker} [linkerClass=DoubleLinker] The class to use for each linker
121
+ * @param {IsArrayable<IsDoubleLinker>} [classType=LinkedList] Provide the type of IsArrayable to use.
122
+ * @returns {DoublyLinkedList}
123
+ */
124
+ static fromArray: (values?: Array<any>, linkerClass?: typeof DoubleLinker, classType?: any) => IsArrayable<IsDoubleLinker> | any;
125
+ }
@@ -6,9 +6,9 @@ Object.defineProperty(exports, '__esModule', {
6
6
  exports.DoublyLinkedList = void 0
7
7
  require('core-js/modules/esnext.iterator.constructor.js')
8
8
  require('core-js/modules/esnext.iterator.for-each.js')
9
- var _DoubleLinker = require('./DoubleLinker')
10
- var _DoubleLinkerIterator = require('../../recipes/DoubleLinkerIterator')
11
- var _LinkedList = require('../linked-list/LinkedList')
9
+ const _DoubleLinker = require('./DoubleLinker')
10
+ const _DoubleLinkerIterator = require('../../recipes/DoubleLinkerIterator')
11
+ const _LinkedList = require('../linked-list/LinkedList')
12
12
  /**
13
13
  * @file doubly linked list.
14
14
  * @author Joshua Heagle <joshuaheagle@gmail.com>