collect-your-stuff 2.1.1 → 2.2.0
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.
- package/README.md +32 -3241
- package/browser/collect-your-stuff.js +1585 -1193
- package/browser/collect-your-stuff.min.js +1 -1
- package/dist/collections/arrayable/ArrayElement.d.ts +33 -38
- package/dist/collections/arrayable/ArrayElement.js +64 -66
- package/dist/collections/arrayable/Arrayable.d.ts +107 -122
- package/dist/collections/arrayable/Arrayable.js +208 -223
- package/dist/collections/doubly-linked-list/DoubleLinker.d.ts +45 -50
- package/dist/collections/doubly-linked-list/DoubleLinker.js +71 -73
- package/dist/collections/doubly-linked-list/DoublyLinkedList.d.ts +108 -125
- package/dist/collections/doubly-linked-list/DoublyLinkedList.js +310 -327
- package/dist/collections/linked-list/LinkedList.d.ts +110 -126
- package/dist/collections/linked-list/LinkedList.js +283 -296
- package/dist/collections/linked-list/Linker.d.ts +41 -46
- package/dist/collections/linked-list/Linker.js +82 -84
- package/dist/collections/linked-tree-list/LinkedTreeList.d.ts +140 -159
- package/dist/collections/linked-tree-list/LinkedTreeList.js +274 -294
- package/dist/collections/linked-tree-list/TreeLinker.d.ts +65 -71
- package/dist/collections/linked-tree-list/TreeLinker.js +91 -94
- package/dist/collections/queue/Queue.d.ts +55 -59
- package/dist/collections/queue/Queue.js +114 -119
- package/dist/collections/queue/Queueable.d.ts +74 -83
- package/dist/collections/queue/Queueable.js +142 -146
- package/dist/collections/queue/TaskQueue.d.ts +59 -68
- package/dist/collections/queue/TaskQueue.js +128 -137
- package/dist/collections/scoped-collection/ScopedCollection.d.ts +42 -0
- package/dist/collections/scoped-collection/ScopedCollection.js +81 -0
- package/dist/collections/scoped-collection/ScopedCollection.min.js +1 -0
- package/dist/collections/stack/Stack.d.ts +60 -64
- package/dist/collections/stack/Stack.js +122 -127
- package/dist/collections/stack/Stackable.d.ts +52 -59
- package/dist/collections/stack/Stackable.js +81 -85
- package/dist/collections/stack/TaskStack.d.ts +56 -65
- package/dist/collections/stack/TaskStack.js +98 -107
- package/dist/main.d.ts +4 -5
- package/dist/main.js +9 -5
- package/dist/main.min.js +1 -1
- package/dist/recipes/ArrayIterator.d.ts +20 -20
- package/dist/recipes/ArrayIterator.js +39 -39
- package/dist/recipes/DoubleLinkerIterator.d.ts +18 -18
- package/dist/recipes/DoubleLinkerIterator.js +33 -33
- package/dist/recipes/IsArrayable.d.ts +85 -105
- package/dist/recipes/IsArrayable.js +5 -5
- package/dist/recipes/IsDoubleLinker.d.ts +14 -14
- package/dist/recipes/IsDoubleLinker.js +5 -5
- package/dist/recipes/IsElement.d.ts +14 -14
- package/dist/recipes/IsElement.js +5 -5
- package/dist/recipes/IsLinker.d.ts +10 -10
- package/dist/recipes/IsLinker.js +5 -5
- package/dist/recipes/IsQueue.d.ts +32 -37
- package/dist/recipes/IsQueue.js +5 -5
- package/dist/recipes/IsScopedCollection.d.ts +27 -0
- package/dist/recipes/IsScopedCollection.js +5 -0
- package/dist/recipes/IsScopedCollection.min.js +1 -0
- package/dist/recipes/IsStack.d.ts +31 -36
- package/dist/recipes/IsStack.js +5 -5
- package/dist/recipes/IsTree.d.ts +11 -11
- package/dist/recipes/IsTree.js +5 -5
- package/dist/recipes/IsTreeNode.d.ts +29 -29
- package/dist/recipes/IsTreeNode.js +5 -5
- package/dist/recipes/LinkerIterator.d.ts +18 -18
- package/dist/recipes/LinkerIterator.js +33 -33
- package/dist/recipes/Runnable.d.ts +42 -55
- package/dist/recipes/Runnable.js +63 -69
- package/dist/recipes/TreeLinkerIterator.d.ts +20 -20
- package/dist/recipes/TreeLinkerIterator.js +36 -36
- package/dist/recipes/recipes.d.ts +12 -15
- package/dist/recipes/recipes.js +19 -22
- package/dist/services/parseTree.d.ts +8 -9
- package/dist/services/parseTree.js +23 -24
- package/dist/services/parseTreeNext.d.ts +16 -17
- package/dist/services/parseTreeNext.js +41 -42
- package/dist/services/services.d.ts +10 -13
- package/dist/services/services.js +19 -22
- package/package.json +4 -4
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.parseTree = void 0
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Loop over all the nodes in a tree starting from left and apply a callback for each
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
exports.parseTree = parseTree
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.parseTree = void 0
|
|
7
|
+
const _parseTreeNext = require('./parseTreeNext')
|
|
8
|
+
/**
|
|
9
|
+
* Loop over all the nodes in a tree starting from left and apply a callback for each
|
|
10
|
+
* @param tree
|
|
11
|
+
* @param callback
|
|
12
|
+
*/
|
|
13
|
+
const parseTree = (tree, callback) => {
|
|
14
|
+
let index = 0
|
|
15
|
+
let current = tree.rootParent
|
|
16
|
+
while (current !== null) {
|
|
17
|
+
callback(current, index, tree)
|
|
18
|
+
current = (0, _parseTreeNext.parseTreeNext)(current)
|
|
19
|
+
++index
|
|
20
|
+
}
|
|
21
|
+
return tree
|
|
22
|
+
}
|
|
23
|
+
exports.parseTree = parseTree
|
|
@@ -1,17 +1,16 @@
|
|
|
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
|
|
14
|
-
* @param
|
|
15
|
-
|
|
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 treeNode Provide a node in a tree and get the next node (left-first approach)
|
|
14
|
+
* @param 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
|
+
*/
|
|
16
|
+
export declare const parseTreeNext: (treeNode: IsTreeNode, boundaryParent?: IsTreeNode | null) => IsTreeNode | null;
|
|
@@ -1,42 +1,41 @@
|
|
|
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
|
|
19
|
-
* @param
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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 treeNode Provide a node in a tree and get the next node (left-first approach)
|
|
19
|
+
* @param 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
|
+
*/
|
|
21
|
+
const parseTreeNext = (treeNode, boundaryParent) => {
|
|
22
|
+
if (!treeNode) {
|
|
23
|
+
return null
|
|
24
|
+
}
|
|
25
|
+
if (treeNode.children && treeNode.children.length) {
|
|
26
|
+
return treeNode.children.first
|
|
27
|
+
}
|
|
28
|
+
if (treeNode.next) {
|
|
29
|
+
return treeNode.next
|
|
30
|
+
}
|
|
31
|
+
// Nothing more below or beside this node, so go back up until there is a node which has a next (or the boundary)
|
|
32
|
+
let parent = treeNode.parent
|
|
33
|
+
while (parent && parent !== boundaryParent) {
|
|
34
|
+
if (parent.next) {
|
|
35
|
+
return parent.next
|
|
36
|
+
}
|
|
37
|
+
parent = parent.parent
|
|
38
|
+
}
|
|
39
|
+
return null
|
|
40
|
+
}
|
|
41
|
+
exports.parseTreeNext = parseTreeNext
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+
* some useful resources when working with collections.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* List helpful functions when dealing with collections.
|
|
6
|
+
*/
|
|
7
|
+
export declare const services: {
|
|
8
|
+
parseTree: (tree: import("../main").IsTree, callback: import("../main").forEachCallback) => import("../main").IsTree;
|
|
9
|
+
parseTreeNext: (treeNode: import("../main").IsTreeNode, boundaryParent?: import("../main").IsTreeNode | null) => import("../main").IsTreeNode | null;
|
|
10
|
+
};
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.services = void 0
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
parseTree: _parseTree.parseTree,
|
|
21
|
-
parseTreeNext: _parseTreeNext.parseTreeNext
|
|
22
|
-
}
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.services = void 0
|
|
7
|
+
const _parseTree = require('./parseTree')
|
|
8
|
+
const _parseTreeNext = require('./parseTreeNext')
|
|
9
|
+
/**
|
|
10
|
+
* some useful resources when working with collections.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* List helpful functions when dealing with collections.
|
|
15
|
+
*/
|
|
16
|
+
const services = exports.services = {
|
|
17
|
+
parseTree: _parseTree.parseTree,
|
|
18
|
+
parseTreeNext: _parseTreeNext.parseTreeNext
|
|
19
|
+
}
|
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.
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"types": "dist/main.d.ts",
|
|
7
7
|
"author": "Joshua Heagle",
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "gulp build",
|
|
18
18
|
"dev": "gulp",
|
|
19
|
-
"
|
|
20
|
-
"readme": "gulp readme",
|
|
19
|
+
"docs": "gulp docs",
|
|
21
20
|
"test": "gulp testFull",
|
|
22
21
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
23
22
|
"test:quick": "gulp testQuick",
|
|
@@ -25,7 +24,8 @@
|
|
|
25
24
|
"watch:test": "gulp watchTest"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
|
-
"js-build-tools": "^
|
|
27
|
+
"js-build-tools": "^5.3.2",
|
|
28
|
+
"typedoc": "^0.28.20"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|