.. | ||
index.js | ||
LICENSE | ||
package.json | ||
README.md |
is-resolvable
A Node module to check if a module ID is resolvable with require()
const isResolvable = require('is-resolvable');
isResolvable('fs'); //=> true
isResolvable('path'); //=> true
// When `./index.js` exists
isResolvable('./index.js') //=> true
isResolvable('./index') //=> true
isResolvable('.') //=> true
Installation
npm install is-resolvable
API
const isResolvable = require('is-resolvable');
isResolvable(moduleId)
moduleId: String
(module ID)
Return: Boolean
It returns true
if require()
can load a file form a given module ID, otherwise false
.
const isResolvable = require('is-resolvable');
// When `./foo.json` exists
isResolvable('./foo.json'); //=> true
isResolvable('./foo'); //=> true
isResolvable('./foo.js'); //=> false
// When `lodash` module is installed but `underscore` isn't
isResolvable('lodash'); //=> true
isResolvable('underscore'); //=> false
// When `readable-stream` module is installed
isResolvable('readable-stream/readable'); //=> true
isResolvable('readable-stream/writable'); //=> true
License
Copyright (c) 2014 - 2016 Shinnosuke Watanabe
Licensed under the MIT License.