javascript-injector
v0.7.1
Published
Inject headers, footers, and wrappers into JavaScript source code
Downloads
24
Readme
javascript-injector
Inject headers, footers, and wrappers into JavaScript source code.
Installation
npm i javascript-injector
Importing
Module
import JavaScriptInjector from "javascript-injector";
CommonJS
const JavaScriptInjector = require("javascript-injector");
Usage
const undecorated = `console.log("undecorated");`;
function decorator (callback) {
console.log("before");
callback();
console.log("after");
}
const injector = new JavaScriptInjector();
injector.addDecorator(decorator);
const decorated = injector.inject(undecorated);
const f = new Function(decorated);
f();