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 +}