odin-javascript-exercises/node_modules/is-resolvable
2017-12-15 12:56:14 -06:00
..
index.js remove timer and simon 2017-12-15 12:56:14 -06:00
LICENSE remove timer and simon 2017-12-15 12:56:14 -06:00
package.json remove timer and simon 2017-12-15 12:56:14 -06:00
README.md remove timer and simon 2017-12-15 12:56:14 -06:00

is-resolvable

NPM version Build Status Build status Coverage Status Dependency Status devDependency Status

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

Use npm.

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.