5.1.0 • Published 5 months ago

@rowanmanning/require-first v5.1.0

Weekly downloads
23
License
MIT
Repository
github
Last release
5 months ago

@rowanmanning/require-first

Require and return the first available module.

Requirements

This library requires the following to run:

Usage

Install with npm:

npm install @rowanmanning/require-first

Load the library into your code with a require call:

const { requireFirst } = require('@rowanmanning/require-first');

Require modules by passing in an array of paths. The first one that successfully resolves will be returned.

const thing = requireFirst(['thing1', './thing2', '~/../example/thing3']);

By default, an error will be thrown if none of the modules are found. You can change this behaviour to return a default value specified by you:

const thing = requireFirst(['thing1', './thing2', '~/../example/thing3'], {
  example: true
});

Migration

A new major version of this project is released if breaking changes are introduced. We maintain a migration guide to help users migrate between these versions.

Contributing

The contributing guide is available here. All contributors must follow this library's code of conduct.

License

Licensed under the MIT license. Copyright © 2019, Rowan Manning

5.1.0

5 months ago

5.0.0

8 months ago

4.2.1

1 year ago

4.2.0

1 year ago

4.1.0

2 years ago

3.0.2

2 years ago

4.0.0

2 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

1.2.0

4 years ago

2.0.0

3 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

7 years ago