storybook
Version:
Storybook: Develop, document, and test UI components in isolation
91 lines (86 loc) • 3.03 kB
JavaScript
import CJS_COMPAT_NODE_URL_q99y7iqlbzn from 'node:url';
import CJS_COMPAT_NODE_PATH_q99y7iqlbzn from 'node:path';
import CJS_COMPAT_NODE_MODULE_q99y7iqlbzn from "node:module";
var __filename = CJS_COMPAT_NODE_URL_q99y7iqlbzn.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_q99y7iqlbzn.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_q99y7iqlbzn.createRequire(import.meta.url);
// ------------------------------------------------------------
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
// ------------------------------------------------------------
import {
__commonJS
} from "./chunk-MB5KTO7X.js";
// ../node_modules/pretty-hrtime/index.js
var require_pretty_hrtime = __commonJS({
"../node_modules/pretty-hrtime/index.js"(exports, module) {
"use strict";
var minimalDesc = ["h", "min", "s", "ms", "\u03BCs", "ns"];
var verboseDesc = ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"];
var convert = [60 * 60, 60, 1, 1e6, 1e3, 1];
module.exports = function(source, opts) {
var verbose, precise, i, spot, sourceAtStep, valAtStep, decimals, strAtStep, results, totalSeconds;
verbose = false;
precise = false;
if (opts) {
verbose = opts.verbose || false;
precise = opts.precise || false;
}
if (!Array.isArray(source) || source.length !== 2) {
return "";
}
if (typeof source[0] !== "number" || typeof source[1] !== "number") {
return "";
}
if (source[1] < 0) {
totalSeconds = source[0] + source[1] / 1e9;
source[0] = parseInt(totalSeconds);
source[1] = parseFloat((totalSeconds % 1).toPrecision(9)) * 1e9;
}
results = "";
for (i = 0; i < 6; i++) {
spot = i < 3 ? 0 : 1;
sourceAtStep = source[spot];
if (i !== 3 && i !== 0) {
sourceAtStep = sourceAtStep % convert[i - 1];
}
if (i === 2) {
sourceAtStep += source[1] / 1e9;
}
valAtStep = sourceAtStep / convert[i];
if (valAtStep >= 1) {
if (verbose) {
valAtStep = Math.floor(valAtStep);
}
if (!precise) {
decimals = valAtStep >= 10 ? 0 : 2;
strAtStep = valAtStep.toFixed(decimals);
} else {
strAtStep = valAtStep.toString();
}
if (strAtStep.indexOf(".") > -1 && strAtStep[strAtStep.length - 1] === "0") {
strAtStep = strAtStep.replace(/\.?0+$/, "");
}
if (results) {
results += " ";
}
results += strAtStep;
if (verbose) {
results += " " + verboseDesc[i];
if (strAtStep !== "1") {
results += "s";
}
} else {
results += " " + minimalDesc[i];
}
if (!verbose) {
break;
}
}
}
return results;
};
}
});
export {
require_pretty_hrtime
};