Skip to content

Commit 407f336

Browse files
committed
sleep vs wait
1 parent 12eb8a7 commit 407f336

7 files changed

Lines changed: 10 additions & 11 deletions

File tree

.oxlintrc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"no-await-in-loop": "off",
3333
"no-underscore-dangle": "off", // Disabled because it's a common pattern in the codebase
3434
"no-array-constructor": "error",
35-
"prefer-arrow-callback": "warn",
3635
"typescript/no-explicit-any": "off", // Disabled because it's a common pattern in the codebase
3736
"typescript/no-require-imports": "off", // Disabled because it's a common pattern in the codebase
3837
"typescript/no-unsafe-function-type": "error",

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"editor.defaultFormatter": "oxc.oxc-vscode",
33
"editor.formatOnSave": true,
4-
"typescript.tsdk": "node_modules/typescript/lib"
4+
"js/ts.tsdk.path": "node_modules/typescript/lib"
55
}

test/batcher.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useFakeClock, wait } from "./helpers/clock.js";
1+
import { useFakeClock, sleep } from "./helpers/clock.js";
22
import { test, describe, expect } from "./helpers/test-api.js";
33
const Bottleneck = require("./bottleneck");
44

@@ -85,7 +85,7 @@ describe("Batcher", () => {
8585

8686
const t0 = Date.now();
8787
const p1 = batcher.add(1);
88-
await wait(50);
88+
await sleep(50);
8989
const p2 = batcher.add(2);
9090
await Promise.all([p1, p2]);
9191

@@ -110,7 +110,7 @@ describe("Batcher", () => {
110110

111111
const t1 = Date.now();
112112
const p4 = batcher.add(4);
113-
await wait(50);
113+
await sleep(50);
114114
const p5 = batcher.add(5);
115115
await Promise.all([p4, p5]);
116116

test/cluster-coordination.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { sleep } from "./helpers/clock.js";
12
import { test, describe, expect, waitForState, deferred } from "./helpers/test-api.js";
23
const Bottleneck = require("./bottleneck");
34
const Scripts = require("../src/cluster/Scripts.js");
@@ -517,7 +518,7 @@ describe("Cluster coordination", () => {
517518
})
518519
.then(function (doneCount) {
519520
expect(doneCount).toEqual(1);
520-
return h.wait(400);
521+
return sleep(400);
521522
})
522523
.then(function () {
523524
return countKeys(limiter);

test/general-traffic.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useFakeClock, useRealClockForThisTest } from "./helpers/clock.js";
1+
import { sleep, useFakeClock, useRealClockForThisTest } from "./helpers/clock.js";
22
import { test, describe, expect, waitForState, deferred } from "./helpers/test-api.js";
33

44
const path = require("path");
@@ -251,7 +251,7 @@ describe("General traffic", () => {
251251
// (`Date.now() - t0 > 145`) verifies j1 actually ran a
252252
// meaningful interval, without depending on a fixed timer that
253253
// can race event-loop jitter.
254-
return h.wait(100).then(function () {
254+
return sleep(100).then(function () {
255255
holdJ1.release();
256256
});
257257
}),

test/helpers/clock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function useRealClockForThisTest() {
3939
}
4040

4141
/** Promise delay via global setTimeout (respects fake timers when installed). */
42-
export function wait(ms) {
42+
export function sleep(ms) {
4343
return new Promise((resolve) => {
4444
setTimeout(resolve, ms);
4545
});

test/helpers/test-api.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test as baseTest, expect as vitestExpect, vi } from "vitest";
2-
import { wait, isFakeClock } from "./clock.js";
2+
import { isFakeClock } from "./clock.js";
33
import { createTaskFns } from "./job-tasks.js";
44
import makeLimiterHelper from "./limiter.js";
55

@@ -64,7 +64,6 @@ function createJobHarness() {
6464
flushLimiter: flushLimiter,
6565
pNoErrVal: pNoErrVal,
6666
noErrVal: noErrVal,
67-
wait: wait,
6867
callTimes: callTimes,
6968
};
7069
}

0 commit comments

Comments
 (0)