@weborigami/origami 0.0.50 → 0.0.51
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/exports/exports.js +3 -3
- package/package.json +4 -4
- package/src/builtins/@groupFn.js +5 -1
- package/src/builtins/{@count.js → @length.js} +2 -5
- package/src/builtins/@mapFn.js +6 -4
- package/src/builtins/@merge.js +21 -1
- package/src/builtins/@regexMatch.js +5 -0
- package/src/misc/treeDot.js +2 -2
- package/src/builtins/@regexParse.js +0 -5
- /package/src/builtins/{@regexParseFn.js → @regexMatchFn.js} +0 -0
package/exports/exports.js
CHANGED
|
@@ -10,7 +10,6 @@ export { default as concat } from "../src/builtins/@concat.js";
|
|
|
10
10
|
export { default as config } from "../src/builtins/@config.js";
|
|
11
11
|
export { default as constructor } from "../src/builtins/@constructor.js";
|
|
12
12
|
export { default as copy } from "../src/builtins/@copy.js";
|
|
13
|
-
export { default as count } from "../src/builtins/@count.js";
|
|
14
13
|
export { default as crawl } from "../src/builtins/@crawl.js";
|
|
15
14
|
export { default as debug } from "../src/builtins/@debug.js";
|
|
16
15
|
export { default as deepMap } from "../src/builtins/@deepMap.js";
|
|
@@ -50,6 +49,7 @@ export { default as json } from "../src/builtins/@json.js";
|
|
|
50
49
|
export { default as jsonParse } from "../src/builtins/@jsonParse.js";
|
|
51
50
|
export { default as keys } from "../src/builtins/@keys.js";
|
|
52
51
|
export { default as keysJson } from "../src/builtins/@keysJson.js";
|
|
52
|
+
export { default as length } from "../src/builtins/@length.js";
|
|
53
53
|
export { default as map } from "../src/builtins/@map.js";
|
|
54
54
|
export { default as mapFn } from "../src/builtins/@mapFn.js";
|
|
55
55
|
export { default as match } from "../src/builtins/@match.js";
|
|
@@ -73,8 +73,8 @@ export { default as perf } from "../src/builtins/@perf.js";
|
|
|
73
73
|
export { default as plain } from "../src/builtins/@plain.js";
|
|
74
74
|
export { default as project } from "../src/builtins/@project.js";
|
|
75
75
|
export { default as redirect } from "../src/builtins/@redirect.js";
|
|
76
|
-
export { default as
|
|
77
|
-
export { default as
|
|
76
|
+
export { default as regexMatch } from "../src/builtins/@regexMatch.js";
|
|
77
|
+
export { default as regexMatchFn } from "../src/builtins/@regexMatchFn.js";
|
|
78
78
|
export { default as repeat } from "../src/builtins/@repeat.js";
|
|
79
79
|
export { default as reverse } from "../src/builtins/@reverse.js";
|
|
80
80
|
export { default as rss } from "../src/builtins/@rss.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weborigami/origami",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.51",
|
|
4
4
|
"description": "Web Origami language, CLI, framework, and server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"typescript": "5.4.5"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@weborigami/async-tree": "0.0.
|
|
21
|
-
"@weborigami/language": "0.0.
|
|
22
|
-
"@weborigami/types": "0.0.
|
|
20
|
+
"@weborigami/async-tree": "0.0.51",
|
|
21
|
+
"@weborigami/language": "0.0.51",
|
|
22
|
+
"@weborigami/types": "0.0.51",
|
|
23
23
|
"exif-parser": "0.1.12",
|
|
24
24
|
"graphviz-wasm": "3.0.2",
|
|
25
25
|
"highlight.js": "11.9.0",
|
package/src/builtins/@groupFn.js
CHANGED
|
@@ -15,9 +15,13 @@ import assertScopeIsDefined from "../misc/assertScopeIsDefined.js";
|
|
|
15
15
|
export default function groupFnBuiltin(groupKey) {
|
|
16
16
|
assertScopeIsDefined(this);
|
|
17
17
|
const scope = this;
|
|
18
|
+
|
|
18
19
|
const groupKeyFn = toFunction(groupKey);
|
|
20
|
+
// Have the group key function run in this scope.
|
|
21
|
+
const extendedGroupKeyFn = groupKeyFn.bind(scope);
|
|
22
|
+
|
|
19
23
|
// @ts-ignore
|
|
20
|
-
const fn = groupFn(
|
|
24
|
+
const fn = groupFn(extendedGroupKeyFn);
|
|
21
25
|
return async (treelike) => {
|
|
22
26
|
const grouped = await fn(treelike);
|
|
23
27
|
const scoped = Scope.treeWithScope(grouped, scope);
|
|
@@ -8,11 +8,8 @@ import getTreeArgument from "../misc/getTreeArgument.js";
|
|
|
8
8
|
* @this {AsyncTree|null}
|
|
9
9
|
* @param {Treelike} [treelike]
|
|
10
10
|
*/
|
|
11
|
-
export default async function
|
|
12
|
-
const tree = await getTreeArgument(this, arguments, treelike, "@
|
|
11
|
+
export default async function length(treelike) {
|
|
12
|
+
const tree = await getTreeArgument(this, arguments, treelike, "@length");
|
|
13
13
|
const keys = Array.from(await tree.keys());
|
|
14
14
|
return keys.length;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
count.usage = `@count <treelike>\tReturn the number of keys in the tree`;
|
|
18
|
-
count.documentation = "https://weborigami.org/cli/@tree.html#count";
|
package/src/builtins/@mapFn.js
CHANGED
|
@@ -33,6 +33,9 @@ export default function mapFnBuiltin(operation) {
|
|
|
33
33
|
if (isPlainObject(operation)) {
|
|
34
34
|
// @ts-ignore
|
|
35
35
|
options = operation;
|
|
36
|
+
if (`value` in options && !options.value) {
|
|
37
|
+
throw new TypeError(`@mapFn: The value function is not defined.`);
|
|
38
|
+
}
|
|
36
39
|
valueFn = options?.value;
|
|
37
40
|
} else if (
|
|
38
41
|
typeof operation === "function" ||
|
|
@@ -57,15 +60,14 @@ export default function mapFnBuiltin(operation) {
|
|
|
57
60
|
);
|
|
58
61
|
}
|
|
59
62
|
|
|
60
|
-
// Extend the value function to include the value and key in scope.
|
|
61
63
|
let extendedValueFn;
|
|
62
64
|
if (valueFn) {
|
|
63
65
|
const resolvedValueFn = toFunction(valueFn);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
// Have the value function run in this scope.
|
|
67
|
+
extendedValueFn = resolvedValueFn.bind(scope);
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
// Extend the
|
|
70
|
+
// Extend the value function to run in scope.
|
|
69
71
|
let extendedKeyFn;
|
|
70
72
|
let extendedInverseKeyFn;
|
|
71
73
|
if (extension) {
|
package/src/builtins/@merge.js
CHANGED
|
@@ -33,7 +33,7 @@ export default async function treeMerge(...trees) {
|
|
|
33
33
|
|
|
34
34
|
// If all trees are plain objects, return a plain object.
|
|
35
35
|
if (unpacked.every((tree) => isPlainObject(tree))) {
|
|
36
|
-
return
|
|
36
|
+
return mergeObjects(...unpacked);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// If a tree can take a scope, give it one that includes the other trees and
|
|
@@ -55,5 +55,25 @@ export default async function treeMerge(...trees) {
|
|
|
55
55
|
return result;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Merge the indicated plain objects. If a key is present in multiple objects,
|
|
60
|
+
* the value from the first object is used.
|
|
61
|
+
*
|
|
62
|
+
* This is similar to calling Object.assign() with the objects in reverse order,
|
|
63
|
+
* but we want to ensure the keys end up in the same order they're encountered
|
|
64
|
+
* in the objects.
|
|
65
|
+
*
|
|
66
|
+
* @param {...any} objects
|
|
67
|
+
*/
|
|
68
|
+
function mergeObjects(...objects) {
|
|
69
|
+
const result = {};
|
|
70
|
+
for (const obj of objects) {
|
|
71
|
+
for (const key of Object.keys(obj)) {
|
|
72
|
+
result[key] ??= obj[key];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
|
|
58
78
|
treeMerge.usage = `@merge <...trees>\tMerge the given trees`;
|
|
59
79
|
treeMerge.documentation = "https://weborigami.org/cli/builtins.html#@merge";
|
package/src/misc/treeDot.js
CHANGED
|
@@ -78,10 +78,10 @@ async function statements(tree, nodePath, nodeLabel, options) {
|
|
|
78
78
|
} else {
|
|
79
79
|
const label = isStringLike(value)
|
|
80
80
|
? String(value)
|
|
81
|
-
: value
|
|
81
|
+
: value !== undefined
|
|
82
82
|
? await serialize.toYaml(value)
|
|
83
83
|
: "";
|
|
84
|
-
if (value
|
|
84
|
+
if (value === undefined) {
|
|
85
85
|
isError = true;
|
|
86
86
|
}
|
|
87
87
|
nodes[key] = { label };
|
|
File without changes
|