333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env node
 
var fs = require('fs');
var path = require('path');
var execSync = require('child_process').execSync;
 
var $ = require('cheerio');
var fromEntries = require('object.fromentries');
 
if (process.argv.length !== 3) {
    throw new RangeError('please provide a year');
}
var year = parseInt(process.argv[2]);
if (year < 2016) {
    throw new RangeError('ES2016+ only');
}
var edition = year - 2009;
 
var specHTMLurl = new URL('https://raw.githubusercontent.com/tc39/ecma262/es' + year + '/spec.html');
 
var specHTML = String(execSync('curl --silent ' + specHTMLurl));
 
var root = $(specHTML);
 
var aOps = root.filter('[aoid]').add(root.find('[aoid]'));
 
var missings = [];
 
var entries = aOps.toArray().map(function (x) {
  var op = $(x);
  var aoid = op.attr('aoid');
  var id = op.attr('id');
 
  if (!id) {
    id = op.closest('[id]').attr('id');
  }
 
  if (!id) {
    missings.push(aoid);
  }
 
  return [
    aoid,
    'https://ecma-international.org/ecma-262/' + edition + '.0/#' + id
  ];
});
 
if (missings.length > 0) {
  console.error('Missing URLs:', missings);
  process.exit(1);
}
 
entries.sort(function (a, b) { return a[0].localeCompare(b[0]); });
 
var obj = fromEntries(entries);
 
var outputPath = path.join('operations', year + '.js');
fs.writeFileSync(outputPath, '\'use strict\';\n\nmodule.exports = ' + JSON.stringify(obj, null, '\t')+ ';\n');
 
console.log('npx eslint --quiet --fix ' + outputPath);
execSync('npx eslint --quiet --fix ' + outputPath);