Nitrate Processed Mincemeat
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    wrapforpublic

    wrapfor Build Status

    Wrap code for usage as an amd/cjs/whatever module.

    Examples

    var input = "var method = function () { return true; };"

    Generate an AMD module:

    wrapfor.amd(input, {exports:'method'});
     
    // ^ returns a string containing
    define(function(require) {
    var method = function() { return true; };
    return method;
    });

    Generate an AMD module with dependencies inline:

    wrapfor.amd(input, {
      deps: {
        "_": "lodash"
      },
      exports: "method"
    });
     
    // ^ returns a string containing
    define(function(require) {
    var _ = require('lodash');
    var method = function() { return true; };
    return method;
    });

    Generate a CommonJS module:

    wrapfor.cjs(input, {exports:'method'});
     
    // ^ returns a string containing
    var method = function() { return true; };
    module.exports = method;

    Generate a CommonJS module with dependencies inline:

    wrapfor.cjs(input, {
      deps: {
        "_": "lodash"
      },
      exports: "method"
    });
     
    // ^ returns a string containing
    var _ = require('lodash');
    var method = function() { return true; };
    module.exports = method;

    Usage

    wrapfor.cjs(input, opts)
    wrapfor.amd(input, opts)

    input

    Type: String Default: 'none'

    A string containing javascript to be wrapped.

    opts

    Type: Object Default: {}

    A configuration object supporting the following keys:

    • exports: the variable to export
    • deps: an object listing dependencies to load and which variable to store them in

    Release History

    • 2013-11-04 - v0.1 - initial release

    Keywords

    none

    install

    npm i wrapfor

    Downloadsweekly downloads

    4

    version

    0.1.0

    license

    none

    repository

    githubgithub

    last publish

    collaborators

    • avatar