collect-your-stuff 2.1.0 → 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 (69) hide show
  1. package/README.md +898 -213
  2. package/browser/collect-your-stuff.js +2672 -20684
  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 -69
  33. package/dist/main.js +1 -2
  34. package/dist/main.min.js +1 -1
  35. package/dist/recipes/ArrayIterator.d.ts +20 -20
  36. package/dist/recipes/ArrayIterator.js +39 -39
  37. package/dist/recipes/DoubleLinkerIterator.d.ts +18 -18
  38. package/dist/recipes/DoubleLinkerIterator.js +33 -33
  39. package/dist/recipes/IsArrayable.d.ts +105 -105
  40. package/dist/recipes/IsArrayable.js +5 -5
  41. package/dist/recipes/IsDoubleLinker.d.ts +14 -14
  42. package/dist/recipes/IsDoubleLinker.js +5 -5
  43. package/dist/recipes/IsElement.d.ts +14 -14
  44. package/dist/recipes/IsElement.js +5 -5
  45. package/dist/recipes/IsLinker.d.ts +10 -10
  46. package/dist/recipes/IsLinker.js +5 -5
  47. package/dist/recipes/IsQueue.d.ts +37 -37
  48. package/dist/recipes/IsQueue.js +5 -5
  49. package/dist/recipes/IsStack.d.ts +36 -36
  50. package/dist/recipes/IsStack.js +5 -5
  51. package/dist/recipes/IsTree.d.ts +11 -11
  52. package/dist/recipes/IsTree.js +5 -5
  53. package/dist/recipes/IsTreeNode.d.ts +29 -29
  54. package/dist/recipes/IsTreeNode.js +5 -5
  55. package/dist/recipes/LinkerIterator.d.ts +18 -18
  56. package/dist/recipes/LinkerIterator.js +33 -33
  57. package/dist/recipes/Runnable.d.ts +55 -55
  58. package/dist/recipes/Runnable.js +69 -69
  59. package/dist/recipes/TreeLinkerIterator.d.ts +20 -20
  60. package/dist/recipes/TreeLinkerIterator.js +1 -1
  61. package/dist/recipes/recipes.d.ts +15 -15
  62. package/dist/recipes/recipes.js +2 -2
  63. package/dist/services/parseTree.d.ts +9 -9
  64. package/dist/services/parseTree.js +1 -1
  65. package/dist/services/parseTreeNext.d.ts +17 -17
  66. package/dist/services/parseTreeNext.js +42 -42
  67. package/dist/services/services.d.ts +13 -13
  68. package/dist/services/services.js +2 -2
  69. package/package.json +2 -2
@@ -1,33 +1,33 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.LinkerIterator = void 0
7
- /**
8
- * Class LinkerIterator returns the next value when using linkers of linked type lists.
9
- */
10
- class LinkerIterator {
11
- /**
12
- * Create an iterator starting at the given item.
13
- * @param {IsLinker} current The item to start from.
14
- */
15
- constructor (current) {
16
- this.current = current
17
- }
18
-
19
- /**
20
- * Get the current item and move on to the following one.
21
- * @param {*} [value] Not used, present to match the Iterator interface.
22
- * @return {IteratorResult<IsLinker>} The current item, or done when there are no more.
23
- */
24
- next (value) {
25
- const result = {
26
- value: this.current,
27
- done: !this.current
28
- }
29
- this.current = this.current ? this.current.next : null
30
- return result
31
- }
32
- }
33
- exports.LinkerIterator = LinkerIterator
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.LinkerIterator = void 0
7
+ /**
8
+ * Class LinkerIterator returns the next value when using linkers of linked type lists.
9
+ */
10
+ class LinkerIterator {
11
+ /**
12
+ * Create an iterator starting at the given item.
13
+ * @param {IsLinker} current The item to start from.
14
+ */
15
+ constructor (current) {
16
+ this.current = current
17
+ }
18
+
19
+ /**
20
+ * Get the current item and move on to the following one.
21
+ * @param {*} [value] Not used, present to match the Iterator interface.
22
+ * @return {IteratorResult<IsLinker>} The current item, or done when there are no more.
23
+ */
24
+ next (value) {
25
+ const result = {
26
+ value: this.current,
27
+ done: !this.current
28
+ }
29
+ this.current = this.current ? this.current.next : null
30
+ return result
31
+ }
32
+ }
33
+ exports.LinkerIterator = LinkerIterator
@@ -1,55 +1,55 @@
1
- /**
2
- * @file Runnable class recipe.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.0.0
5
- * @memberOf module:collect-your-stuff
6
- */
7
- /**
8
- * Return results of the task.
9
- * @typedef {Object} completeResponse
10
- * @property {*} success
11
- * @property {*} error
12
- * @property {*} context
13
- */
14
- export type completeResponse = {
15
- success: boolean | any;
16
- error: boolean | any;
17
- context: any;
18
- };
19
- /**
20
- * Specify a type of class that is Runnable.
21
- */
22
- export interface IsRunnable {
23
- data: any;
24
- get task(): Function;
25
- run(): completeResponse | any;
26
- }
27
- /**
28
- * Identify a class that can be run.
29
- */
30
- export declare class Runnable implements IsRunnable {
31
- /** The task (or data) this runnable holds. */
32
- data: any;
33
- /**
34
- * Instantiate a Runnable class.
35
- * @param {*} [data=null] The task (a function) or the data which the task returns.
36
- */
37
- constructor(data?: any);
38
- /**
39
- * Retrieve the data which should be formed as a task.
40
- * @return {Function}
41
- */
42
- get task(): Function;
43
- /**
44
- * Run the runnable task.
45
- * @return {*}
46
- */
47
- run(): completeResponse | any;
48
- /**
49
- * Check if a given thing is Runnable
50
- * @memberof Runnable
51
- * @param {*} thing The value to check, or nothing to check whether this class is Runnable.
52
- * @return {boolean}
53
- */
54
- static isRunnable(thing: any): boolean;
55
- }
1
+ /**
2
+ * @file Runnable class recipe.
3
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
4
+ * @version 1.0.0
5
+ * @memberOf module:collect-your-stuff
6
+ */
7
+ /**
8
+ * Return results of the task.
9
+ * @typedef {Object} completeResponse
10
+ * @property {*} success
11
+ * @property {*} error
12
+ * @property {*} context
13
+ */
14
+ export type completeResponse = {
15
+ success: boolean | any;
16
+ error: boolean | any;
17
+ context: any;
18
+ };
19
+ /**
20
+ * Specify a type of class that is Runnable.
21
+ */
22
+ export interface IsRunnable {
23
+ data: any;
24
+ get task(): Function;
25
+ run(): completeResponse | any;
26
+ }
27
+ /**
28
+ * Identify a class that can be run.
29
+ */
30
+ export declare class Runnable implements IsRunnable {
31
+ /** The task (or data) this runnable holds. */
32
+ data: any;
33
+ /**
34
+ * Instantiate a Runnable class.
35
+ * @param {*} [data=null] The task (a function) or the data which the task returns.
36
+ */
37
+ constructor(data?: any);
38
+ /**
39
+ * Retrieve the data which should be formed as a task.
40
+ * @return {Function}
41
+ */
42
+ get task(): Function;
43
+ /**
44
+ * Run the runnable task.
45
+ * @return {*}
46
+ */
47
+ run(): completeResponse | any;
48
+ /**
49
+ * Check if a given thing is Runnable
50
+ * @memberof Runnable
51
+ * @param {*} thing The value to check, or nothing to check whether this class is Runnable.
52
+ * @return {boolean}
53
+ */
54
+ static isRunnable(thing: any): boolean;
55
+ }
@@ -1,69 +1,69 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.Runnable = void 0
7
- /**
8
- * @file Runnable class recipe.
9
- * @author Joshua Heagle <joshuaheagle@gmail.com>
10
- * @version 1.0.0
11
- * @memberOf module:collect-your-stuff
12
- */
13
- /**
14
- * Identify a class that can be run.
15
- */
16
- class Runnable {
17
- /**
18
- * Instantiate a Runnable class.
19
- * @param {*} [data=null] The task (a function) or the data which the task returns.
20
- */
21
- constructor (data = null) {
22
- /** The task (or data) this runnable holds. */
23
- this.data = null
24
- this.data = data
25
- }
26
-
27
- /**
28
- * Retrieve the data which should be formed as a task.
29
- * @return {Function}
30
- */
31
- get task () {
32
- if (typeof this.data === 'function') {
33
- return this.data
34
- }
35
- return () => this.data
36
- }
37
-
38
- /**
39
- * Run the runnable task.
40
- * @return {*}
41
- */
42
- run () {
43
- return this.task()
44
- }
45
-
46
- /**
47
- * Check if a given thing is Runnable
48
- * @memberof Runnable
49
- * @param {*} thing The value to check, or nothing to check whether this class is Runnable.
50
- * @return {boolean}
51
- */
52
- static isRunnable (thing) {
53
- if (typeof thing === 'undefined') {
54
- // No argument past, this class is runnable
55
- return this instanceof Runnable
56
- }
57
- if (typeof thing !== 'object') {
58
- // It is not even an object, so cannot be a class instance
59
- return false
60
- }
61
- if (typeof thing.task !== 'function') {
62
- // It does not have a task getter that returns a function
63
- return false
64
- }
65
- // Finally, it has a runnable 'run' method. This method should return the result of running the task.
66
- return typeof thing.run === 'function'
67
- }
68
- }
69
- exports.Runnable = Runnable
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.Runnable = void 0
7
+ /**
8
+ * @file Runnable class recipe.
9
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
10
+ * @version 1.0.0
11
+ * @memberOf module:collect-your-stuff
12
+ */
13
+ /**
14
+ * Identify a class that can be run.
15
+ */
16
+ class Runnable {
17
+ /**
18
+ * Instantiate a Runnable class.
19
+ * @param {*} [data=null] The task (a function) or the data which the task returns.
20
+ */
21
+ constructor (data = null) {
22
+ /** The task (or data) this runnable holds. */
23
+ this.data = null
24
+ this.data = data
25
+ }
26
+
27
+ /**
28
+ * Retrieve the data which should be formed as a task.
29
+ * @return {Function}
30
+ */
31
+ get task () {
32
+ if (typeof this.data === 'function') {
33
+ return this.data
34
+ }
35
+ return () => this.data
36
+ }
37
+
38
+ /**
39
+ * Run the runnable task.
40
+ * @return {*}
41
+ */
42
+ run () {
43
+ return this.task()
44
+ }
45
+
46
+ /**
47
+ * Check if a given thing is Runnable
48
+ * @memberof Runnable
49
+ * @param {*} thing The value to check, or nothing to check whether this class is Runnable.
50
+ * @return {boolean}
51
+ */
52
+ static isRunnable (thing) {
53
+ if (typeof thing === 'undefined') {
54
+ // No argument past, this class is runnable
55
+ return this instanceof Runnable
56
+ }
57
+ if (typeof thing !== 'object') {
58
+ // It is not even an object, so cannot be a class instance
59
+ return false
60
+ }
61
+ if (typeof thing.task !== 'function') {
62
+ // It does not have a task getter that returns a function
63
+ return false
64
+ }
65
+ // Finally, it has a runnable 'run' method. This method should return the result of running the task.
66
+ return typeof thing.run === 'function'
67
+ }
68
+ }
69
+ exports.Runnable = Runnable
@@ -1,20 +1,20 @@
1
- import { IsTreeNode } from './IsTreeNode';
2
- /**
3
- * Class TreeLinkerIterator returns the next value taking a left-first approach down a tree.
4
- */
5
- export declare class TreeLinkerIterator implements Iterator<IsTreeNode> {
6
- private current;
7
- private readonly boundaryParent;
8
- /**
9
- * Create an iterator starting at the given item.
10
- * @param {IsTreeNode} current The item to start from.
11
- * @param {IsTreeNode|null} [boundaryParent] The parent of the nodes to stay within (null for the top of a tree), the whole tree when not given.
12
- */
13
- constructor(current: IsTreeNode, boundaryParent?: IsTreeNode | null);
14
- /**
15
- * Get the current item and move on to the following one (left-first, down each branch).
16
- * @param {*} [value] Not used, present to match the Iterator interface.
17
- * @return {IteratorResult<IsTreeNode>} The current item, or done when there are no more.
18
- */
19
- next(value?: any): IteratorResult<IsTreeNode>;
20
- }
1
+ import { IsTreeNode } from './IsTreeNode';
2
+ /**
3
+ * Class TreeLinkerIterator returns the next value taking a left-first approach down a tree.
4
+ */
5
+ export declare class TreeLinkerIterator implements Iterator<IsTreeNode> {
6
+ private current;
7
+ private readonly boundaryParent;
8
+ /**
9
+ * Create an iterator starting at the given item.
10
+ * @param {IsTreeNode} current The item to start from.
11
+ * @param {IsTreeNode|null} [boundaryParent] The parent of the nodes to stay within (null for the top of a tree), the whole tree when not given.
12
+ */
13
+ constructor(current: IsTreeNode, boundaryParent?: IsTreeNode | null);
14
+ /**
15
+ * Get the current item and move on to the following one (left-first, down each branch).
16
+ * @param {*} [value] Not used, present to match the Iterator interface.
17
+ * @return {IteratorResult<IsTreeNode>} The current item, or done when there are no more.
18
+ */
19
+ next(value?: any): IteratorResult<IsTreeNode>;
20
+ }
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', {
4
4
  value: true
5
5
  })
6
6
  exports.TreeLinkerIterator = void 0
7
- var _parseTreeNext = require('../services/parseTreeNext')
7
+ const _parseTreeNext = require('../services/parseTreeNext')
8
8
  /**
9
9
  * Class TreeLinkerIterator returns the next value taking a left-first approach down a tree.
10
10
  */
@@ -1,15 +1,15 @@
1
- /**
2
- * @file sample classes which follow a pattern (have certain members or methods).
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.0.0
5
- * @memberOf module:collect-your-stuff
6
- */
7
- import { ArrayIterator } from './ArrayIterator';
8
- import { Runnable } from './Runnable';
9
- /**
10
- * List of class declarations that can be used to specify attributes for a style of object / class.
11
- */
12
- export declare const recipes: {
13
- ArrayIterator: typeof ArrayIterator;
14
- Runnable: typeof Runnable;
15
- };
1
+ /**
2
+ * @file sample classes which follow a pattern (have certain members or methods).
3
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
4
+ * @version 1.0.0
5
+ * @memberOf module:collect-your-stuff
6
+ */
7
+ import { ArrayIterator } from './ArrayIterator';
8
+ import { Runnable } from './Runnable';
9
+ /**
10
+ * List of class declarations that can be used to specify attributes for a style of object / class.
11
+ */
12
+ export declare const recipes: {
13
+ ArrayIterator: typeof ArrayIterator;
14
+ Runnable: typeof Runnable;
15
+ };
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', {
4
4
  value: true
5
5
  })
6
6
  exports.recipes = void 0
7
- var _ArrayIterator = require('./ArrayIterator')
8
- var _Runnable = require('./Runnable')
7
+ const _ArrayIterator = require('./ArrayIterator')
8
+ const _Runnable = require('./Runnable')
9
9
  /**
10
10
  * @file sample classes which follow a pattern (have certain members or methods).
11
11
  * @author Joshua Heagle <joshuaheagle@gmail.com>
@@ -1,9 +1,9 @@
1
- import { forEachCallback } from '../recipes/IsArrayable';
2
- import { IsTree } from '../recipes/IsTree';
3
- /**
4
- * Loop over all the nodes in a tree starting from left and apply a callback for each
5
- * @param {IsArrayable<IsTreeNode>} tree
6
- * @param {forEachCallback} callback
7
- * @returns {IsArrayable<IsTreeNode>}
8
- */
9
- export declare const parseTree: (tree: IsTree, callback: forEachCallback) => IsTree;
1
+ import { forEachCallback } from '../recipes/IsArrayable';
2
+ import { IsTree } from '../recipes/IsTree';
3
+ /**
4
+ * Loop over all the nodes in a tree starting from left and apply a callback for each
5
+ * @param {IsArrayable<IsTreeNode>} tree
6
+ * @param {forEachCallback} callback
7
+ * @returns {IsArrayable<IsTreeNode>}
8
+ */
9
+ export declare const parseTree: (tree: IsTree, callback: forEachCallback) => IsTree;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', {
4
4
  value: true
5
5
  })
6
6
  exports.parseTree = void 0
7
- var _parseTreeNext = require('./parseTreeNext')
7
+ const _parseTreeNext = require('./parseTreeNext')
8
8
  /**
9
9
  * Loop over all the nodes in a tree starting from left and apply a callback for each
10
10
  * @param {IsArrayable<IsTreeNode>} tree
@@ -1,17 +1,17 @@
1
- import { IsTreeNode } from '../recipes/IsTreeNode';
2
- /**
3
- * Be able to parse over every node in a tree.
4
- * 1. Start at root (get root parent)
5
- * 2. Get first child (repeat until no children)
6
- * 3. Check next child
7
- * 4. Repeat 2
8
- * 5. Repeat 3
9
- * 6. If no next child, return to parent and repeat 3
10
- * 7. Stop at root (next is null and parent is null
11
- * A boundary can be given to parse only part of a tree: going back up to the parents stops at the boundary, so the
12
- * parsing stays within the nodes whose parent is the boundary (and everything below them).
13
- * @param {IsTreeNode} treeNode Provide a node in a tree and get the next node (left-first approach)
14
- * @param {IsTreeNode|null} [boundaryParent] The parent of the nodes to stay within, null for the nodes at the top of a tree. When it is not given the whole tree is parsed.
15
- * @returns {IsTreeNode|null}
16
- */
17
- export declare const parseTreeNext: (treeNode: IsTreeNode, boundaryParent?: IsTreeNode | null) => IsTreeNode | null;
1
+ import { IsTreeNode } from '../recipes/IsTreeNode';
2
+ /**
3
+ * Be able to parse over every node in a tree.
4
+ * 1. Start at root (get root parent)
5
+ * 2. Get first child (repeat until no children)
6
+ * 3. Check next child
7
+ * 4. Repeat 2
8
+ * 5. Repeat 3
9
+ * 6. If no next child, return to parent and repeat 3
10
+ * 7. Stop at root (next is null and parent is null
11
+ * A boundary can be given to parse only part of a tree: going back up to the parents stops at the boundary, so the
12
+ * parsing stays within the nodes whose parent is the boundary (and everything below them).
13
+ * @param {IsTreeNode} treeNode Provide a node in a tree and get the next node (left-first approach)
14
+ * @param {IsTreeNode|null} [boundaryParent] The parent of the nodes to stay within, null for the nodes at the top of a tree. When it is not given the whole tree is parsed.
15
+ * @returns {IsTreeNode|null}
16
+ */
17
+ export declare const parseTreeNext: (treeNode: IsTreeNode, boundaryParent?: IsTreeNode | null) => IsTreeNode | null;
@@ -1,42 +1,42 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.parseTreeNext = void 0
7
- /**
8
- * Be able to parse over every node in a tree.
9
- * 1. Start at root (get root parent)
10
- * 2. Get first child (repeat until no children)
11
- * 3. Check next child
12
- * 4. Repeat 2
13
- * 5. Repeat 3
14
- * 6. If no next child, return to parent and repeat 3
15
- * 7. Stop at root (next is null and parent is null
16
- * A boundary can be given to parse only part of a tree: going back up to the parents stops at the boundary, so the
17
- * parsing stays within the nodes whose parent is the boundary (and everything below them).
18
- * @param {IsTreeNode} treeNode Provide a node in a tree and get the next node (left-first approach)
19
- * @param {IsTreeNode|null} [boundaryParent] The parent of the nodes to stay within, null for the nodes at the top of a tree. When it is not given the whole tree is parsed.
20
- * @returns {IsTreeNode|null}
21
- */
22
- const parseTreeNext = (treeNode, boundaryParent) => {
23
- if (!treeNode) {
24
- return null
25
- }
26
- if (treeNode.children && treeNode.children.length) {
27
- return treeNode.children.first
28
- }
29
- if (treeNode.next) {
30
- return treeNode.next
31
- }
32
- // Nothing more below or beside this node, so go back up until there is a node which has a next (or the boundary)
33
- let parent = treeNode.parent
34
- while (parent && parent !== boundaryParent) {
35
- if (parent.next) {
36
- return parent.next
37
- }
38
- parent = parent.parent
39
- }
40
- return null
41
- }
42
- exports.parseTreeNext = parseTreeNext
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.parseTreeNext = void 0
7
+ /**
8
+ * Be able to parse over every node in a tree.
9
+ * 1. Start at root (get root parent)
10
+ * 2. Get first child (repeat until no children)
11
+ * 3. Check next child
12
+ * 4. Repeat 2
13
+ * 5. Repeat 3
14
+ * 6. If no next child, return to parent and repeat 3
15
+ * 7. Stop at root (next is null and parent is null
16
+ * A boundary can be given to parse only part of a tree: going back up to the parents stops at the boundary, so the
17
+ * parsing stays within the nodes whose parent is the boundary (and everything below them).
18
+ * @param {IsTreeNode} treeNode Provide a node in a tree and get the next node (left-first approach)
19
+ * @param {IsTreeNode|null} [boundaryParent] The parent of the nodes to stay within, null for the nodes at the top of a tree. When it is not given the whole tree is parsed.
20
+ * @returns {IsTreeNode|null}
21
+ */
22
+ const parseTreeNext = (treeNode, boundaryParent) => {
23
+ if (!treeNode) {
24
+ return null
25
+ }
26
+ if (treeNode.children && treeNode.children.length) {
27
+ return treeNode.children.first
28
+ }
29
+ if (treeNode.next) {
30
+ return treeNode.next
31
+ }
32
+ // Nothing more below or beside this node, so go back up until there is a node which has a next (or the boundary)
33
+ let parent = treeNode.parent
34
+ while (parent && parent !== boundaryParent) {
35
+ if (parent.next) {
36
+ return parent.next
37
+ }
38
+ parent = parent.parent
39
+ }
40
+ return null
41
+ }
42
+ exports.parseTreeNext = parseTreeNext
@@ -1,13 +1,13 @@
1
- /**
2
- * @file some useful resources when working with collections.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.1.0
5
- * @memberOf module:collect-your-stuff
6
- */
7
- /**
8
- * List helpful functions when dealing with collections.
9
- */
10
- export declare const services: {
11
- parseTree: (tree: import("../main").IsTree, callback: import("../main").forEachCallback) => import("../main").IsTree;
12
- parseTreeNext: (treeNode: import("../main").IsTreeNode, boundaryParent?: import("../main").IsTreeNode | null) => import("../main").IsTreeNode | null;
13
- };
1
+ /**
2
+ * @file some useful resources when working with collections.
3
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
4
+ * @version 1.1.0
5
+ * @memberOf module:collect-your-stuff
6
+ */
7
+ /**
8
+ * List helpful functions when dealing with collections.
9
+ */
10
+ export declare const services: {
11
+ parseTree: (tree: import("../main").IsTree, callback: import("../main").forEachCallback) => import("../main").IsTree;
12
+ parseTreeNext: (treeNode: import("../main").IsTreeNode, boundaryParent?: import("../main").IsTreeNode | null) => import("../main").IsTreeNode | null;
13
+ };
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', {
4
4
  value: true
5
5
  })
6
6
  exports.services = void 0
7
- var _parseTree = require('./parseTree')
8
- var _parseTreeNext = require('./parseTreeNext')
7
+ const _parseTree = require('./parseTree')
8
+ const _parseTreeNext = require('./parseTreeNext')
9
9
  /**
10
10
  * @file some useful resources when working with collections.
11
11
  * @author Joshua Heagle <joshuaheagle@gmail.com>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "collect-your-stuff",
3
3
  "description": "Use a variety of collections to collect your stuff when building code.",
4
- "version": "2.1.0",
4
+ "version": "2.1.2",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",
7
7
  "author": "Joshua Heagle",
@@ -25,7 +25,7 @@
25
25
  "watch:test": "gulp watchTest"
26
26
  },
27
27
  "devDependencies": {
28
- "js-build-tools": "^4.1.1"
28
+ "js-build-tools": "^5.2.0"
29
29
  },
30
30
  "repository": {
31
31
  "type": "git",