Created
June 6, 2011 16:27
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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