@mdn/browser-compat-data 4.1.20 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -4
- package/data.json +1 -1
- package/index.ts +9 -0
- package/legacynode.mjs +4 -0
- package/package.json +1 -1
- package/types.d.ts +38 -14
- package/index.d.ts +0 -10
- package/index.js +0 -1
package/README.md
CHANGED
|
@@ -14,20 +14,62 @@ Read how this project is [governed](GOVERNANCE.md).
|
|
|
14
14
|
|
|
15
15
|
Chat on [chat.mozilla.org#mdn](https://chat.mozilla.org/#/room/#mdn:mozilla.org).
|
|
16
16
|
|
|
17
|
-
## Installation
|
|
17
|
+
## Installation and Import
|
|
18
|
+
|
|
19
|
+
### NodeJS
|
|
18
20
|
|
|
19
21
|
You can install `@mdn/browser-compat-data` as a node package.
|
|
20
22
|
|
|
21
|
-
```
|
|
23
|
+
```bash
|
|
22
24
|
npm install @mdn/browser-compat-data
|
|
25
|
+
# ...or...
|
|
26
|
+
yarn add @mdn/browser-compat-data
|
|
23
27
|
```
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
Then, you can import BCD into your project with either `import` or `require()`:
|
|
26
30
|
|
|
27
31
|
```js
|
|
32
|
+
// ESM with Import Assertions (NodeJS 16+)
|
|
33
|
+
import bcd from '@mdn/browser-compat-data' assert { type: 'json' };
|
|
34
|
+
|
|
35
|
+
// ...or...
|
|
36
|
+
|
|
37
|
+
// ESM Wrapper for older NodeJS versions (NodeJS v12+)
|
|
38
|
+
import bcd from '@mdn/browser-compat-data/forLegacyNode';
|
|
39
|
+
|
|
40
|
+
// ...or...
|
|
41
|
+
|
|
42
|
+
// CommonJS Module (Any NodeJS)
|
|
28
43
|
const bcd = require('@mdn/browser-compat-data');
|
|
29
|
-
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Deno/Browsers
|
|
47
|
+
|
|
48
|
+
You can import `@mdn/browser-compat-data` using a CDN.
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
import bcd from 'https://unpkg.com/@mdn/browser-compat-data' assert { type: 'json' };
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Other Languages
|
|
55
|
+
|
|
56
|
+
You can obtain the raw compatibility data for `@mdn/browser-compat-data` using a CDN and loading the `data.json` file included in releases.
|
|
57
|
+
|
|
58
|
+
```py
|
|
59
|
+
https://unpkg.com/@mdn/browser-compat-data/data.json
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
Once you have imported BCD, you can access the compatibility data for any feature by accessing the properties of the dictionary.
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
// Grab the desired support statement
|
|
68
|
+
const support = bcd.css.properties.background.__compat;
|
|
30
69
|
// returns a compat data object (see schema)
|
|
70
|
+
|
|
71
|
+
// You may use any syntax to obtain dictionary items
|
|
72
|
+
const support = bcd['api']['Document']['body']['__compat'];
|
|
31
73
|
```
|
|
32
74
|
|
|
33
75
|
## Package contents
|