From 5642e0d8660934c1665bc02b7acf89e9588f66a1 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 29 Mar 2022 14:07:24 +0100 Subject: [PATCH] fix: use `perfect-debounce` (#22) --- package.json | 2 +- src/server/dev.ts | 4 ++-- yarn.lock | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 9b186423c9..b48d3b226d 100644 --- a/package.json +++ b/package.json @@ -70,8 +70,8 @@ "object-hash": "^3.0.0", "ohmyfetch": "^0.4.15", "ora": "^6.1.0", - "p-debounce": "^4.0.0", "pathe": "^0.2.0", + "perfect-debounce": "^0.1.3", "pkg-types": "^0.3.2", "pretty-bytes": "^6.0.0", "rollup": "^2.70.1", diff --git a/src/server/dev.ts b/src/server/dev.ts index a854700288..3b00f60431 100644 --- a/src/server/dev.ts +++ b/src/server/dev.ts @@ -3,7 +3,7 @@ import { Worker } from 'worker_threads' import { IncomingMessage, ServerResponse } from 'http' import { existsSync, promises as fsp } from 'fs' import chokidar, { FSWatcher } from 'chokidar' -import debounce from 'p-debounce' +import { debounce } from 'perfect-debounce' import { promisifyHandle, createApp, Middleware, useBase } from 'h3' import httpProxy from 'http-proxy' import { listen, Listener, ListenOptions } from 'listhen' @@ -73,7 +73,7 @@ export function createDevServer (nitro: Nitro) { // Replace new worker as current currentWorker = newWorker } - const reload = debounce(() => _reload().catch(console.warn), 200, { before: true }) + const reload = debounce(() => _reload().catch(console.warn)) nitro.hooks.hook('nitro:dev:reload', reload) // App diff --git a/yarn.lock b/yarn.lock index c8c6a1e498..0e5b0fed9c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5121,8 +5121,8 @@ __metadata: object-hash: ^3.0.0 ohmyfetch: ^0.4.15 ora: ^6.1.0 - p-debounce: ^4.0.0 pathe: ^0.2.0 + perfect-debounce: ^0.1.3 pkg-types: ^0.3.2 pretty-bytes: ^6.0.0 rollup: ^2.70.1 @@ -5539,13 +5539,6 @@ __metadata: languageName: node linkType: hard -"p-debounce@npm:^4.0.0": - version: 4.0.0 - resolution: "p-debounce@npm:4.0.0" - checksum: 7f796f6ed264cb964b83601e70c4c0d94dd52d54e1361400ee80df7527217a59074aa14ab746d4d3089b352181c4ffb5329158fd679cb4b4b52c208574e9e56d - languageName: node - linkType: hard - "p-limit@npm:^1.1.0": version: 1.3.0 resolution: "p-limit@npm:1.3.0" @@ -5721,6 +5714,13 @@ __metadata: languageName: node linkType: hard +"perfect-debounce@npm:^0.1.3": + version: 0.1.3 + resolution: "perfect-debounce@npm:0.1.3" + checksum: c77465eb23d87669e5ee646d12331507c45278e0f2e6fc20a587104b956c1a53f9afe723915d882f73fa588e42770a2edd2bbd93eb0b958c9ff1eb7b915ccdc1 + languageName: node + linkType: hard + "picocolors@npm:^1.0.0": version: 1.0.0 resolution: "picocolors@npm:1.0.0"