tailwindcss/packages/@tailwindcss-cli/src/utils/format-ns.ts
Robin Malfait 0597489604
Move the CLI to its own package @tailwindcss/cli (#13095)
* move `cli` to its own package `@tailwindcss/cli`

* minify builds when using `tsup`

* prefer tsup cli flag over tsup.config.ts file

* add `--clean`, to make sure `dist/` folders are cleaned before building

* make CLI esm only

* use version of `tailwindcss` instead of the version of `@tailwindcss/cli`
2024-03-06 05:41:12 -05:00

23 lines
434 B
TypeScript

export function formatNanoseconds(input: bigint | number) {
let ns = typeof input === 'number' ? BigInt(input) : input
if (ns < 1_000n) return `${ns}ns`
ns /= 1_000n
if (ns < 1_000n) return `${ns}µs`
ns /= 1_000n
if (ns < 1_000n) return `${ns}ms`
ns /= 1_000n
if (ns < 60n) return `${ns}s`
ns /= 60n
if (ns < 60n) return `${ns}m`
ns /= 60n
if (ns < 24n) return `${ns}h`
ns /= 24n
return `${ns}d`
}