baseline-browser-mapping 2.10.41 → 2.11.21

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 CHANGED
@@ -41,12 +41,13 @@ If you want to ensure [reproducible builds](https://www.wikiwand.com/en/articles
41
41
 
42
42
  ## Importing `baseline-browser-mapping`
43
43
 
44
- This module exposes two functions: `getCompatibleVersions()` and `getAllVersions()`, both which can be imported directly from `baseline-browser-mapping`:
44
+ This module exposes three functions: `getCompatibleVersions()`, `getAllVersions()`, and `getTimeline()`, all of which can be imported directly from `baseline-browser-mapping`:
45
45
 
46
46
  ```javascript
47
47
  import {
48
48
  getCompatibleVersions,
49
49
  getAllVersions,
50
+ getTimeline,
50
51
  } from "baseline-browser-mapping";
51
52
  ```
52
53
 
@@ -57,6 +58,7 @@ If you want to load the script and data directly in a web page without hosting i
57
58
  import {
58
59
  getCompatibleVersions,
59
60
  getAllVersions,
61
+ getTimeline,
60
62
  } from "https://cdn.jsdelivr.net/npm/baseline-browser-mapping";
61
63
  </script>
62
64
  ```
@@ -405,6 +407,82 @@ The outputs of `getAllVersions()` are available as JSON or CSV files generated o
405
407
 
406
408
  These files are updated on a daily basis.
407
409
 
410
+ ## Get timeline of browser version compatibility bumps
411
+
412
+ To calculate compatible browser versions on custom/arbitrary dates completely client-side without loading the full `@mdn/browser-compat-data` database, you can call the `getTimeline()` function. It returns the timeline of minimum version requirements as a chronologically sorted array of change events:
413
+
414
+ ```javascript
415
+ import { getTimeline } from "baseline-browser-mapping";
416
+
417
+ const timeline = getTimeline();
418
+ ```
419
+
420
+ It returns an `Array` of events, where each event has a `date` and an array of `browsers` representing the compatibility changes on that date:
421
+
422
+ ```javascript
423
+ [
424
+ {
425
+ date: "2015-07-29",
426
+ browsers: [
427
+ { browser: "chrome", version: "38", release_date: "2014-10-07" },
428
+ { browser: "chrome_android", version: "38", release_date: "2014-10-08" },
429
+ { browser: "edge", version: "12", release_date: "2015-07-29" },
430
+ { browser: "firefox", version: "38", release_date: "2015-05-12" },
431
+ { browser: "firefox_android", version: "38", release_date: "2015-05-12" },
432
+ { browser: "safari", version: "11", release_date: "2017-09-19" },
433
+ { browser: "safari_ios", version: "11", release_date: "2017-09-19" }
434
+ ]
435
+ },
436
+ {
437
+ date: "2015-09-22",
438
+ browsers: [
439
+ { browser: "firefox", version: "41", release_date: "2015-09-22" },
440
+ { browser: "firefox_android", version: "41", release_date: "2015-09-22" }
441
+ ]
442
+ },
443
+ ...
444
+ ]
445
+ ```
446
+
447
+ ### Options
448
+
449
+ `getTimeline()` accepts an optional configuration `Object` with the following properties:
450
+
451
+ - `groupBy` (`"date"` by default):
452
+ - If `"date"` (default), it returns a chronologically sorted `Array` of events, where each event represents a date on which a browser's Baseline requirements changed.
453
+ - If `"browser"`, it returns an `Object` where keys are browser names and values are arrays of version change events for that specific browser:
454
+ ```javascript
455
+ {
456
+ chrome: [
457
+ { date: "2015-07-29", version: "38", release_date: "2014-10-07" },
458
+ { date: "2016-03-02", version: "49", release_date: "2016-03-02" },
459
+ ...
460
+ ],
461
+ safari: [
462
+ { date: "2015-09-30", version: "9", release_date: "2015-09-30" },
463
+ ...
464
+ ],
465
+ ...
466
+ }
467
+ ```
468
+ - `listAllBrowsers` (`false` by default):
469
+ - If `false`, the `browsers` array for each event (when `groupBy` is `"date"`) contains _only_ the browsers that changed on that specific date.
470
+ - If `true`, the `browsers` array for each event will contain the state of _all_ active compatible browsers at that point in time (showing the versions they had on that date).
471
+ - _Note: Only applicable when `groupBy` is `"date"` (or when `groupBy` is `"browser"`, this lists every date in the timeline for each browser)._
472
+ - `includeDownstreamBrowsers` (`false` by default): Whether to include downstream browsers that share the same engine as a core browser.
473
+ - `includeKaiOS` (`false` by default): Whether to include KaiOS (requires `includeDownstreamBrowsers: true`).
474
+
475
+ ```javascript
476
+ // Get a complete view of all core browsers at every timeline event
477
+ const fullTimeline = getTimeline({ listAllBrowsers: true });
478
+
479
+ // Get the timeline grouped by browser instead of by date
480
+ const browserTimeline = getTimeline({ groupBy: "browser" });
481
+
482
+ // Include downstream browsers in the timeline of changes
483
+ const downstreamTimeline = getTimeline({ includeDownstreamBrowsers: true });
484
+ ```
485
+
408
486
  ## CLI
409
487
 
410
488
  `baseline-browser-mapping` includes a command line interface that exposes the same data and options as the `getCompatibleVersions()` function. To learn more about using the CLI, run: