Skip to content

Commit bd4c03f

Browse files
Eliminate use of delay library (#269)
* Eliminate use of delay library * Remove it from package-lock.json too
1 parent 74be6b7 commit bd4c03f

4 files changed

Lines changed: 4 additions & 18 deletions

File tree

package-lock.json

Lines changed: 0 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
},
3737
"license": "Apache-2.0",
3838
"dependencies": {
39-
"delay": "^5.0.0",
4039
"node-gyp-build": "<4.0",
4140
"p-limit": "^3.1.0",
4241
"pprof-format": "^2.2.1",

ts/src/time-profiler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import delay from 'delay';
17+
import {setTimeout} from 'timers/promises';
1818

1919
import {
2020
serializeTimeProfile,
@@ -84,7 +84,7 @@ const DEFAULT_OPTIONS: TimeProfilerOptions = {
8484
export async function profile(options: TimeProfilerOptions = {}) {
8585
options = {...DEFAULT_OPTIONS, ...options};
8686
start(options);
87-
await delay(options.durationMillis!);
87+
await setTimeout(options.durationMillis!);
8888
return stop();
8989
}
9090

ts/test/test-time-profiler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import delay from 'delay';
1817
import * as sinon from 'sinon';
1918
import {time, getNativeThreadId} from '../src';
2019
import * as v8TimeProfiler from '../src/time-profiler-bindings';
@@ -25,6 +24,7 @@ import {AssertionError} from 'assert';
2524
import {GenerateTimeLabelsArgs, LabelSet} from '../src/v8-types';
2625
import {AsyncLocalStorage} from 'async_hooks';
2726
import {satisfies} from 'semver';
27+
import {setTimeout as setTimeoutPromise} from 'timers/promises';
2828

2929
import assert from 'assert';
3030

@@ -470,7 +470,7 @@ describe('Time Profiler', () => {
470470
time.profile(PROFILE_OPTIONS).then(() => {
471471
isProfiling = false;
472472
});
473-
await delay(2 * PROFILE_OPTIONS.durationMillis);
473+
await setTimeoutPromise(2 * PROFILE_OPTIONS.durationMillis);
474474
assert.strictEqual(false, isProfiling, 'profiler is still running');
475475
});
476476

0 commit comments

Comments
 (0)