Skip to content

Commit 0ce3406

Browse files
ddbeckfoolip
andauthored
compute-baseline: Add README and LICENSE files (#934)
Co-authored-by: Philip Jägenstedt <[email protected]>
1 parent d5f5748 commit 0ce3406

File tree

3 files changed

+118
-3
lines changed

3 files changed

+118
-3
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
node_modules/
22
packages/compute-baseline/dist/
33
packages/web-features/index.d.ts
4-
packages/web-features/LICENSE.txt
4+
packages/**/LICENSE.txt
55
packages/web-features/types.ts
66
index.json
77
index.js
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# [`compute-baseline`](https://github.com/web-platform-dx/web-features/)
2+
3+
By the [W3C WebDX Community Group](https://www.w3.org/community/webdx/) and contributors.
4+
5+
`compute-baseline` computes preliminary [Baseline statuses](https://github.com/web-platform-dx/web-features/blob/main/docs/baseline.md) from `@mdn/browser-compat-data` feature keys.
6+
You can use `compute-baseline` to help you find interoperable web platform features, propose new [`web-features`](https://github.com/web-platform-dx/web-features/) features, or compare support between features.
7+
8+
`compute-baseline` also provides utility classes for working with `@mdn/browser-compat-data` generally.
9+
10+
## Limitations
11+
12+
If you need authoritative Baseline statuses, check out the [`web-features`](https://github.com/web-platform-dx/web-features/tree/main/packages/web-features) package instead.
13+
14+
Don't use `compute-baseline` to generate publishable Baseline statuses for arbitrary web platform features.
15+
The results of `compute-baseline` invocations have _not_ received editorial review.
16+
Strictly speaking, a Baseline status requires editorial review, so statuses generated by `compute-baseline` are tentative.
17+
If you need authoritative Baseline statuses, check out the [`web-features`](https://github.com/web-platform-dx/web-features/tree/main/packages/web-features) package instead.
18+
19+
You can use `compute-baseline` to explore possibilities or do error correction.
20+
For example, you might use `compute-baseline` to hide a Baseline status, when showing a broader feature's status might be misleading.
21+
22+
If you're not sure whether your application fits with the definition of Baseline, please [file an issue](https://github.com/web-platform-dx/web-features/issues/new).
23+
24+
## Prerequisites
25+
26+
To use this package, you'll need:
27+
28+
- Node.js (a supported [current, active LTS, or maintenance LTS release](https://nodejs.org/en/about/previous-releases))
29+
30+
## Install
31+
32+
To install the package, run:
33+
34+
`npm install --save compute-baseline`
35+
36+
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.
37+
Run:
38+
39+
`npm install --save @mdn/browser-compat-data@latest`
40+
41+
## Usage
42+
43+
### Check support for a group of compat keys
44+
45+
```javascript
46+
import { computeBaseline } from "compute-baseline";
47+
48+
computeBaseline({
49+
compatKeys: [
50+
"javascript.builtins.AsyncFunction",
51+
"javascript.builtins.AsyncFunction.AsyncFunction",
52+
"javascript.operators.async_function",
53+
"javascript.operators.await",
54+
"javascript.statements.async_function",
55+
],
56+
});
57+
```
58+
59+
Returns:
60+
61+
```
62+
{
63+
baseline: 'high',
64+
baseline_low_date: '2017-04-05',
65+
baseline_high_date: '2019-10-05',
66+
discouraged: false,
67+
support: Map(7) { … }
68+
toJSON: [Function: toJSON]
69+
}
70+
```
71+
72+
Use the `toJSON()` method to get a `web-features`-like plain JSON representation of the status.
73+
74+
### Check support for a single support key
75+
76+
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.
77+
This is typically most interesting when checking a single key.
78+
Use the `withAncestors` option:
79+
80+
```javascript
81+
import { computeBaseline } from "compute-baseline";
82+
83+
computeBaseline({
84+
compatKeys: ["api.Notification.body"],
85+
withAncestors: true,
86+
});
87+
```
88+
89+
### Bring your own compatibility data
90+
91+
If you don't want to import `@mdn/browser-compat-data` as your data source, you can bring your own schema-compatible compat data.
92+
93+
```javascript
94+
import data from "some-parsed-json-file";
95+
import { computeBaseline } from "compute-baseline";
96+
import { Compat } from "compute-baseline/browser-compat-data";
97+
98+
const compat = new Compat(data);
99+
100+
computeBaseline(
101+
{
102+
compatKeys: ["css.properties.border-color"],
103+
},
104+
compat,
105+
);
106+
```
107+
108+
<!-- TODO: API reference -->
109+
110+
## Helping out and getting help
111+
112+
`compute-baseline` is part of the W3C WebDX Community Group's web-features project.
113+
Go to [web-platform-dx/web-features](https://github.com/web-platform-dx/web-features/) for more information on contributing or getting help.

packages/compute-baseline/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
"./browser-compat-data": "./dist/browser-compat-data/index.js"
99
},
1010
"files": [
11-
"dist"
11+
"dist",
12+
"LICENSE.txt",
13+
"README.md"
1214
],
1315
"types": "./dist/index.d.ts",
1416
"type": "module",
1517
"scripts": {
1618
"test": "mocha -r tsx 'src/**/*.test.ts'",
17-
"prepare": "tsc"
19+
"prepare": "cp ../../LICENSE.txt . && tsc"
1820
},
1921
"license": "Apache-2.0",
2022
"devDependencies": {

0 commit comments

Comments
 (0)