X7ROOT File Manager
Current Path:
/opt/alt/alt-nodejs18/root/usr/lib/node_modules/npm/lib/utils
opt
/
alt
/
alt-nodejs18
/
root
/
usr
/
lib
/
node_modules
/
npm
/
lib
/
utils
/
ðŸ“
..
📄
audit-error.js
(1.02 KB)
📄
auth.js
(3.21 KB)
📄
cmd-list.js
(2.89 KB)
📄
completion.fish
(1.56 KB)
📄
completion.sh
(1.85 KB)
📄
did-you-mean.js
(1.16 KB)
📄
display.js
(15.38 KB)
📄
error-message.js
(14.6 KB)
📄
explain-dep.js
(3.03 KB)
📄
explain-eresolve.js
(2.56 KB)
📄
format-bytes.js
(629 B)
📄
format-search-stream.js
(4.7 KB)
📄
format.js
(1.91 KB)
📄
get-identity.js
(802 B)
📄
get-workspaces.js
(1.71 KB)
📄
installed-deep.js
(1.1 KB)
📄
installed-shallow.js
(583 B)
📄
is-windows.js
(177 B)
📄
log-file.js
(7.78 KB)
📄
npm-usage.js
(2.02 KB)
📄
open-url.js
(2.36 KB)
📄
output-error.js
(767 B)
📄
ping.js
(252 B)
📄
queryable.js
(9.56 KB)
📄
read-user-info.js
(1.91 KB)
📄
reify-finish.js
(886 B)
📄
reify-output.js
(5.65 KB)
📄
sbom-cyclonedx.js
(5.21 KB)
📄
sbom-spdx.js
(4.59 KB)
📄
tar.js
(3.47 KB)
📄
timers.js
(2.07 KB)
📄
update-workspaces.js
(1013 B)
📄
validate-lockfile.js
(1023 B)
📄
verify-signatures.js
(11.92 KB)
Editing: timers.js
const EE = require('node:events') const fs = require('node:fs') const { log, time } = require('proc-log') const INITIAL_TIMER = 'npm' class Timers extends EE { #file #timing #unfinished = new Map() #finished = {} constructor () { super() this.on() time.start(INITIAL_TIMER) this.started = this.#unfinished.get(INITIAL_TIMER) } on () { process.on('time', this.#timeHandler) } off () { process.off('time', this.#timeHandler) } load ({ path, timing } = {}) { this.#timing = timing this.#file = `${path}timing.json` } finish (metadata) { time.end(INITIAL_TIMER) for (const [name, timer] of this.#unfinished) { log.silly('unfinished npm timer', name, timer) } if (!this.#timing) { // Not in timing mode, nothing else to do here return } try { this.#writeFile(metadata) log.info('timing', `Timing info written to: ${this.#file}`) } catch (e) { log.warn('timing', `could not write timing file: ${e}`) } } #writeFile (metadata) { const globalStart = this.started const globalEnd = this.#finished[INITIAL_TIMER] const content = { metadata, timers: this.#finished, // add any unfinished timers with their relative start/end unfinishedTimers: [...this.#unfinished.entries()].reduce((acc, [name, start]) => { acc[name] = [start - globalStart, globalEnd - globalStart] return acc }, {}), } fs.writeFileSync(this.#file, JSON.stringify(content) + '\n') } #timeHandler = (level, name) => { const now = Date.now() switch (level) { case time.KEYS.start: this.#unfinished.set(name, now) break case time.KEYS.end: { if (this.#unfinished.has(name)) { const ms = now - this.#unfinished.get(name) this.#finished[name] = ms this.#unfinished.delete(name) log.timing(name, `Completed in ${ms}ms`) } else { log.silly('timing', `Tried to end timer that doesn't exist: ${name}`) } } } } } module.exports = Timers
Upload File
Create Folder