1.0.0 • Published 6 years ago

require-cjs-string v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

require-cjs-string npm-version

Dynamic eval commonjs/umd module from string in Node & Browser.

Install

npm install require-cjs-string

Usage

const rcs = require('require-cjs-string')

rcs('module.exports = 1')  // => 1

More Examples:

const rcs = require('require-cjs-string')

const { sqrt, square } = rcs(`
  exports.sqrt = Math.sqrt;
  exports.square = x => x * x;
`)
square(12)  // => 144
sqrt(36)    // => 6

const fn = rcs(`
  module.exports = (x, y) => {
    var z = x + y;
    return z * z * z;
  }
`)
fn(3, 4)    // => 343

License

MIT @ Amio