require_replacement_templates
v0.0.3
Published
module templates, loadable by node or browser
Downloads
4
Readme
require_replacement_templates
module templates, loadable by node or browser
what is this?
Nothing too exciting, just templates to use as a guideline for exporting functions from javascript files so they can be loaded by node or a browser.
Whilst they are designed to be used with require_replacement (not released yet), they can be used in any context.
You can install them or just copy them from this readme page.
singleFunction.js
// node/browser function template (basic node anonymous export variant)
// installation:
// browser:
// <script src='singleFunction.js'></script>
// node: (or with browser when using /js/require.js from require_replacement)
//
// var myFunction = require('./singleFunction.js');
var singleFunction = (function(m,e){return m[e] =
function singleFunction () {
}
})((this._n=typeof window=='undefined')?module:window,this._n?'exports':'singleFunction');
delete this._n;
namedFunction.js
// node/browser function template (named node export variant)
// installation:
// browser:
// <script src='namedFunction.js'></script>
// node: (or with browser when using /js/require.js from require_replacement)
//
// var namedFunction = require('./namedFunction.js').namedFunction;
var namedFunction = (function(e) {return e.namedFunction =
function namedFunction() {
};
})(typeof window==='undefined'?module.exports:window);
multiFunction.js
// node/browser function template (multiple function variant)
// installation:
// browser:
// <script src='multiFunction.js'></script>
// (once loaded)
// multiFunction.sampleFunction1();
// multiFunction.sampleFunction2();
// node: (or with browser when using /js/require.js from require_replacement)
//
// var multiFunction = require('./multiFunction.js');
//
// multiFunction.sampleFunction1();
// multiFunction.sampleFunction2();
//
// async usage under require_replacement
// require('./multiFunction.js',function(err,multiFunction){
//
// multiFunction.sampleFunction1();
// multiFunction.sampleFunction2();
//
// });
var multiFunction={};
(function(e){
var sampleFunction1 =
e.sampleFunction1 =
function sampleFunction1 () {
}
var sampleFunction2 =
e.sampleFunction2 =
function sampleFunction2 () {
}
})(typeof window==='undefined'?module.exports:multiFunction);