Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rspack-contrib/browserslist-to-es-version

Convert browserslist query to ECMAScript version.
https://github.com/rspack-contrib/browserslist-to-es-version

browserslist ecmascript

Last synced: about 1 month ago
JSON representation

Convert browserslist query to ECMAScript version.

Awesome Lists containing this project

README

        

# browserslist-to-es-version

Convert [browserslist](https://github.com/browserslist/browserslist) query to ECMAScript version.



npm version

license

## Usage

Install:

```bash
npm add browserslist-to-es-version -D
```

Example:

```ts
import { browserslistToESVersion } from 'browserslist-to-es-version';

const esVersion = browserslistToESVersion([
"chrome >= 87",
"edge >= 88",
"firefox >= 78",
"safari >= 14",
]);

console.log(esVersion); // 2017
```

## Type

```ts
// Only supports ES5 ~ ES2018
type ESVersion = 5 | 2015 | 2016 | 2017 | 2018;

function browserslistToESVersion(browsers: string[]): ESVersion;
```

## License

[MIT](./LICENSE).