strong-trace-transform

1.0.2 • Public • Published

strong-trace-transform

Replace the symantics of require for JavaScript files such that it will call a set of transform functions on the content before requiring it.

Example

var requireTransform = require("strong-trace-transform")
function LogName() {}
LogName.prototype.transform = function transform(content, filename) {
  console.log(filename)
  // keep content intact
  return content
}

requireTransform(new LogName())
require("redis")

API

var requireTransform = require("strong-trace_transform")

requireTransform.replaceCompile(transformer[, fileTest])

Replace the internals of require such that Module._compile runs transformer.transform on any filename that passes fileTest

transformer

Will call transformer.transform(content, filename) and then pass the transformed content to the normal Module._compile.

fileTest(filename)

For the given filename, return true to run the transformer functions, or false to bypass them.

Default fileTest will always return true.

requireTransform.restoreCompile()

Restores the Module._compile to the original.

Package Sidebar

Install

npm i strong-trace-transform

Weekly Downloads

4

Version

1.0.2

License

StrongLoop

Last publish

Collaborators

  • dhmlau
  • 0candy
  • hacksparrow