パッケージの詳細

require-one-of

Kikobeats4.9kMIT1.0.23

Conditional require with fallback support

conditional, of, one, require

readme

require-one-of

Last version Coverage 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 · X @Kikobeats

更新履歴

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.0.23 (2025-05-23)

1.0.22 (2025-05-20)

1.0.21 (2025-05-20)

1.0.20 (2024-12-06)

1.0.19 (2023-10-24)

1.0.18 (2023-09-05)

1.0.17 (2023-09-05)

1.0.16 (2022-06-12)

1.0.15 (2020-11-20)

1.0.14 (2020-09-21)

1.0.13 (2019-09-24)

Bug Fixes

1.0.12 (2019-09-20)

Bug Fixes

1.0.11 (2019-06-19)

Bug Fixes

Build System

1.0.10 (2019-05-20)

Build System

  • change git-authors-cli position (939d0ae)

1.0.9 (2019-05-04)

1.0.8 (2019-04-06)

1.0.7 (2019-03-29)

Bug Fixes

  • support npx relative packages (6dc47dd)

1.0.6 (2019-03-08)

Bug Fixes

1.0.5 (2019-03-08)

Bug Fixes

1.0.4 (2019-02-03)

Bug Fixes

1.0.3 (2019-01-14)

Bug Fixes

  • don't cache cwd directory (86ee294)
  • ensure to resolve starting from cwd (9b0a877)
  • use minus name (610ac28)

1.0.2 (2019-01-14)

Bug Fixes

  • ensure to resolve starting from cwd (9b0a877)
  • use minus name (610ac28)

1.0.1 (2019-01-14)

1.0.0 (2019-01-14)

build

BREAKING CHANGES

  • first release