require-optional

0.4.0 • Public • Published

require-optional NPM Version Build Status

Usage

Install via npm:

$ npm install require-optional

Basic usage:

var requireOptional = require('require-optional')
var optDep = requireOptional('dep')
if (optDep) {
  /* do stuff with optDep */
}

require-optional can return a default value:

var optDep = requireOptional('dep', function () {})
optDep('processing')

require-optional accepts an error callback for when the module is not found:

requireOptional('dep', null, function (err) {
  console.warn(err)
})

require-optional can also require relative modules:

var optDep = requireOptional('./dep')

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.4.0283latest

Version History

VersionDownloads (Last 7 Days)Published
0.4.0283
0.3.00
0.2.10
0.2.00
0.1.00
0.0.10

Package Sidebar

Install

npm i require-optional

Weekly Downloads

283

Version

0.4.0

License

MIT

Last publish

Collaborators

  • fengb