From 65679759d530e9cecb59c0cd51b26a966e1edc27 Mon Sep 17 00:00:00 2001 From: Dylan Nugent Date: Tue, 9 Jul 2024 17:00:05 -0500 Subject: [PATCH] Add support for array --- src/main.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 9a1846b..a23746f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -75,6 +75,22 @@ export default class Jinter { } return 'proceed'; }); + this.visitor.on('Array', (node, visitor) => { + if (node.type === 'Identifier') + return Array; + + if (node.type === 'CallExpression' && node.callee.type === 'MemberExpression') { + const prop: keyof typeof Array = visitor.visitNode(node.callee.property); + const args = node.arguments.map((arg) => visitor.visitNode(arg)); + const array_prop = Array[prop] as Function; + + if (!array_prop) + return 'proceed'; + + return array_prop(args); + } return 'proceed'; + }); + this.visitor.on('Date', (node) => { if (node.type === 'Identifier') return Date; @@ -88,4 +104,4 @@ export default class Jinter { public interpret() { return this.visitor.run(); } -} \ No newline at end of file +}