Created
January 18, 2010 08:20
-
-
Save kriskowal/279880 to your computer and use it in GitHub Desktop.
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
// require, exports, and module are injected automatically | |
// a and b had to be injected explicitly | |
var UTIL = require("util"); | |
exports.result = UTIL.add(a, b); |
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
// these are not explicitly injected by "load": | |
typeof require === "undefined"; | |
typeof exports === "undefined"; | |
typeof module === "undefined"; | |
return a + b; |
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
var ASSERT = require("assert"); | |
// load | |
ASSERT.equal(load("foo")({a: 10, b: 20}), 30); | |
// require.once | |
var BAR = require.once("bar", {a: 10, b: 20}); | |
ASSERT.equal(BAR.result, 30); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment