Permalink
Browse files

new resolve.{core,isCore} with tests and documentation, bump to 0.0.1

  • Loading branch information...
1 parent 2032753 commit a9ef081a4897e9882bf6bc6b31457c53b8d0fc0d @substack substack committed Jun 18, 2011
Showing with 23 additions and 4 deletions.
  1. +5 −0 README.markdown
  2. +6 −3 index.js
  3. +1 −1 package.json
  4. +11 −0 test/core.js
View
@@ -21,3 +21,8 @@ algorithm](http://nodejs.org/docs/v0.4.8/api/all.html#all_Together...)
for `X=pkg` and `Y=opts.basedir`.
If nothing is found, all of the directories in `opts.paths` are searched.
+
+resolve.isCore(pkg)
+-------------------
+
+Return whether a package is in core.
View
@@ -3,11 +3,14 @@ var path = require('path');
// http://nodejs.org/docs/v0.4.8/api/all.html#all_Together...
-var core = [ 'assert', 'buffer', 'child_process', 'crypto', 'dgram', 'dns',
- 'events', 'fs', 'http', 'https', 'net', 'os', 'path', 'querystring', 'repl',
- 'stream', 'sys', 'tls', 'tty', 'url', 'util', 'vm'
+var core = exports.core = [
+ 'assert', 'buffer', 'child_process', 'crypto', 'dgram', 'dns', 'events',
+ 'fs', 'http', 'https', 'net', 'os', 'path', 'querystring', 'repl', 'stream',
+ 'sys', 'tls', 'tty', 'url', 'util', 'vm'
].reduce(function (acc, x) { acc[x] = true; return acc }, {});
+exports.isCore = function (x) { return core[x] };
+
exports.sync = function (x, opts) {
if (core[x]) return x;
View
@@ -1,7 +1,7 @@
{
"name" : "resolve",
"description" : "A more hookable require.resolve() implementation",
- "version" : "0.0.0",
+ "version" : "0.0.1",
"repository" : {
"type" : "git",
"url" : "git://github.com/substack/node-resolve.git"
View
@@ -0,0 +1,11 @@
+var assert = require('assert');
+var resolve = require('../');
+
+exports.core = function () {
+ assert.ok(resolve.isCore('fs'));
+ assert.ok(resolve.isCore('net'));
+ assert.ok(resolve.isCore('http'));
+
+ assert.ok(!resolve.isCore('seq'));
+ assert.ok(!resolve.isCore('../'));
+};

0 comments on commit a9ef081

Please sign in to comment.