UNPKG

html-to-pdf-converter

Version:

HTML to PDF converter with support for HEADERS, FOOTERS and page numbers

25 lines 914 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class ExecutionTimer { constructor() { this.start = process.hrtime(); this.logs = []; } log(tag, format = false) { const time = process.hrtime(this.start); this.logs.push({ tag, time }); this.start = process.hrtime(); return format ? `${tag}: ${this.format(time)}` : time; } format(time) { return `${time[0]}s ${time[1] / 1000000}ms`; } toString() { const NS_PER_SEC = 1e9; const logs = this.logs.map(({ tag, time }) => `${tag}: ${this.format(time)}`); const total = this.logs.reduce(([s, n], { time: t }) => [s + t[0], n + t[1]], [0, 0]); return logs.join('\n') + `\ntotal: ${(total[0] * NS_PER_SEC + total[1]) / NS_PER_SEC}s`; } } exports.ExecutionTimer = ExecutionTimer; //# sourceMappingURL=execution-timer.js.map