Skip to content

Commit

Permalink
generate all data
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Dec 18, 2024
1 parent b0dfcc6 commit bb81d3c
Show file tree
Hide file tree
Showing 322 changed files with 14,088 additions and 962 deletions.
9 changes: 9 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# https://github.com/crate-ci/typos
# cargo install typos-cli
# typos

[files]
extend-exclude = [
"data.json",
"src/meta/*.rs",
]
48 changes: 47 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,12 @@ unnecessary_safety_comment = "warn"
undocumented_unsafe_blocks = "warn"
infinite_loop = "warn"

[workspace.dependencies]
convert_case = "0.6.0"
prettyplease = "0.2.20"
project-root = "0.2.2"
quote = "1.0"
serde = "1.0"
serde_json = "1.0"
syn = "2"

[lints]
workspace = true

[dependencies]
oxc = { version = "0.41.0", features = ["semantic"] }
rayon = "1.10.0"

[profile.release]
# Configurations explicitly listed here for clarity.
Expand Down
69 changes: 65 additions & 4 deletions build.cjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,70 @@
const es2016 = require('./compat-table/data-es2016plus.js');
const es5 = require('./compat-table/data-es5.js').tests.map((t) => ({
target: 'es5',
...t,
}));
const es6 = require('./compat-table/data-es6.js').tests.map((t) => ({
target: 'es6',
...t,
}));
const es2016Plus = require('./compat-table/data-es2016plus.js').tests.map((t) => ({
target: 'es2016',
...t,
}));
const esnext = require('./compat-table/data-esnext.js').tests.map((t) => ({
target: 'esnext',
...t,
}));

const data = es2016.tests.map((test) => {
const data = es5.concat(es6, es2016Plus, esnext).map((test) => {
return mapper(test);
});

console.log(JSON.stringify(data, null, 2));

function mapper(test) {
return {
name: test.name,
target: test.target,
category: test.category,
significance: test.significance,
spec: test.spec,
mdn: test.mdn,
exec: test.exec && testScript(test.exec).trim(),
subtests: test.subtests && test.subtests.map(mapper),
};
});
}

console.log(JSON.stringify(data, null, 2));
function testScript(fn) {
function deindentFunc(fn) {
fn = fn + '';
var indent = /(?:^|\n)([\t ]+)[^\n]+/.exec(fn);
if (indent) {
fn = fn.replace(new RegExp('\n' + indent[1], 'g'), '\n');
}
return fn;
}
if (!fn) {
return '';
}
if (typeof fn === 'function') {
// see if the code is encoded in a comment
var expr = (fn + '').match(/[^]*\/\*([^]*)\*\/\}$/);
// if there wasn't an expression, make the function statement into one
if (!expr) {
expr = deindentFunc(fn);
return expr;
} else {
expr = deindentFunc(expr[1]);
return expr;
}
} else {
// it's an array of objects like the following:
// { type: 'application/javascript;version=1.8', script: function () { ... } }
return fn.reduce(function(text, script) {
var expr = deindentFunc(
(script.script + '').replace(/^function \(\) \{\s*|\s*\}$/g, ''),
);
return text + '\n' + expr;
}, '');
}
}
Loading

0 comments on commit bb81d3c

Please sign in to comment.