Skip to content

Commit

Permalink
Drop Node.js v10 support
Browse files Browse the repository at this point in the history
(And, start testing Node v16 instead of Node v15 on CI.)

Notable:

* In Node v12+, Array.prototype.sort() is stable, so we no longer need lodash/sortby.

* In Node v12 and v14, fs.rmdirSync()'s recursive option works, so we no longer need the clear-dir.js utility. However, it stopped working in v16; there you need to use the new-in-v14 fs.rmSync(). So we have to use (fs.rmSync || fs.rmdirSync).

* In Node v12+, TextEncoder and TextDecoder are globals.
  • Loading branch information
domenic committed Jun 26, 2021
1 parent 183e028 commit 08e5988
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 41 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ jobs:
fail-fast: false
matrix:
node-version:
- 10
- 12
- 14
- 15
- 16
architecture:
- x64
steps:
Expand Down
9 changes: 5 additions & 4 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"license": "MIT",
"repository": "jsdom/whatwg-url",
"dependencies": {
"lodash": "^4.7.0",
"tr46": "^2.1.0",
"webidl-conversions": "^6.1.0"
},
Expand All @@ -28,7 +27,7 @@
"webidl2js": "^16.2.0"
},
"engines": {
"node": ">=10"
"node": ">=12"
},
"scripts": {
"coverage": "jest --coverage",
Expand Down
17 changes: 0 additions & 17 deletions scripts/clear-dir.js

This file was deleted.

3 changes: 1 addition & 2 deletions scripts/get-latest-platform-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const fs = require("fs");
const path = require("path");
const util = require("util");
const stream = require("stream");
const clearDir = require("./clear-dir");

const got = require("got");

Expand All @@ -29,7 +28,7 @@ const commitHash = "706f8d143464de7d923dab391f3eab2469f042ae";
const urlPrefix = `https://raw.githubusercontent.com/web-platform-tests/wpt/${commitHash}/url/`;
const targetDir = path.resolve(__dirname, "..", "test", "web-platform-tests");

clearDir(targetDir);
(fs.rmSync || fs.rmdirSync)(targetDir, { recursive: true, force: true });
fs.mkdirSync(path.resolve(targetDir, "resources"), { recursive: true });

for (const file of [
Expand Down
4 changes: 2 additions & 2 deletions scripts/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ const path = require("path");
const recast = require("recast");
const glob = require("glob");
const WebIDL2JS = require("webidl2js");
const clearDir = require("./clear-dir");

const srcDir = path.resolve(__dirname, "../src");
const outputDir = path.resolve(__dirname, "../dist");

clearDir(outputDir);
(fs.rmSync || fs.rmdirSync)(outputDir, { recursive: true, force: true });
fs.mkdirSync(outputDir, { recursive: true });

for (const file of glob.sync(`${srcDir}/*.js`)) {
const code = fs.readFileSync(file, { encoding: "utf8" });
Expand Down
12 changes: 10 additions & 2 deletions src/URLSearchParams-impl.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"use strict";
const stableSortBy = require("lodash/sortBy");
const urlencoded = require("./urlencoded");

exports.implementation = class URLSearchParamsImpl {
Expand Down Expand Up @@ -108,7 +107,16 @@ exports.implementation = class URLSearchParamsImpl {
}

sort() {
this._list = stableSortBy(this._list, [0]);
this._list.sort((a, b) => {
if (a[0] < b[0]) {
return -1;
}
if (a[0] > b[0]) {
return 1;
}
return 0;
});

this._updateSteps();
}

Expand Down
10 changes: 0 additions & 10 deletions src/encoding.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
"use strict";
let { TextEncoder, TextDecoder } = require("util");
// Handle browserify's lack of support (https://github.com/browserify/node-util/issues/46), which
// is important for the live viewer:
if (!TextEncoder) {
TextEncoder = global.TextEncoder;
}
if (!TextDecoder) {
TextDecoder = global.TextDecoder;
}

const utf8Encoder = new TextEncoder();
const utf8Decoder = new TextDecoder("utf-8", { ignoreBOM: true });

Expand Down

0 comments on commit 08e5988

Please sign in to comment.