INNER CODE UNIT · JavaScript

visit

graphql-community/koa-graphql · resources/load-statically-from-npm.js:17

  return function visit(node) {
    if (ts.isCallExpression(node)) {
      if (
        ts.isIdentifier(node.expression) &&
        node.expression.text === 'loadFileStaticallyFromNPM'
      ) {
        const npmPath = node.arguments[0].text;
        const filePath = require.resolve(npmPath);
        const content = fs.readFileSync(filePath, 'utf-8');
        return ts.createStringLiteral(content);
      }
    }
    return ts.visitEachChild(node, visit, context);
  };
};

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…