# require-extensions

> Get the extensions of executable file names as glob pattern or regular expression

Latest version **0.0.4** (published 2016-01-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install require-extensions
pnpm add require-extensions
yarn add require-extensions
bun add require-extensions
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2016-01-24 |
| First published | 2016-01-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Andreas Pizsa |
| Maintainers | andreaspizsa |
| Keywords | require, module, js, coffee, coffeescript, literate, pattern, glob, find, file, file name, filename, execute, executable, code, extensions, extension |

## Links

- npm: https://www.npmjs.com/package/require-extensions
- Repository: https://github.com/andreaspizsa/require-extensions
- Homepage: https://github.com/andreaspizsa/require-extensions#readme
- Issues: https://github.com/andreaspizsa/require-extensions/issues
- npm.io page: https://npm.io/package/require-extensions

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.4 (latest) — 2016-01-24
- 0.0.3 — 2016-01-21
- 0.0.2 — 2016-01-18
- 0.0.1 — 2016-01-18

## README

# require-extensions ![Travis](https://img.shields.io/travis/AndreasPizsa/require-extensions.svg?style=flat-square) ![Coverage Status](https://img.shields.io/coveralls/AndreasPizsa/require-extensions.svg?style=flat-square) ![Downloads](https://img.shields.io/npm/dm/require-extensions.svg?style=flat-square)

> Get the extensions of executable file names as glob pattern or regular expression

Install with [npm](https://www.npmjs.com/)

```sh
$ npm i require-extensions --save
```

## Usage

```javascript
require.extensions.glob             // -> {.js,.coffee}
require.extensions.regexp           // -> /(?:\.js|\.coffee)/
require.extensions.regexp.string    // -> '(?:\.js|\.coffee)'
```

```javascript
require('require-extensions');

var glob = require('glob');
var files = glob.sync("plugins/*." + require.extensions.glob);
// -> ['plugins/thisfile.js', 'plugins/thatfile.coffee', 'plugins/thisfile.litcoffee']

files[0].match(require.extensions.regexp);
// -> != null
```

### Functions

### [glob](index.js#L19)

return a glob pattern for `require.extensions`

### [regexp](index.js#L30)

return a new `RegExp` object that matches `require.extensions`

### [regexp_string](index.js#L43)

return a new `String` regular expression that matches `require.extensions`

## Motivation

Many libraries use a hardcoded `.js` string to discover executable file names, unfortunately leaving out other extensions that contain executable code such as `.coffee`, `.litcoffee`, and potentially others that are accessible through Node’s `require.extensions` property. By making this property accessible as a glob pattern and regular expression, it will become easier to use it as a search pattern and load code that was written in other languages or dialects.

## Author

**Andreas Pizsa**

+ [github/AndreasPizsa](https://github.com/AndreasPizsa)
+ [twitter/AndreasPizsa](http://twitter.com/AndreasPizsa)

## License

Copyright © 2016 Andreas Pizsa
Released under the MIT license.

***

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on January 21, 2016._

---
_Source: https://npm.io/package/require-extensions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
