From e3806eaefd8842ecaedabbad0e6f87f300f0693f Mon Sep 17 00:00:00 2001 From: Kiko Beats Date: Sun, 8 Oct 2023 13:23:05 +0200 Subject: [PATCH] refactor: use @kikobeats/time-span --- package.json | 2 +- src/index.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index f411fae..8c779b6 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "request" ], "dependencies": { + "@kikobeats/time-span": "~1.0.2", "@metascraper/helpers": "~5.37.1", "cheerio": "~1.0.0-rc.12", "css-url-regex": "~4.0.0", @@ -43,7 +44,6 @@ "p-cancelable": "~2.1.0", "p-retry": "~4.6.0", "replace-string": "~3.1.0", - "time-span": "~4.0.0", "top-sites": "~1.1.169", "write-json-file": "~4.3.0" }, diff --git a/src/index.js b/src/index.js index a956b89..8314312 100644 --- a/src/index.js +++ b/src/index.js @@ -2,10 +2,10 @@ const { parseUrl, isMediaUrl } = require('@metascraper/helpers') const debug = require('debug-logfmt')('html-get') +const timeSpan = require('@kikobeats/time-span') const PCancelable = require('p-cancelable') const { AbortError } = require('p-retry') const htmlEncode = require('html-encode') -const timeSpan = require('time-span') const got = require('got') const autoDomains = require('./auto-domains') @@ -203,7 +203,7 @@ module.exports = PCancelable.fn( const toEncode = htmlEncode(encoding) const reqMode = getMode(targetUrl, { prerender }) - const time = timeSpan() + const duration = timeSpan() const promise = getContent(targetUrl, reqMode, { getBrowserless, @@ -218,7 +218,7 @@ module.exports = PCancelable.fn( const { mode, ...payload } = await promise - return Object.assign(payload, { stats: { mode, timing: time.rounded() } }) + return Object.assign(payload, { stats: { mode, timing: duration() } }) } )