Skip to content

Instantly share code, notes, and snippets.

@kriskowal
Created January 18, 2010 08:20
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 kriskowal/279880 to your computer and use it in GitHub Desktop.
Save kriskowal/279880 to your computer and use it in GitHub Desktop.
// 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);
// these are not explicitly injected by "load":
typeof require === "undefined";
typeof exports === "undefined";
typeof module === "undefined";
return a + b;
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