https://github.com/best-shot/ext-to-regexp
Convert extname into regexp
https://github.com/best-shot/ext-to-regexp
extension extname regexp webpack
Last synced: about 2 months ago
JSON representation
Convert extname into regexp
- Host: GitHub
- URL: https://github.com/best-shot/ext-to-regexp
- Owner: best-shot
- License: mit
- Created: 2021-06-09T13:22:37.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-09T13:23:11.000Z (almost 5 years ago)
- Last Synced: 2025-09-26T10:56:17.087Z (8 months ago)
- Topics: extension, extname, regexp, webpack
- Language: JavaScript
- Homepage:
- Size: 99.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ext-to-regexp
Convert extname into regexp.
[![npm][npm-badge]][npm-url]
[![github][github-badge]][github-url]
![node][node-badge]
[npm-url]: https://www.npmjs.com/package/ext-to-regexp
[npm-badge]: https://img.shields.io/npm/v/ext-to-regexp.svg?style=flat-square&logo=npm
[github-url]: https://github.com/best-shot/ext-to-regexp
[github-badge]: https://img.shields.io/npm/l/ext-to-regexp.svg?style=flat-square&colorB=blue&logo=github
[node-badge]: https://img.shields.io/node/v/ext-to-regexp.svg?style=flat-square&colorB=green&logo=node.js
## Installation
```bash
npm install ext-to-regexp
```
## Usage
```cjs
const extToRegexp = require('ext-to-regexp');
extToRegexp({
extname: ['js', 'jsx']
});
// /\.(js|jsx)$/
extToRegexp({
suffix: ['min'],
extname: ['jpg', 'png']
});
// /\.min\.(jpg|png)$/
const foo = extToRegexp({ extname: ['css'] });
const bar = foo.add('sass', 'scss').add('less');
const baz = bar.remove('sass').remove('scss');
console.log(foo); // /\.css$/
console.log(bar); // /\.(css|less|sass|scss)$/
console.log(baz); // /\.(css|less)$/
```