Skip to content

Instantly share code, notes, and snippets.

@jfsiii
Created June 6, 2011 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfsiii/1010582 to your computer and use it in GitHub Desktop.
Save jfsiii/1010582 to your computer and use it in GitHub Desktop.
xports - Turning jdalton's work on https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2039-2055 into a reusable function
function xports(name, api){
if (typeof exports == 'object' && exports) {
if (typeof module == 'object' && module.exports == exports) {
module.exports = api;
} else {
exports[name] = api;
}
} else if (typeof define == 'function' && typeof define.amd == 'object') {
define(function() { return api; });
} else {
window[name] = api;
}
}
function xports(b,a){typeof exports=="object"&&exports?typeof module=="object"&&module.exports==exports?module.exports=a:exports[b]=a:typeof define=="function"&&typeof define.amd=="object"?define(function(){return a}):window[b]=a};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment