JSPM

  • Created
  • Published
  • Downloads 15092
  • Score
    100M100P100Q21103F
  • 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 or MDN features and generates a browserslist that targets all browsers that support these features

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

Takes any amount of caniuse or MDN 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 caniuse or MDN 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 or MDN features.

normalizeBrowserslist (browserslist: string[]|string): string[]

Generates a normalized Browserslist from the given one.

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"
);

Backers

Become a backer and get your name, logo, and link to your site listed here. Your help is greatly appreciated!