How to use the regenerator/node_modules/recast.Visitor function in regenerator

To help you get started, we’ve selected a few regenerator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github metascript / metascript / lib / build-regenerator-runtime.js View on Github external
// It allows to merge it directly into the generated program
// to avoid breaking source maps.

var fs = require('fs');

var regenerator = require('regenerator');
// HACK: Use recast from regenerator's deps
var recast = require('regenerator/node_modules/recast');

var runtime = fs.readFileSync(regenerator.runtime.min, "utf-8");
var body = recast.parse(runtime, {
  sourceFileName: regenerator.runtime.min,
}).program.body;

// Reduce source maps size by removing location information
var StripLoc = recast.Visitor.extend({
  visit: function (node) {
    this.genericVisit(node);
    node.loc = null;
    return node;
  }
});
(new StripLoc).visit(body);

fs.writeFileSync('./lib/regenerator-runtime.json', JSON.stringify(body[0]))

regenerator

Source transformer enabling ECMAScript 6 generator functions (yield) in JavaScript-of-today (ES5)

MIT
Latest version published 1 year ago

Package Health Score

59 / 100
Full package analysis