New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

require-one-of

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

require-one-of

Conditional require with fallback support

  • 1.0.12
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
999
decreased by-21.03%
Maintainers
1
Weekly downloads
 
Created
Source

require-one-of

Last version Build Status Coverage Status Dependency status Dev Dependencies Status NPM Status

Conditional require with fallback support. Minimal size (>700B), no dependencies.

Install

$ npm install require-one-of --save

Usage

const requireOneOf = require('require-one-of')

// throw an error if `puppeteer` not found
requireOneOf(['puppeteer'])

// throw an error if `puppeteer` or `puppeteer-core` not found
requireOneOf(['puppeteer', 'puppeteer-core'])

// pass fn as second argument for setup custom error
requireOneOf(['puppeteer', 'puppeteer-core'], modules => {
  return new TypeError(
    `Uh, oh. ${modules
      .map(m => `'${m}'`)
      .join(',')} not found on dependencies`
  )
})

API

requireOneOf(modules, [fn])

modules

Required
Type: array

List of modules to be required. The first found will be resolved.

fn

Type: function

It exposes the function to call to create the error to be returned in case none of the modules are found.

License

require-one-of © Kiko Beats, released under the MIT License.
Authored and maintained by Kiko Beats with help from contributors.

kikobeats.com · GitHub Kiko Beats · Twitter @Kikobeats

Keywords

FAQs

Package last updated on 20 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc