Skip to content

Commit c7543b6

Browse files
authored
Merge pull request #9 from web-platform-dx/add-all-browsers-function
Adds a function that returns all known browsers with their Baseline compatibility as a JS `Array` or as a `String` CSV
2 parents 88674b9 + fe75381 commit c7543b6

File tree

3 files changed

+295
-27
lines changed

3 files changed

+295
-27
lines changed

README.md

+95-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
By the [W3C WebDX Community Group](https://www.w3.org/community/webdx/) and contributors.
44

5-
`baseline-browser-mapping` exposes arrays of browsers compatible with Baseline Widely Available and specified Baseline year feature sets.
5+
`baseline-browser-mapping` exposes arrays of browsers compatible with Baseline Widely available and specified Baseline year feature sets.
66
You can use `baseline-browser-mapping` to help you determine minimum browser version support for your chosen Baseline feature set.
77

88
## Prerequisites
@@ -25,11 +25,9 @@ To install the package, run:
2525
]
2626
```
2727

28-
## Usage
28+
## Get Baseline Widely available browser versions
2929

30-
### Get Baseline Widely Available browser versions
31-
32-
To get the current list of minimum browser versions compatible with Baseline Widely Available features from the core browser set, call the `getCompatibleVersions()` function with:
30+
To get the current list of minimum browser versions compatible with Baseline Widely available features from the core browser set, call the `getCompatibleVersions()` function:
3331

3432
```javascript
3533
import { getCompatibleVersions } from "baseline-browser-mapping";
@@ -64,9 +62,9 @@ Executed on 7th March 2025, the above code returns the following browser version
6462
```
6563

6664
> [!NOTE]
67-
> The minimum versions of each browser are not strictly the final release before the Widely Available cutoff date of `TODAY - 30 MONTHS`. Some earlier versions will have supported the full Widely Available feature set.
65+
> The minimum versions of each browser are not strictly the final release before the Widely available cutoff date of `TODAY - 30 MONTHS`. Some earlier versions will have supported the full Widely available feature set.
6866
69-
### Configuration options
67+
### `getCompatibleVersions()` configuration options
7068

7169
`getCompatibleVersions()` accepts an `Object` as an argument with configuration options. The defaults are as follows:
7270

@@ -118,7 +116,7 @@ Returns the following versions:
118116
119117
#### `widelyAvailableOnDate`
120118

121-
The `widelyAvailableOnDate` options returns the minimum versions compatible with Baseline Widely Available on a specified date in the formay `YYYY-MM-DD`:
119+
The `widelyAvailableOnDate` options returns the minimum versions compatible with Baseline Widely available on a specified date in the formay `YYYY-MM-DD`:
122120

123121
```javascript
124122
getCompatibleVersions({
@@ -127,7 +125,7 @@ getCompatibleVersions({
127125
```
128126

129127
> [!TIP]
130-
> This can be particularly useful if you provide a versioned library that target Baseline Widely Available on each version's release date and want to provide a table of minimum supported browsers in your documentation.
128+
> This can be particularly useful if you provide a versioned library that target Baseline Widely available on each version's release date and want to provide a table of minimum supported browsers in your documentation.
131129
132130
#### `includeDownstreamBrowsers`
133131

@@ -151,6 +149,94 @@ getCompatibleVersions({
151149
});
152150
```
153151

152+
## Get data for all browser versions
153+
154+
You may want to obtain data on all the browser versions available in this module for use in an analytics solution or dashboard. To get details of each browser version's level of Baseline support, call the `getAllVersions()` function:
155+
156+
```javascript
157+
import { getAllVersions } from "baseline-browser-mapping";
158+
159+
getAllVersions();
160+
```
161+
162+
By default, this function returns an `Array` of `Objects` and excludes downstream browsers:
163+
164+
```javascript
165+
[
166+
...
167+
{
168+
browser: 'chrome_android', // Browser name
169+
version: '68', // Browser version as a string
170+
release_date: '2018-07-24', // Release date
171+
year: 2019, //Baseline year feature set the version supports
172+
waCompatible: false // Boolean indicating whether the version is compatible with Baseline Widely available
173+
},
174+
...
175+
]
176+
```
177+
178+
### `getAllVersions()` Configuration options
179+
180+
`getAllVersions()` accepts an `Object` as an argument with configuration options. The defaults are as follows:
181+
182+
```javascript
183+
{
184+
includeDownstreamBrowsers: false,
185+
outputFormat: "array"
186+
}
187+
```
188+
189+
#### `includeDownstreamBrowsers` (in `getAllVersions()` output)
190+
191+
As with `getCompatibleVersions()`, you can set `includeDownstreamBrowsers` to `true` to include the Chromium downstream browsers [listed below](#list-of-downstream-browsers).
192+
193+
```javascript
194+
getAllVersions({
195+
includeDownstreamBrowsers: true,
196+
});
197+
```
198+
199+
Downstream browsers include the same properties as core browsers, as well as the engine they use and which version of that engine they implement, for example:
200+
201+
```javascript
202+
[
203+
...
204+
{
205+
"browser": "samsunginternet_android",
206+
"version": "18.0",
207+
"release_date": "2022-08-08",
208+
"engine": "Blink",
209+
"engine_version": "99",
210+
"year": 2021,
211+
"waCompatible": false
212+
},
213+
...
214+
]
215+
```
216+
217+
#### `outputFormat`
218+
219+
By default, this function returns an `Array` of `Objects` which can be manipulated in Javascript or output to JSON. To return a `String` in CSV format, set `outputFormat` to `csv`:
220+
221+
```javascript
222+
getAllVersions({
223+
outputFormat: "csv",
224+
});
225+
```
226+
227+
`getAllVersions` returns a `String` with a header row and comma-separated values for each browser version that you can write to a file or pass to another service. Core browsers will have "NULL" as the value for their `engine` and `engine_version`:
228+
229+
```csv
230+
"browser","version","year","waCompatible","release_date","engine","engine_version"
231+
"chrome","53","2016","false","2016-09-07","NULL","NULL"
232+
...
233+
"ya_android","20.12","2020","false","2020-12-20","Blink","87"
234+
...
235+
```
236+
237+
> [!NOTE]
238+
> The above example uses `"includeDownstreamBrowsers": true`
239+
154240
## Downstream browsers
155241

156242
### Limitations

src/index.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
import { getCompatibleVersions } from "./scripts/baseline-browser-versions.js";
1+
import {
2+
getCompatibleVersions,
3+
getAllVersions,
4+
} from "./scripts/baseline-browser-versions.js";
25

3-
export { getCompatibleVersions };
6+
export { getCompatibleVersions, getAllVersions };

0 commit comments

Comments
 (0)