@weborigami/origami 0.5.3 → 0.5.5
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/index.ts +0 -4
- package/main.js +20 -3
- package/package.json +4 -4
- package/src/builtinsProgram.js +1 -10
- package/src/common/documentObject.js +2 -2
- package/src/common/loadJsDom.js +13 -0
- package/src/common/utilities.d.ts +0 -1
- package/src/common/utilities.js +0 -36
- package/src/dev/ExplorableSiteTransform.js +0 -4
- package/src/dev/changes.js +10 -5
- package/src/dev/code.js +1 -6
- package/src/dev/copy.js +4 -8
- package/src/dev/crawler/audit.js +8 -8
- package/src/dev/crawler/crawl.js +3 -5
- package/src/dev/crawler/findPaths.js +9 -3
- package/src/dev/crawler/pathsInHtml.js +4 -3
- package/src/dev/debug.js +4 -7
- package/src/dev/dev.js +4 -2
- package/src/dev/explore.js +4 -3
- package/src/dev/help.js +0 -4
- package/src/dev/help.yaml +14 -13
- package/src/dev/log.js +1 -2
- package/src/dev/serve.js +5 -18
- package/src/dev/treeDot.js +5 -6
- package/src/dev/watch.js +8 -12
- package/src/handlers/csv.handler.js +3 -0
- package/src/handlers/oridocument.handler.js +1 -1
- package/src/origami/csv.js +1 -5
- package/src/origami/document.js +2 -5
- package/src/origami/htmlDom.js +3 -2
- package/src/origami/image/format.js +0 -5
- package/src/origami/image/resize.js +0 -3
- package/src/origami/inline.js +3 -8
- package/src/origami/json.js +2 -6
- package/src/origami/jsonKeys.js +4 -10
- package/src/origami/mdHtml.js +5 -5
- package/src/origami/once.js +3 -7
- package/src/origami/ori.js +5 -0
- package/src/origami/origami.js +1 -2
- package/src/origami/pack.js +0 -5
- package/src/origami/post.js +4 -3
- package/src/origami/rss.js +7 -8
- package/src/origami/sitemap.js +5 -7
- package/src/origami/static.js +5 -7
- package/src/origami/string.js +0 -4
- package/src/origami/unpack.js +0 -5
- package/src/protocols/explore.js +0 -2
- package/src/protocols/httpstree.js +0 -2
- package/src/protocols/httptree.js +0 -2
- package/src/protocols/package.js +2 -2
- package/src/server/constructResponse.js +2 -2
- package/src/server/server.js +2 -33
- package/src/common/ConstantTree.js +0 -18
- package/src/protocols/js.js +0 -13
- package/src/tree/addNextPrevious.js +0 -22
- package/src/tree/cache.js +0 -22
- package/src/tree/calendar.js +0 -1
- package/src/tree/clear.js +0 -19
- package/src/tree/concat.js +0 -17
- package/src/tree/constant.js +0 -1
- package/src/tree/deepMap.js +0 -32
- package/src/tree/deepMerge.js +0 -18
- package/src/tree/deepReverse.js +0 -23
- package/src/tree/deepTake.js +0 -26
- package/src/tree/deepValues.js +0 -22
- package/src/tree/defineds.js +0 -30
- package/src/tree/filter.js +0 -19
- package/src/tree/first.js +0 -19
- package/src/tree/fromFn.js +0 -29
- package/src/tree/globKeys.js +0 -19
- package/src/tree/group.js +0 -26
- package/src/tree/inners.js +0 -30
- package/src/tree/keys.js +0 -15
- package/src/tree/length.js +0 -15
- package/src/tree/map.d.ts +0 -11
- package/src/tree/map.js +0 -125
- package/src/tree/mask.js +0 -19
- package/src/tree/match.js +0 -79
- package/src/tree/merge.js +0 -41
- package/src/tree/paginate.js +0 -20
- package/src/tree/parent.js +0 -15
- package/src/tree/plain.js +0 -15
- package/src/tree/regExpKeys.js +0 -19
- package/src/tree/reverse.js +0 -17
- package/src/tree/setDeep.js +0 -49
- package/src/tree/shuffle.js +0 -57
- package/src/tree/sort.js +0 -52
- package/src/tree/take.js +0 -19
- package/src/tree/tree.js +0 -52
- package/src/tree/values.js +0 -15
package/src/tree/match.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Tree } from "@weborigami/async-tree";
|
|
2
|
-
import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Return a tree with the indicated keys (if provided).
|
|
6
|
-
*
|
|
7
|
-
* The pattern can a string with a simplified pattern syntax that tries to match
|
|
8
|
-
* against the entire key and uses brackets to identify named wildcard values.
|
|
9
|
-
* E.g. `[name].html` will match `Alice.html` with wildcard values { name:
|
|
10
|
-
* "Alice" }.
|
|
11
|
-
*
|
|
12
|
-
* The pattern can also be a JavaScript regular expression.
|
|
13
|
-
*
|
|
14
|
-
* If a key is requested, match against the given pattern and, if matches,
|
|
15
|
-
* invokes the given function with an object containing the matched values.
|
|
16
|
-
*
|
|
17
|
-
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
18
|
-
* @typedef {import("@weborigami/async-tree").Treelike} Treelike
|
|
19
|
-
* @typedef {import("../../index.ts").Invocable} Invocable
|
|
20
|
-
*
|
|
21
|
-
* @this {AsyncTree|null}
|
|
22
|
-
* @param {string|RegExp} pattern
|
|
23
|
-
* @param {Invocable} resultFn
|
|
24
|
-
* @param {Treelike} [keys]
|
|
25
|
-
*/
|
|
26
|
-
export default function match(pattern, resultFn, keys = []) {
|
|
27
|
-
assertTreeIsDefined(this, "match");
|
|
28
|
-
let regex;
|
|
29
|
-
if (typeof pattern === "string") {
|
|
30
|
-
// Convert the simple pattern format into a regular expression.
|
|
31
|
-
const regexText = pattern.replace(
|
|
32
|
-
/\[(?<variable>.+)\]/g,
|
|
33
|
-
(match, p1, offset, string, groups) => `(?<${groups.variable}>.+)`
|
|
34
|
-
);
|
|
35
|
-
regex = new RegExp(`^${regexText}$`);
|
|
36
|
-
} else if (pattern instanceof RegExp) {
|
|
37
|
-
regex = pattern;
|
|
38
|
-
} else {
|
|
39
|
-
throw new Error(`match(): Unsupported pattern`);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const tree = this;
|
|
43
|
-
|
|
44
|
-
const result = {
|
|
45
|
-
async get(key) {
|
|
46
|
-
const keyMatch = regex.exec(key);
|
|
47
|
-
if (!keyMatch) {
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
typeof resultFn !== "function" &&
|
|
53
|
-
!(Tree.isAsyncTree(resultFn) && "parent" in resultFn)
|
|
54
|
-
) {
|
|
55
|
-
// Simple return value; return as is
|
|
56
|
-
return resultFn;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Copy the `groups` property to a real object
|
|
60
|
-
const matches = { ...keyMatch.groups };
|
|
61
|
-
|
|
62
|
-
// Invoke the result function with the extended scope.
|
|
63
|
-
let value;
|
|
64
|
-
if (typeof resultFn === "function") {
|
|
65
|
-
value = await resultFn.call(this, matches);
|
|
66
|
-
} else {
|
|
67
|
-
value = Object.create(resultFn);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return value;
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
async keys() {
|
|
74
|
-
return typeof keys === "function" ? await keys.call(tree) : keys;
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
return result;
|
|
79
|
-
}
|
package/src/tree/merge.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { isPlainObject, isUnpackable, merge } from "@weborigami/async-tree";
|
|
2
|
-
import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Create a tree that's the result of merging the given trees.
|
|
6
|
-
*
|
|
7
|
-
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
8
|
-
* @typedef {import("@weborigami/async-tree").Treelike} Treelike
|
|
9
|
-
*
|
|
10
|
-
* @this {AsyncTree|null}
|
|
11
|
-
* @param {(Treelike|null)[]} trees
|
|
12
|
-
*/
|
|
13
|
-
export default async function treeMerge(...trees) {
|
|
14
|
-
assertTreeIsDefined(this, "merge");
|
|
15
|
-
|
|
16
|
-
// Filter out null or undefined trees.
|
|
17
|
-
/** @type {Treelike[]}
|
|
18
|
-
* @ts-ignore */
|
|
19
|
-
const filtered = trees.filter((tree) => tree);
|
|
20
|
-
|
|
21
|
-
if (filtered.length === 1) {
|
|
22
|
-
// Only one tree, no need to merge.
|
|
23
|
-
return filtered[0];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Unpack any packed objects.
|
|
27
|
-
const unpacked = await Promise.all(
|
|
28
|
-
filtered.map((obj) =>
|
|
29
|
-
isUnpackable(obj) ? /** @type {any} */ (obj).unpack() : obj
|
|
30
|
-
)
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
// If all trees are plain objects, return a plain object.
|
|
34
|
-
if (unpacked.every((tree) => isPlainObject(tree))) {
|
|
35
|
-
return merge(...unpacked);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Merge the trees.
|
|
39
|
-
const result = merge(...unpacked);
|
|
40
|
-
return result;
|
|
41
|
-
}
|
package/src/tree/paginate.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { paginate } from "@weborigami/async-tree";
|
|
2
|
-
import getTreeArgument from "../common/getTreeArgument.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Return a new grouping of the treelike's values into chunks of the specified
|
|
6
|
-
* size.
|
|
7
|
-
*
|
|
8
|
-
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
9
|
-
* @typedef {import("@weborigami/async-tree").Treelike} Treelike
|
|
10
|
-
*
|
|
11
|
-
* @this {AsyncTree|null}
|
|
12
|
-
* @param {Treelike} [treelike]
|
|
13
|
-
* @param {number} [size=10]
|
|
14
|
-
*/
|
|
15
|
-
export default async function paginateBuiltin(treelike, size = 10) {
|
|
16
|
-
const tree = await getTreeArgument(this, arguments, treelike, "paginate");
|
|
17
|
-
const paginated = await paginate(tree, size);
|
|
18
|
-
paginated.parent = this;
|
|
19
|
-
return paginated;
|
|
20
|
-
}
|
package/src/tree/parent.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import getTreeArgument from "../common/getTreeArgument.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns the parent of the current tree.
|
|
5
|
-
*
|
|
6
|
-
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
7
|
-
* @typedef {import("@weborigami/async-tree").Treelike} Treelike
|
|
8
|
-
*
|
|
9
|
-
* @this {AsyncTree|null}
|
|
10
|
-
* @param {Treelike} [treelike]
|
|
11
|
-
*/
|
|
12
|
-
export default async function parent(treelike) {
|
|
13
|
-
const tree = await getTreeArgument(this, arguments, treelike, "parent");
|
|
14
|
-
return tree.parent;
|
|
15
|
-
}
|
package/src/tree/plain.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Tree } from "@weborigami/async-tree";
|
|
2
|
-
import getTreeArgument from "../common/getTreeArgument.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Return the interior nodes of the tree.
|
|
6
|
-
*
|
|
7
|
-
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
8
|
-
* @typedef {import("@weborigami/async-tree").Treelike} Treelike
|
|
9
|
-
* @this {AsyncTree|null}
|
|
10
|
-
* @param {Treelike} [treelike]
|
|
11
|
-
*/
|
|
12
|
-
export default async function plain(treelike) {
|
|
13
|
-
const tree = await getTreeArgument(this, arguments, treelike, "plain");
|
|
14
|
-
return Tree.plain(tree);
|
|
15
|
-
}
|
package/src/tree/regExpKeys.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { setParent } from "@weborigami/async-tree";
|
|
2
|
-
import regExpKeys from "@weborigami/async-tree/src/operations/regExpKeys.js";
|
|
3
|
-
import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Define a tree whose keys are regular expression strings.
|
|
7
|
-
*
|
|
8
|
-
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
9
|
-
* @typedef {import("@weborigami/async-tree").Treelike} Treelike
|
|
10
|
-
*
|
|
11
|
-
* @param {Treelike} tree
|
|
12
|
-
* @this {AsyncTree|null}
|
|
13
|
-
*/
|
|
14
|
-
export default async function regExpKeysBuiltin(tree) {
|
|
15
|
-
assertTreeIsDefined(this, "regExpKeys");
|
|
16
|
-
const result = regExpKeys(tree);
|
|
17
|
-
setParent(this, result);
|
|
18
|
-
return result;
|
|
19
|
-
}
|
package/src/tree/reverse.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { reverse } from "@weborigami/async-tree";
|
|
2
|
-
import getTreeArgument from "../common/getTreeArgument.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Reverse the order of the top-level keys in the tree.
|
|
6
|
-
*
|
|
7
|
-
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
8
|
-
* @typedef {import("@weborigami/async-tree").Treelike} Treelike
|
|
9
|
-
*
|
|
10
|
-
* @this {AsyncTree|null}
|
|
11
|
-
* @param {Treelike} [treelike]
|
|
12
|
-
*/
|
|
13
|
-
export default async function reverseBuiltin(treelike) {
|
|
14
|
-
const tree = await getTreeArgument(this, arguments, treelike, "reverse");
|
|
15
|
-
const reversed = reverse(tree);
|
|
16
|
-
return reversed;
|
|
17
|
-
}
|
package/src/tree/setDeep.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Tree } from "@weborigami/async-tree";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {import("@weborigami/async-tree").Treelike} Treelike
|
|
5
|
-
*
|
|
6
|
-
* @this {import("@weborigami/types").AsyncTree|null}
|
|
7
|
-
* @param {Treelike} target
|
|
8
|
-
* @param {Treelike} source
|
|
9
|
-
*/
|
|
10
|
-
export default async function setDeep(target, source) {
|
|
11
|
-
const targetTree = Tree.from(target, { parent: this });
|
|
12
|
-
const sourceTree = Tree.from(source, { parent: this });
|
|
13
|
-
await applyUpdates(sourceTree, targetTree);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Apply all updates from the source to the target.
|
|
17
|
-
async function applyUpdates(source, target) {
|
|
18
|
-
// Fire off requests to update all keys, then wait for all of them to finish.
|
|
19
|
-
const promises = [];
|
|
20
|
-
for (const key of await source.keys()) {
|
|
21
|
-
const updateKeyPromise = applyUpdateForKey(source, target, key);
|
|
22
|
-
promises.push(updateKeyPromise);
|
|
23
|
-
}
|
|
24
|
-
await Promise.all(promises);
|
|
25
|
-
|
|
26
|
-
// HACK: Transforms like KeysTransform that maintain caches will need to
|
|
27
|
-
// recalculate things now that updates have been applied. This should be an
|
|
28
|
-
// automatic part of calling set() -- but triggering those changes inside
|
|
29
|
-
// set() produces cases where set() and get() calls can be interleaved. The
|
|
30
|
-
// atomicity of set() needs to be reconsidered. For now, we work around the
|
|
31
|
-
// problem by triggering `onChange` after the updates have been applied.
|
|
32
|
-
target.onChange?.();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Copy the value for the given key from the source to the target.
|
|
36
|
-
async function applyUpdateForKey(source, target, key) {
|
|
37
|
-
const sourceValue = await source.get(key);
|
|
38
|
-
if (Tree.isAsyncTree(sourceValue)) {
|
|
39
|
-
const targetValue = await target.get(key);
|
|
40
|
-
if (Tree.isAsyncTree(targetValue)) {
|
|
41
|
-
// Both source and target are async dictionaries; recurse.
|
|
42
|
-
await applyUpdates(sourceValue, targetValue);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Copy the value from the source to the target.
|
|
48
|
-
await target.set(key, sourceValue);
|
|
49
|
-
}
|
package/src/tree/shuffle.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import getTreeArgument from "../common/getTreeArgument.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Return a new tree with the original's keys shuffled
|
|
5
|
-
*
|
|
6
|
-
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
7
|
-
* @typedef {import("@weborigami/async-tree").Treelike} Treelike
|
|
8
|
-
*
|
|
9
|
-
* @this {AsyncTree|null}
|
|
10
|
-
* @param {Treelike} [treelike]
|
|
11
|
-
* @param {boolean} [reshuffle]
|
|
12
|
-
*/
|
|
13
|
-
export default async function shuffleTree(treelike, reshuffle = false) {
|
|
14
|
-
// Special case: If the treelike is an array, shuffle it directly. Otherwise
|
|
15
|
-
// we'll end up shuffling the array's indexes, and if this is directly
|
|
16
|
-
// displayed by the ori CLI, this will end up creating a plain object. Even
|
|
17
|
-
// though this object will be created with the keys in the correct shuffled
|
|
18
|
-
// order, a JS object will always return numeric keys in numeric order --
|
|
19
|
-
// undoing the shuffle.
|
|
20
|
-
if (Array.isArray(treelike)) {
|
|
21
|
-
const array = treelike.slice();
|
|
22
|
-
shuffle(array);
|
|
23
|
-
return array;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const tree = await getTreeArgument(this, arguments, treelike, "shuffle");
|
|
27
|
-
|
|
28
|
-
let keys;
|
|
29
|
-
return {
|
|
30
|
-
async get(key) {
|
|
31
|
-
return tree.get(key);
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
async keys() {
|
|
35
|
-
if (!keys || reshuffle) {
|
|
36
|
-
keys = Array.from(await tree.keys());
|
|
37
|
-
shuffle(keys);
|
|
38
|
-
}
|
|
39
|
-
return keys;
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/*
|
|
45
|
-
* Shuffle an array.
|
|
46
|
-
*
|
|
47
|
-
* Performs a Fisher-Yates shuffle. From http://sedition.com/perl/javascript-fy.html
|
|
48
|
-
*/
|
|
49
|
-
export function shuffle(array) {
|
|
50
|
-
let i = array.length;
|
|
51
|
-
while (--i >= 0) {
|
|
52
|
-
const j = Math.floor(Math.random() * (i + 1));
|
|
53
|
-
const temp = array[i];
|
|
54
|
-
array[i] = array[j];
|
|
55
|
-
array[j] = temp;
|
|
56
|
-
}
|
|
57
|
-
}
|
package/src/tree/sort.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { sort as sortTransform } from "@weborigami/async-tree";
|
|
2
|
-
import getTreeArgument from "../common/getTreeArgument.js";
|
|
3
|
-
import { toFunction } from "../common/utilities.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Return a new tree with the original's keys sorted.
|
|
7
|
-
*
|
|
8
|
-
* If the `options` include a `sortKey` function, that will be invoked for each
|
|
9
|
-
* key in the tree to produce a sort key. If no `sortKey` function is provided,
|
|
10
|
-
* the original keys will be used as sort keys.
|
|
11
|
-
*
|
|
12
|
-
* If the `options` include a `compare` function, that will be used to compare
|
|
13
|
-
* sort keys.
|
|
14
|
-
*
|
|
15
|
-
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
16
|
-
* @typedef {import("@weborigami/async-tree").Treelike} Treelike
|
|
17
|
-
* @typedef {import("@weborigami/async-tree").ValueKeyFn} ValueKeyFn
|
|
18
|
-
* @typedef {{ compare?: (a: any, b: any) => number, sortKey?: ValueKeyFn }}
|
|
19
|
-
* SortOptions
|
|
20
|
-
*
|
|
21
|
-
* @this {AsyncTree|null}
|
|
22
|
-
* @param {Treelike} [treelike]
|
|
23
|
-
* @param {SortOptions|ValueKeyFn} [options]
|
|
24
|
-
*/
|
|
25
|
-
export default async function sortBuiltin(treelike, options) {
|
|
26
|
-
const tree = await getTreeArgument(this, arguments, treelike, "sort");
|
|
27
|
-
|
|
28
|
-
if (typeof options === "function") {
|
|
29
|
-
// Take the function as the `sortKey` option
|
|
30
|
-
options = { sortKey: options };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const compare = options?.compare;
|
|
34
|
-
let extendedSortKeyFn;
|
|
35
|
-
if (options?.sortKey) {
|
|
36
|
-
const originalSortKey = toFunction(options?.sortKey);
|
|
37
|
-
const parent = this;
|
|
38
|
-
extendedSortKeyFn = async (key, tree) => {
|
|
39
|
-
const value = await tree.get(key);
|
|
40
|
-
const sortKey = await originalSortKey.call(parent, value, key);
|
|
41
|
-
return sortKey;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const sorted = await sortTransform(tree, {
|
|
46
|
-
compare,
|
|
47
|
-
sortKey: extendedSortKeyFn,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
sorted.parent = this;
|
|
51
|
-
return sorted;
|
|
52
|
-
}
|
package/src/tree/take.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { take as takeTransform } from "@weborigami/async-tree";
|
|
2
|
-
import getTreeArgument from "../common/getTreeArgument.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Given a tree, take the first n items from it.
|
|
6
|
-
*
|
|
7
|
-
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
8
|
-
* @typedef {import("@weborigami/async-tree").Treelike} Treelike
|
|
9
|
-
*
|
|
10
|
-
* @this {AsyncTree|null}
|
|
11
|
-
* @param {Treelike} treelike
|
|
12
|
-
* @param {number} count
|
|
13
|
-
*/
|
|
14
|
-
export default async function take(treelike, count) {
|
|
15
|
-
const tree = await getTreeArgument(this, arguments, treelike, "take");
|
|
16
|
-
const taken = await takeTransform(tree, count);
|
|
17
|
-
taken.parent = this;
|
|
18
|
-
return taken;
|
|
19
|
-
}
|
package/src/tree/tree.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Tree } from "@weborigami/async-tree";
|
|
2
|
-
export { default as addNextPrevious } from "./addNextPrevious.js";
|
|
3
|
-
export { default as cache } from "./cache.js";
|
|
4
|
-
export { default as calendar } from "./calendar.js";
|
|
5
|
-
export { default as clear } from "./clear.js";
|
|
6
|
-
export { default as concat } from "./concat.js";
|
|
7
|
-
export { default as constant } from "./constant.js";
|
|
8
|
-
export { default as deepMap } from "./deepMap.js";
|
|
9
|
-
export { default as deepMerge } from "./deepMerge.js";
|
|
10
|
-
export { default as deepReverse } from "./deepReverse.js";
|
|
11
|
-
export { default as deepTake } from "./deepTake.js";
|
|
12
|
-
export { default as deepValues } from "./deepValues.js";
|
|
13
|
-
export { default as defineds } from "./defineds.js";
|
|
14
|
-
export { default as filter } from "./filter.js";
|
|
15
|
-
export { default as first } from "./first.js";
|
|
16
|
-
export { default as fromFn } from "./fromFn.js";
|
|
17
|
-
export { default as globKeys } from "./globKeys.js";
|
|
18
|
-
export { default as group } from "./group.js";
|
|
19
|
-
export { default as inners } from "./inners.js";
|
|
20
|
-
export { default as keys } from "./keys.js";
|
|
21
|
-
export { default as length } from "./length.js";
|
|
22
|
-
export { default as map } from "./map.js";
|
|
23
|
-
export { default as mask } from "./mask.js";
|
|
24
|
-
export { default as match } from "./match.js";
|
|
25
|
-
export { default as merge } from "./merge.js";
|
|
26
|
-
export { default as paginate } from "./paginate.js";
|
|
27
|
-
export { default as parent } from "./parent.js";
|
|
28
|
-
export { default as plain } from "./plain.js";
|
|
29
|
-
export { default as regExpKeys } from "./regExpKeys.js";
|
|
30
|
-
export { default as reverse } from "./reverse.js";
|
|
31
|
-
export { default as setDeep } from "./setDeep.js";
|
|
32
|
-
export { default as shuffle } from "./shuffle.js";
|
|
33
|
-
export { default as sort } from "./sort.js";
|
|
34
|
-
export { default as take } from "./take.js";
|
|
35
|
-
export { default as values } from "./values.js";
|
|
36
|
-
|
|
37
|
-
export const assign = Tree.assign;
|
|
38
|
-
export const entries = Tree.entries;
|
|
39
|
-
export const forEach = Tree.forEach;
|
|
40
|
-
export const from = Tree.from;
|
|
41
|
-
export const has = Tree.has;
|
|
42
|
-
export const isAsyncMutableTree = Tree.isAsyncMutableTree;
|
|
43
|
-
export const isAsyncTree = Tree.isAsyncTree;
|
|
44
|
-
export const isTraversable = Tree.isTraversable;
|
|
45
|
-
export const isTreelike = Tree.isTreelike;
|
|
46
|
-
export const mapReduce = Tree.mapReduce;
|
|
47
|
-
export const paths = Tree.paths;
|
|
48
|
-
export const remove = Tree.remove;
|
|
49
|
-
export const root = Tree.root;
|
|
50
|
-
export const traverse = Tree.traverse;
|
|
51
|
-
export const traverseOrThrow = Tree.traverseOrThrow;
|
|
52
|
-
export const traversePath = Tree.traversePath;
|
package/src/tree/values.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Tree } from "@weborigami/async-tree";
|
|
2
|
-
import getTreeArgument from "../common/getTreeArgument.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Return the interior nodes of the tree.
|
|
6
|
-
*
|
|
7
|
-
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
8
|
-
* @typedef {import("@weborigami/async-tree").Treelike} Treelike
|
|
9
|
-
* @this {AsyncTree|null}
|
|
10
|
-
* @param {Treelike} [treelike]
|
|
11
|
-
*/
|
|
12
|
-
export default async function values(treelike) {
|
|
13
|
-
const tree = await getTreeArgument(this, arguments, treelike, "values");
|
|
14
|
-
return Tree.values(tree);
|
|
15
|
-
}
|