esnode/visitor.js
/**
 * Factory create visitor which analyze each node and
 * update nodes with resolved path.
 *
 * @param options Visitor options.
 * @return Node visitor.
 * @author Oleksandr Dakal <oleksandr-dakal@project-kit.org>
 */
Factory create visitor which analyze each node and
update nodes with resolved path.

@param options Visitor options.
@return Node visitor.
@author Oleksandr Dakal 
Factory create visitor which analyze each node and update nodes with resolved path . @param options Visitor options . @return Node visitor . @author Oleksandr Dakal
function visitorFactory(options) {
    return function visitor(node) {
        if (ts.isCallExpression(node)) {
            if (node.expression.getText() === 'require' && node.arguments.length > 0) {
                const [importArg] = node.arguments;
                if (importArg && ts.isStringLiteral(importArg)) {
                    node = ts.updateCall(node, node.expression, node.typeArguments, [
                        createPathLiteral(Object.assign({}, options, { path: clearPath(importArg.getText()) }))
                    ]);
                }
            }
        }
        else if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
            node = updateDeclaration(node, options);
        }
        return ts.visitEachChild(node, visitor, options.context);
    };
}
function visitorFactory ( options ) { return function visitor ( node ) { if ( ts . isCallExpression ( node ) ) { if ( node . expression . getText ( ) === 'require' && node . arguments . length > 0 ) { const [ importArg ] = node . arguments ; if ( importArg && ts . isStringLiteral ( importArg ) ) { node = ts . updateCall ( node , node . expression , node . typeArguments , [ createPathLiteral ( Object . assign ( { } , options , { path : clearPath ( importArg . getText ( ) ) } ) ) ] ) ; } } } else if ( ts . isImportDeclaration ( node ) || ts . isExportDeclaration ( node ) ) { node = updateDeclaration ( node , options ) ; } return ts . visitEachChild ( node , visitor , options . context ) ; } ; }
Factory create visitor which analyze each node and
 update nodes with resolved path.
Factory create visitor which analyze each node and update nodes with resolved path .
// Visitor which traverse across AST tree. // Resolve require ts syntax. // Resolve only string literal. // Update ES declaration syntax.