-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Update es-builtins #174
feat: Update es-builtins #174
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is built using
https://github.com/mdn/browser-compat-data
dotAll: { [READ]: { supported: "8.10.0" } }, | ||
hasIndices: { [READ]: { supported: "16.0.0" } }, | ||
input: { [READ]: { supported: "0.10.0" } }, | ||
lastIndex: { [READ]: { supported: "0.10.0" } }, | ||
lastMatch: { [READ]: { supported: "0.10.0" } }, | ||
lastParen: { [READ]: { supported: "0.10.0" } }, | ||
leftContext: { [READ]: { supported: "0.10.0" } }, | ||
n: { [READ]: { supported: "0.10.0" } }, | ||
rightContext: { [READ]: { supported: "0.10.0" } }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There appear to be some wrong here, I will look more later 🤔
I have a little extension to this in scagood#1 That removes all the 'backport' properties in favour of just having a supported array. |
There is data that we want in both The script I used to help automate this is:const data = require("./data.json")
const knownIssues = new Set([
"TypedArray",
"AsyncFunction",
"Generator",
"AsyncGenerator",
"GeneratorFunction",
"AsyncGeneratorFunction",
"Iterator",
"AsyncIterator",
"undefined",
"AggregateError.errors",
])
function getVersion(data) {
return (
data.__compat?.support?.nodejs?.version_added ??
data.__compat?.support?.nodejs?.[0]?.version_added ??
false
)
}
const dataset = data.javascript.builtins
for (const builtin in dataset) {
if (knownIssues.has(builtin)) {
continue
}
const builtinData =
builtin.endsWith("Array") && !builtin.startsWith("Array")
? {
...dataset.TypedArray,
...dataset[builtin],
}
: dataset[builtin]
const builtinVersion = getVersion(builtinData)
if (builtinVersion === false) {
continue
}
let lines = [
`${builtin}: {`,
` [READ]: { supported: "${builtinVersion}" },`,
]
for (const fullKey of Object.keys(builtinData)) {
// if (fullKey.endsWith('_static') === false) {
// continue;
// }
const key = fullKey //.slice(0, -7);
const keyData = builtinData[fullKey]
if (
key === builtin ||
key === "__compat" ||
key.startsWith("@@") ||
knownIssues.has(`${builtin}.${key}`) ||
knownIssues.has(`${builtin}.*`) ||
knownIssues.has(`*.${key}`)
) {
continue
}
if (
// Its a new feature of ${builtin}
keyData.__compat?.spec_url == null ||
// Its not a static property
keyData.__compat?.spec_url.includes(
`.prototype.${key.toLowerCase()}`
)
) {
continue
}
const keyVersion = getVersion(keyData)
if (keyVersion === false) {
continue
}
lines.push(` ${key}: { [READ]: { supported: "${keyVersion}" } },`)
}
lines.push("},")
console.info(lines.join("\n"))
} Even though its super hacky... when the if (fullKey.endsWith('_static') === false) {
continue;
}
const key = fullKey.slice(0, -7); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! 💯
I took the data from mdn/browser-compat-data and used that to update the es-builtins file (it was a lot-a-bit manual).
I do wander if we should make a script to automate this fully.