Skip to content

Commit

Permalink
update rome
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored and anonrig committed Jan 2, 2023
1 parent f4ee455 commit b594edd
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: actions/setup-node@v3

- name: Install dependencies
run: npm install
run: npm install --ignore-scripts

- name: Linter
run: npm run format:ci
8 changes: 5 additions & 3 deletions benchmark/bench-thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ switch (benchmark.type) {
break;
}

suite.on("cycle", (event) => {
parentPort.postMessage(String(event.target));
}).run();
suite
.on("cycle", (event) => {
parentPort.postMessage(String(event.target));
})
.run();
2 changes: 1 addition & 1 deletion benchmark/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const benchmarks = [
{
type: "stringify",
name: "{ id: 1e+22 }",
input: { id: 1e+22 },
input: { id: 1e22 },
},
{
type: "stringify",
Expand Down
14 changes: 7 additions & 7 deletions lib/internals/querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ function encodeString(str) {
if (c < 0x800) {
lastPos = ++i;
out += utf16[c];
} else if (c < 0xD800) {
} else if (c < 0xd800) {
lastPos = ++i;
out += utf16[c];
} else if (c < 0xE000) {
} else if (c < 0xe000) {
// Surrogate pair

// This branch should never happen because all URLSearchParams entries
Expand All @@ -89,13 +89,13 @@ function encodeString(str) {
throw new Error("URI malformed");
}

c = 0x10000 + (((c & 0x3FF) << 10) | (str.charCodeAt(i) & 0x3FF));
c = 0x10000 + (((c & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff));
lastPos = ++i;
out +=
hexTable[0xF0 | (c >> 18)] +
hexTable[0x80 | ((c >> 12) & 0x3F)] +
hexTable[0x80 | ((c >> 6) & 0x3F)] +
hexTable[0x80 | (c & 0x3F)];
hexTable[0xf0 | (c >> 18)] +
hexTable[0x80 | ((c >> 12) & 0x3f)] +
hexTable[0x80 | ((c >> 6) & 0x3f)] +
hexTable[0x80 | (c & 0x3f)];
} else {
if (lastPos < i) {
out += str.slice(lastPos, i);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"query-string": "^7.1.1",
"querystringify": "^2.2.0",
"querystringparser": "^0.1.1",
"rome": "0.9.1-next",
"rome": "11.0.0",
"simple-git": "^3.14.1",
"vitest": "^0.23.4"
},
Expand Down
9 changes: 4 additions & 5 deletions test/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ import { qsNoMungeTestCases, qsTestCases, qsWeirdObjects } from "./node";
import querystring from "querystring";

test("should succeed on node.js tests", () => {
qsWeirdObjects.forEach(
(t) =>
assert.deepEqual(qs.parse(t[1] as string), t[2] as Record<string, any>),
qsWeirdObjects.forEach((t) =>
assert.deepEqual(qs.parse(t[1] as string), t[2] as Record<string, any>),
);
qsNoMungeTestCases.forEach((t) => assert.deepEqual(qs.parse(t[0]), t[1]));
qsTestCases.forEach((t) => assert.deepEqual(qs.parse(t[0]), t[2]));
});

test("native querystring module should match the test suite result", () => {
qsTestCases.forEach((t) => assert.deepEqual(querystring.parse(t[0]), t[2]));
qsNoMungeTestCases.forEach(
(t) => assert.deepEqual(querystring.parse(t[0]), t[1]),
qsNoMungeTestCases.forEach((t) =>
assert.deepEqual(querystring.parse(t[0]), t[1]),
);
});

Expand Down
16 changes: 6 additions & 10 deletions test/stringify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,19 @@ import { test, assert } from "vitest";
import querystring from "querystring";

test("should succeed on node.js tests", () => {
qsWeirdObjects.forEach(
(t) =>
assert.deepEqual(
qs.stringify(t[2] as Record<string, any>),
t[1] as string,
),
qsWeirdObjects.forEach((t) =>
assert.deepEqual(qs.stringify(t[2] as Record<string, any>), t[1] as string),
);
qsNoMungeTestCases.forEach((t) => assert.deepEqual(qs.stringify(t[1]), t[0]));
qsTestCases.forEach((t) => assert.deepEqual(qs.stringify(t[2]), t[1]));
});

test("native querystring module should match the test suite result", () => {
qsTestCases.forEach(
(t) => assert.deepEqual(querystring.stringify(t[2]), t[1]),
qsTestCases.forEach((t) =>
assert.deepEqual(querystring.stringify(t[2]), t[1]),
);
qsNoMungeTestCases.forEach(
(t) => assert.deepEqual(querystring.stringify(t[1]), t[0]),
qsNoMungeTestCases.forEach((t) =>
assert.deepEqual(querystring.stringify(t[1]), t[0]),
);
});

Expand Down

0 comments on commit b594edd

Please sign in to comment.