UNPKG

typedconverter

Version:

Convert object into classes match with TypeScript type annotation

36 lines (35 loc) 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pipe = void 0; class ExtensionInvocationImpl { constructor(ext, next) { this.ext = ext; this.next = next; this.value = next.value; this.type = next.type; this.path = next.path; this.decorators = next.decorators; this.parent = next.parent; } proceed() { return this.ext(this.next); } } class VisitorInvocationImpl { constructor(value, path, ast, decorators, visitor, parent) { this.ast = ast; this.visitor = visitor; this.value = value; this.type = ast.type; this.path = path; this.decorators = decorators; this.parent = parent; } proceed() { return this.visitor(); } } function pipe(value, strPath, ast, decorators, extensions, visitor, parent) { return extensions.reduce((prev, cur) => new ExtensionInvocationImpl(cur, prev), new VisitorInvocationImpl(value, strPath, ast, decorators, visitor, parent)); } exports.pipe = pipe;