
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
compute-baseline
Advanced tools
A library for computing web-features statuses from browser compatibility data
compute-baseline
By the W3C WebDX Community Group and contributors.
compute-baseline
computes Baseline statuses from @mdn/browser-compat-data
feature keys.
You can use compute-baseline
to help you find interoperable web platform features, propose new web-features
features, or compare support between features.
compute-baseline
also provides utility classes for working with @mdn/browser-compat-data
generally.
If you need authoritative Baseline statuses, check out the web-features
package first.
Most of the time, the status information provided by web-features
is the best representation of a feature overall.
If you need to know the Baseline status of a specific browser compatibility data entry within a web-features
feature, then you can use the getStatus
method.
The web-features
package and the getStatus
method are the only ways to get a status that have completed the full Baseline editorial review process.
All other invocations of compute-baseline
have not received editorial review.
Don't use compute-baseline
to generate publishable Baseline statuses for arbitrary web platform features.
If you're not sure whether your application fits with the definition of Baseline, please file an issue.
To use this package, you'll need:
To install the package, run:
npm install --save compute-baseline
If you wish to specify which version of @mdn/browser-compat-data
(or manage its upgrades explicitly, such as with Dependabot), then install the latest @mdn/browser-compat-data
too.
Run:
npm install --save @mdn/browser-compat-data@latest
To get a Baseline status for a specific browser compatibility data entry within a web-features
feature, call getStatus
with the web feature's ID and the BCD feature key as parameters, as shown below:
import { getStatus } from "compute-baseline";
getStatus("fetch", "api.Response.json");
Returns:
{
baseline: 'high',
baseline_low_date: '2017-03-27',
baseline_high_date: '2019-09-27',
support: {
chrome: '42',
chrome_android: '42',
edge: '14',
firefox: '39',
firefox_android: '39',
safari: '10.1',
safari_ios: '10.3'
}
}
Note: This example returns support data that has not received an editorial review. Do not use for presenting a Baseline status. See Limitations.
import { computeBaseline } from "compute-baseline";
computeBaseline({
compatKeys: [
"javascript.builtins.AsyncFunction",
"javascript.builtins.AsyncFunction.AsyncFunction",
"javascript.operators.async_function",
"javascript.operators.await",
"javascript.statements.async_function",
],
});
Returns:
{
baseline: 'high',
baseline_low_date: '2017-04-05',
baseline_high_date: '2019-10-05',
discouraged: false,
support: Map(7) { … }
toJSON: [Function: toJSON]
}
Use the toJSON()
method to get a web-features
-like plain JSON representation of the status.
Note: This example returns support data that has not received an editorial review. Do not use for presenting a Baseline status. See Limitations.
Sometimes it can be helpful to know if parent features have less support than the specific feature you're checking (for example, the parent is behind a prefix or flag) when computing a status for a deeply-nested feature.
This is typically most interesting when checking a single key.
Use the withAncestors
option:
import { computeBaseline } from "compute-baseline";
computeBaseline({
compatKeys: ["api.Notification.body"],
withAncestors: true,
});
Note: This example returns support data that has not received an editorial review. Do not use for presenting a Baseline status. See Limitations.
If you want to use some other source of data (such as pre-release browser-compat-data), you can bring your own schema-compatible compat data.
import data from "some-parsed-json-file";
import { computeBaseline } from "compute-baseline";
import { Compat } from "compute-baseline/browser-compat-data";
const compat = new Compat(data);
computeBaseline(
{
compatKeys: ["css.properties.border-color"],
},
compat,
);
compute-baseline
is part of the W3C WebDX Community Group's web-features project.
Go to web-platform-dx/web-features for more information on contributing or getting help.
FAQs
A library for computing web-features statuses from browser compatibility data
The npm package compute-baseline receives a total of 2,213 weekly downloads. As such, compute-baseline popularity was classified as popular.
We found that compute-baseline demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.