From b35c5631abe16c3e86c6c6eedf52a64575202c5b Mon Sep 17 00:00:00 2001 From: Jason Dent Date: Fri, 17 Sep 2021 17:38:43 +0200 Subject: [PATCH 1/2] fix: Use process directly instead of importing it. Fix: #1704 --- packages/cspell-trie-lib/src/lib/timer.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/cspell-trie-lib/src/lib/timer.ts b/packages/cspell-trie-lib/src/lib/timer.ts index 2daca2c0fe4..31d99848e16 100644 --- a/packages/cspell-trie-lib/src/lib/timer.ts +++ b/packages/cspell-trie-lib/src/lib/timer.ts @@ -1,6 +1,4 @@ -import { hrtime } from 'process'; - -const _hrTime: HRTimeFn = hrtime || polyHrTime; +const _hrTime: HRTimeFn = process?.hrtime || polyHrTime; export interface Timer { /** Start / restart the timer. */ From ed21038c6707bba339657a7271c6ba6c1b0c8e02 Mon Sep 17 00:00:00 2001 From: Jason Dent Date: Fri, 17 Sep 2021 17:39:19 +0200 Subject: [PATCH 2/2] Update timer.test.ts --- packages/cspell-trie-lib/src/lib/timer.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cspell-trie-lib/src/lib/timer.test.ts b/packages/cspell-trie-lib/src/lib/timer.test.ts index c7f1958c70a..baab99da674 100644 --- a/packages/cspell-trie-lib/src/lib/timer.test.ts +++ b/packages/cspell-trie-lib/src/lib/timer.test.ts @@ -6,14 +6,14 @@ const delay = promisify(setTimeout); describe('timer', () => { test('createTimer', async () => { const t = createTimer(); - await delay(11); + await delay(12); expect(t.elapsed()).toBeGreaterThan(10); }); test('polyHrTime', async () => { const a = createTimer(); const b = createTimer(polyHrTime); - await delay(11); + await delay(12); const a1 = a.elapsed(); const b1 = b.elapsed(); expect(a1).toBeGreaterThanOrEqual(10);