Created
February 14, 2024 12:31
-
-
Save Elchi3/3c59d3b69b2c07806a462a841a229472 to your computer and use it in GitHub Desktop.
Creating web-features from BCD tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import yaml from 'yaml'; | |
import bcd from '../index.js'; | |
import { walk } from '../utils/index.js'; | |
const walker = walk(undefined, bcd); | |
const bundles = {}; | |
for (const feature of walker) { | |
if (feature.compat.tags) { | |
feature.compat.tags.find(tag => { | |
if (tag.startsWith('web-features-bundle:')) { | |
const bundle = tag.split('web-features-bundle:')[1]; | |
if (bundles[bundle]) { | |
bundles[bundle].compat_features.push(feature.path); | |
// recalculate (or warn about) status if different to previous feature | |
} else { | |
bundles[bundle] = { | |
name: 'PROVIDE NAME', | |
description: 'PROVIDE DESCRIPTION', | |
snapshot: '', // surface web-features-snapshot BCD tag for this bundle | |
groups: [''], // surface web-features-group BCD tags for this bundle | |
status: { | |
baseline: 'calculateME', | |
chrome: feature.compat.support.chrome.version_added, | |
chrome_android: feature.compat.support.chrome_android.version_added, | |
edge: feature.compat.support.edge.version_added, | |
firefox: feature.compat.support.firefox.version_added, | |
firefox_android: feature.compat.support.firefox_android.version_added, | |
safari: feature.compat.support.safari.version_added, | |
safari_ios: feature.compat.support.safari_ios.version_added | |
}, | |
compat_features: [feature.path] | |
}; | |
} | |
} | |
}); | |
} | |
} | |
const doc = new yaml.Document(); | |
doc.contents = bundles; | |
console.log(doc.toString()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# These should be separate files per bundle (e.g. basic-arrays.yml, array-at.yml) | |
basic-arrays: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "1" | |
edge: "12" | |
firefox: "1" | |
safari: "1" | |
compat_features: | |
- javascript.builtins.Array | |
- javascript.builtins.Array.Array | |
- javascript.builtins.Array.concat | |
- javascript.builtins.Array.join | |
- javascript.builtins.Array.length | |
- javascript.builtins.Array.pop | |
- javascript.builtins.Array.push | |
- javascript.builtins.Array.reverse | |
- javascript.builtins.Array.shift | |
- javascript.builtins.Array.slice | |
- javascript.builtins.Array.sort | |
- javascript.builtins.Array.toLocaleString | |
- javascript.builtins.Array.toString | |
- javascript.builtins.Array.unshift | |
- javascript.grammar.array_literals | |
array-at: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "92" | |
firefox: "90" | |
safari: "15.4" | |
compat_features: | |
- javascript.builtins.Array.at | |
- javascript.builtins.TypedArray.at | |
array-copywithin: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "45" | |
edge: "12" | |
firefox: "32" | |
safari: "9" | |
compat_features: | |
- javascript.builtins.Array.copyWithin | |
- javascript.builtins.TypedArray.copyWithin | |
array-iterators: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "38" | |
edge: "12" | |
firefox: "28" | |
safari: "8" | |
compat_features: | |
- javascript.builtins.Array.entries | |
- javascript.builtins.Array.keys | |
- javascript.builtins.Array.values | |
- javascript.builtins.Array.@@iterator | |
array-iteration-methods: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "1" | |
edge: "12" | |
firefox: "1.5" | |
safari: "3" | |
safari_ios: "1" | |
compat_features: | |
- javascript.builtins.Array.every | |
- javascript.builtins.Array.filter | |
- javascript.builtins.Array.forEach | |
- javascript.builtins.Array.indexOf | |
- javascript.builtins.Array.lastIndexOf | |
- javascript.builtins.Array.map | |
- javascript.builtins.Array.reduce | |
- javascript.builtins.Array.reduceRight | |
- javascript.builtins.Array.some | |
array-fill: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "45" | |
edge: "12" | |
firefox: "31" | |
safari: "8" | |
compat_features: | |
- javascript.builtins.Array.fill | |
- javascript.builtins.TypedArray.fill | |
array-find: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "45" | |
edge: "12" | |
firefox: "25" | |
firefox_android: "4" | |
safari: "8" | |
compat_features: | |
- javascript.builtins.Array.find | |
- javascript.builtins.Array.findIndex | |
- javascript.builtins.TypedArray.find | |
- javascript.builtins.TypedArray.findIndex | |
array-findlast: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "97" | |
firefox: "104" | |
safari: "15.4" | |
compat_features: | |
- javascript.builtins.Array.findLast | |
- javascript.builtins.Array.findLastIndex | |
- javascript.builtins.TypedArray.findLast | |
- javascript.builtins.TypedArray.findLastIndex | |
array-flattening: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "69" | |
firefox: "62" | |
safari: "12" | |
compat_features: | |
- javascript.builtins.Array.flat | |
- javascript.builtins.Array.flatMap | |
array-from: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "45" | |
edge: "12" | |
firefox: "32" | |
safari: "9" | |
compat_features: | |
- javascript.builtins.Array.from | |
- javascript.builtins.TypedArray.from | |
array-fromasync: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "121" | |
firefox: "115" | |
safari: "16.4" | |
compat_features: | |
- javascript.builtins.Array.fromAsync | |
array-includes: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "47" | |
edge: "14" | |
firefox: "43" | |
safari: "9" | |
compat_features: | |
- javascript.builtins.Array.includes | |
- javascript.builtins.TypedArray.includes | |
array-isarray: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "4" | |
edge: "12" | |
firefox: "4" | |
safari: "5" | |
safari_ios: "5" | |
compat_features: | |
- javascript.builtins.Array.isArray | |
array-of: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "45" | |
chrome_android: "39" | |
edge: "12" | |
firefox: "25" | |
safari: "9" | |
compat_features: | |
- javascript.builtins.Array.of | |
- javascript.builtins.TypedArray.of | |
stable-array-sort: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "70" | |
firefox: "3" | |
safari: "10.1" | |
compat_features: | |
- javascript.builtins.Array.sort.stable_sorting | |
array-splice: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "1" | |
edge: "12" | |
firefox: "1" | |
safari: "1" | |
compat_features: | |
- javascript.builtins.Array.splice | |
array-by-copy: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "110" | |
firefox: "115" | |
safari: "16" | |
compat_features: | |
- javascript.builtins.Array.toReversed | |
- javascript.builtins.Array.toSorted | |
- javascript.builtins.Array.toSpliced | |
- javascript.builtins.Array.with | |
- javascript.builtins.TypedArray.toReversed | |
- javascript.builtins.TypedArray.toSorted | |
- javascript.builtins.TypedArray.with | |
basic-typed-arrays: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "7" | |
edge: "12" | |
firefox: "4" | |
safari: "5.1" | |
safari_ios: "4.2" | |
compat_features: | |
- javascript.builtins.Float32Array | |
- javascript.builtins.Float32Array.Float32Array | |
- javascript.builtins.Float32Array.Float32Array.constructor_without_parameters | |
- javascript.builtins.Float32Array.Float32Array.iterable_allowed | |
- javascript.builtins.Float32Array.Float32Array.new_required | |
- javascript.builtins.Float64Array | |
- javascript.builtins.Float64Array.Float64Array | |
- javascript.builtins.Float64Array.Float64Array.constructor_without_parameters | |
- javascript.builtins.Float64Array.Float64Array.iterable_allowed | |
- javascript.builtins.Float64Array.Float64Array.new_required | |
- javascript.builtins.Int16Array | |
- javascript.builtins.Int16Array.Int16Array | |
- javascript.builtins.Int16Array.Int16Array.constructor_without_parameters | |
- javascript.builtins.Int16Array.Int16Array.new_required | |
- javascript.builtins.Int32Array | |
- javascript.builtins.Int32Array.Int32Array | |
- javascript.builtins.Int32Array.Int32Array.constructor_without_parameters | |
- javascript.builtins.Int32Array.Int32Array.iterable_allowed | |
- javascript.builtins.Int32Array.Int32Array.new_required | |
- javascript.builtins.Int8Array | |
- javascript.builtins.Int8Array.Int8Array | |
- javascript.builtins.Int8Array.Int8Array.constructor_without_parameters | |
- javascript.builtins.Int8Array.Int8Array.iterable_allowed | |
- javascript.builtins.Int8Array.Int8Array.new_required | |
- javascript.builtins.TypedArray | |
- javascript.builtins.TypedArray.BYTES_PER_ELEMENT | |
- javascript.builtins.TypedArray.buffer | |
- javascript.builtins.TypedArray.byteLength | |
- javascript.builtins.TypedArray.byteOffset | |
- javascript.builtins.TypedArray.constructor_without_parameters | |
- javascript.builtins.TypedArray.join | |
- javascript.builtins.TypedArray.length | |
- javascript.builtins.TypedArray.name | |
- javascript.builtins.TypedArray.named_properties | |
- javascript.builtins.TypedArray.new_required | |
- javascript.builtins.TypedArray.reverse | |
- javascript.builtins.TypedArray.set | |
- javascript.builtins.TypedArray.slice | |
- javascript.builtins.TypedArray.sort | |
- javascript.builtins.TypedArray.subarray | |
- javascript.builtins.TypedArray.toLocaleString | |
- javascript.builtins.TypedArray.toString | |
- javascript.builtins.Uint16Array | |
- javascript.builtins.Uint16Array.Uint16Array | |
- javascript.builtins.Uint16Array.Uint16Array.constructor_without_parameters | |
- javascript.builtins.Uint16Array.Uint16Array.iterable_allowed | |
- javascript.builtins.Uint16Array.Uint16Array.new_required | |
- javascript.builtins.Uint8Array | |
- javascript.builtins.Uint8Array.Uint8Array | |
- javascript.builtins.Uint8Array.Uint8Array.constructor_without_parameters | |
- javascript.builtins.Uint8Array.Uint8Array.iterable_allowed | |
- javascript.builtins.Uint8Array.Uint8Array.new_required | |
- javascript.builtins.Uint8ClampedArray | |
- javascript.builtins.Uint8ClampedArray.Uint8ClampedArray | |
- javascript.builtins.Uint8ClampedArray.Uint8ClampedArray.iterable_allowed | |
- javascript.builtins.Uint8ClampedArray.Uint8ClampedArray.new_required | |
typed-array-iterators: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "45" | |
edge: "12" | |
firefox: "37" | |
safari: "9.1" | |
compat_features: | |
- javascript.builtins.TypedArray.entries | |
- javascript.builtins.TypedArray.keys | |
- javascript.builtins.TypedArray.values | |
- javascript.builtins.TypedArray.@@iterator | |
typed-array-iteration-methods: | |
name: PROVIDE NAME | |
description: PROVIDE DESCRIPTION | |
snapshot: "" | |
groups: | |
- "" | |
status: | |
baseline: calculateME | |
chrome: "45" | |
edge: "12" | |
firefox: "37" | |
safari: "9.1" | |
compat_features: | |
- javascript.builtins.TypedArray.every | |
- javascript.builtins.TypedArray.filter | |
- javascript.builtins.TypedArray.forEach | |
- javascript.builtins.TypedArray.indexOf | |
- javascript.builtins.TypedArray.lastIndexOf | |
- javascript.builtins.TypedArray.map | |
- javascript.builtins.TypedArray.reduce | |
- javascript.builtins.TypedArray.reduceRight | |
- javascript.builtins.TypedArray.some |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment