MCPcopy Index your code
hub / github.com/aiscript-dev/aiscript / nodeToJs

Function nodeToJs

src/utils/node-to-js.ts:4–21  ·  view source on GitHub ↗
(node: Ast.Node)

Source from the content-addressed store, hash-verified

2import type * as Ast from '../node.js';
3
4export function nodeToJs(node: Ast.Node): JsValue {
5 switch (node.type) {
6 case 'arr': return node.value.map(item => nodeToJs(item));
7 case 'bool': return node.value;
8 case 'null': return null;
9 case 'num': return node.value;
10 case 'obj': {
11 const obj: { [keys: string]: JsValue } = {};
12 for (const [k, v] of node.value.entries()) {
13 // TODO: keyが__proto__とかじゃないかチェック
14 obj[k] = nodeToJs(v);
15 }
16 return obj;
17 }
18 case 'str': return node.value;
19 default: return undefined;
20 }
21}

Callers 2

collectMetadataMethod · 0.90
parseMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected