JSPM

  • Created
  • Published
  • Downloads 15203
  • Score
    100M100P100Q21063F
  • License MIT

A library that helps with generating a browserslist automatically. For example, a browserslist can be generated that targets only browsers that support specific required features.

Package Exports

  • @wessberg/browserslist-generator

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@wessberg/browserslist-generator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Browserslist Generator

NPM version License-mit

Description

A library that makes it easier to work with browserslists. For example, a browserslist can be generated that targets only browsers that support specific required features. Or, a browserslist can be generated that target only browsers that doesn't support specific features.

Features

browsersWithSupportForFeatures (...features: string[]): string[]

Takes any amount of caniuse features and generates a browserslist that targets all browsers that support these features

browsersWithoutSupportForFeatures (...features: string[]): string[]

Takes any amount of caniuse features and generates a browserslist that targets all browsers that doesn't support these features

browserslistSupportsFeatures (browserslist: string[], ...features: string[]): boolean

Returns true if the given browserslist supports all of the given features

matchBrowserslistOnUserAgent (userAgent: string, browserslist: string[]): boolean

Will check if the given user agent string matches the given browserslist and return true if so.

userAgentSupportsFeatures (useragent: string, ...features: string[]): boolean

Checks if the given user agent string supports all of the given caniuse features.

Installation

npm install @wessberg/browserslist-generator

Usage

import {browsersWithSupportForFeatures} from "@wessberg/browserslist-generator";

// Generate a browserslist for browsers that support all of the given features
const browserslist = browsersWithSupportForFeatures(
    "es6-module",
    "shadowdomv1",
    "custom-elementsv1"
);