{"xo":[{"files":["test.js"],"rules":{"node-test/require-assertion":"off","node-test/no-conditional-assertion":"off"}}],"_id":"pretty-ms@10.0.0","bugs":{"url":"https://github.com/sindresorhus/pretty-ms/issues"},"dist":{"shasum":"3a223bfea7625711955557f1a58389b80d9ed00c","tarball":"http://registry-npm.ywwl.com/pretty-ms/download/pretty-ms-10.0.0.tgz","fileCount":5,"integrity":"sha512-6BWuxY2dCNgT45VnGzZcfNy7WeLqXiZqhhy4aHThTE6KI56R2ZBw9HQ7spPFKYchDizvJbPxTEknIpmW4FSmQA==","signatures":[{"sig":"MEQCIAQA9Y4giiIubgvggjTSIX2CEx2D61S8q1BSciBsLQuXAiAy7TM1USrixf/WiPtQE9KRKWAkYQ5hgpPWLmrTRpiMKg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIH7MX9d5Y2hbvCiJNuUKEemiB+rPUrmJSivPFREtP6/tAiEAhptPXGAnhctbIuZRXT4LGY9KVZvheawgMClc4+9uhC4="}],"unpackedSize":24413,"size":7291,"noattachment":false,"key":"/pretty-ms/-/pretty-ms-10.0.0.tgz"},"name":"pretty-ms","type":"module","types":"./index.d.ts","author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"engines":{"node":">=22"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"a0410bb189906b25000fc118ce06ba84c07971c6","license":"MIT","scripts":{"test":"xo && node --test && nz"},"version":"10.0.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"homepage":"https://github.com/sindresorhus/pretty-ms#readme","keywords":["pretty","prettify","human","humanize","humanized","readable","time","ms","milliseconds","duration","period","range","text","string","number","hrtime"],"repository":{"url":"git+https://github.com/sindresorhus/pretty-ms.git","type":"git"},"_npmVersion":"12.2.0","description":"Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`","directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"sideEffects":false,"_nodeVersion":"26.11.1","_hasShrinkwrap":false,"devDependencies":{"nz":"^0.1.0","xo":"^5.0.1","@typescript/native":"npm:typescript@^7.0.2"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pretty-ms_10.0.0_1791956041030_0.44317621291132325"},"readme":"# pretty-ms\n\n> Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`\n\n*See [`parse-duration-ms`](https://github.com/sindresorhus/parse-duration-ms) for the inverse.*\n\n## Install\n\n```sh\nnpm install pretty-ms\n```\n\n## Usage\n\n```js\nimport prettyMilliseconds from 'pretty-ms';\n\nprettyMilliseconds(1337000000);\n//=> '15d 11h 23m 20s'\n\nprettyMilliseconds(1337000000n);\n//=> '15d 11h 23m 20s'\n\nprettyMilliseconds(1337);\n//=> '1.3s'\n\nprettyMilliseconds(133);\n//=> '133ms'\n\n// `compact` option\nprettyMilliseconds(1337, {compact: true});\n//=> '1s'\n\n// `verbose` option\nprettyMilliseconds(1335669000, {verbose: true});\n//=> '15 days 11 hours 1 minute 9 seconds'\n\n// `colonNotation` option\nprettyMilliseconds(95500, {colonNotation: true});\n//=> '1:35.5'\n\n// `formatSubMilliseconds` option\nprettyMilliseconds(100.400080, {formatSubMilliseconds: true})\n//=> '100ms 400µs 80ns'\n\n// `subSecondsAsDecimals` option\nprettyMilliseconds(900, {subSecondsAsDecimals: true});\n//=> '0.9s'\n\n// Can be useful for time durations\nprettyMilliseconds(new Date(2014, 0, 1, 10, 40) - new Date(2014, 0, 1, 10, 5))\n//=> '35m'\n```\n\n## API\n\n### prettyMilliseconds(milliseconds, options?)\n\n#### milliseconds\n\nType: `number | bigint`\n\nMilliseconds to humanize.\n\nAn integer (`number` or `bigint`) is exact at any size.\n\nA fractional number is first rounded to 15 significant digits, the precision of a number, which removes float noise:\n\n- `0.57 * 100_000` (`56999.99999999999`) is `57s`.\n- `999.9999999999999` (16 digits) is `1s`, but `999.99999999999` (14 digits) is `999ms`.\n\nFrom `1e14` milliseconds (about 3,170 years) up, no digits are left for the fraction, so the duration is rounded to whole milliseconds, and from `1e15` (about 31,700 years) up, to the nearest 10 milliseconds.\n\n#### options\n\nType: `object`\n\n##### secondsDecimalDigits\n\nType: `number`\\\nDefault: `1`\n\nNumber of digits to appear after the seconds decimal point.\n\nDigits are floored, not rounded, so the seconds never round up into the next step: `1999ms` is `1.9s`, and at `0` digits it is `1s`, never `2s`. The flooring applies to the duration after it is read (see `milliseconds` for how a fractional number is read).\n\n##### millisecondsDecimalDigits\n\nType: `number`\\\nDefault: `0`\n\nNumber of digits to appear after the milliseconds decimal point.\n\nThe milliseconds are rounded, not floored, but they never round up to `1000ms`, and a nonzero duration under a second never rounds down to `0ms`: `999.6ms` is `999ms`, and `0.2ms` is `1ms`. This does not apply with `formatSubMilliseconds`, which floors instead.\n\nUseful in combination with [`process.hrtime()`](https://nodejs.org/api/process.html#process_process_hrtime_time).\n\n##### keepDecimalsOnWholeSeconds\n\nType: `boolean`\\\nDefault: `false`\n\nKeep milliseconds on whole seconds: `13s` → `13.0s`.\n\nUseful when you are showing a number of seconds spent on an operation and don't want the width of the output to change when hitting a whole number.\n\n##### compact\n\nType: `boolean`\\\nDefault: `false`\n\nOnly show the first unit: `1h 10m` → `1h`.\n\nAlso ensures that `millisecondsDecimalDigits` and `secondsDecimalDigits` are both set to `0`.\n\n##### unitCount\n\nType: `number`\\\nDefault: `Infinity`\n\nNumber of units to show. Setting `compact` to `true` overrides this option. It is ignored with `colonNotation`.\n\n##### verbose\n\nType: `boolean`\\\nDefault: `false`\n\nUse full-length units: `5h 1m 45s` → `5 hours 1 minute 45 seconds`\n\n##### separateMilliseconds\n\nType: `boolean`\\\nDefault: `false`\n\nShow milliseconds separately. This means they won't be included in the decimal part of the seconds.\n\n##### formatSubMilliseconds\n\nType: `boolean`\\\nDefault: `false`\n\nShow microseconds and nanoseconds.\n\nThe values are floored to whole nanoseconds, so a duration under 1 nanosecond is `0ms`.\n\n##### colonNotation\n\nType: `boolean`\\\nDefault: `false`\n\nDisplay time using colon notation: `5h 1m 45s` → `5:01:45`. Always shows time in at least minutes: `1s` → `0:01`, or in at least hours with `hideSeconds`: `1m` → `0:01`.\n\nUseful when you want to display time without the time units, similar to a digital watch.\n\nSetting `colonNotation` to `true` overrides the following options to `false`:\n- `compact`\n- `formatSubMilliseconds`\n- `separateMilliseconds`\n- `verbose`\n\nDays after a year are padded to 3 digits to keep the width: `1:005:00:00:00`.\n\nIt also ignores `unitCount`, as dropping a field would change what the remaining fields mean: `1:01:01` would become `1:01`, which reads as 1 minute.\n\n##### hideYear\n\nType: `boolean`\\\nDefault: `false`\n\nHides the year and shows the hidden year additionally as days (365 per year): `1y 3d 5h 1m 45s` → `368d 5h 1m 45s`.\n\n##### hideYearAndDays\n\nType: `boolean`\\\nDefault: `false`\n\nHides the year and days and shows the hidden values additionally as hours: `1y 3d 5h 1m 45s` → `8837h 1m 45s`.\n\n##### hideSeconds\n\nType: `boolean`\\\nDefault: `false`\n\nHides the seconds: `1y 3d 5h 1m 45s` → `1y 3d 5h 1m`.\n\nA duration under a minute has no coarser unit, so it keeps its seconds rather than showing nothing. With `colonNotation`, the hours are always shown, so the fields read as `h:mm`: `60000` → `0:01`, and `45000` → `0:00:45`.\n\n##### subSecondsAsDecimals\n\nType: `boolean`\\\nDefault: `false`\n\nShow sub-second values as decimal seconds: `900ms` → `0.9s`.\n\nUseful for progress indicators where you want consistent unit format to prevent flickering.\n\nAlso floored, so `999ms` is `0.9s`.\n\nA duration too small for the seconds field to show, like `50ms` at the default `secondsDecimalDigits` of `1`, stays in milliseconds rather than showing as zero. With `compact`, the seconds have no decimals, so a duration under a second stays in milliseconds.\n\n## FAQ\n\n### Why doesn't this package support months?\n\nThis package formats time durations, not calendar dates. Months (28-31 days) have variable lengths, making duration calculations ambiguous. Years are shown as a fixed 365 days, so they do not account for leap years. Use the [`hideYear`](#hideyear) option to show days as the largest unit, since days are always exactly 24 hours. For calendar-based formatting, use [Temporal API](https://tc39.es/proposal-temporal/docs/) or a date library like [date-fns](https://github.com/date-fns/date-fns).\n\n### Why doesn't the formatted difference of two values match the formatted values?\n\n```js\nprettyMilliseconds(3670);        //=> '3.6s'\nprettyMilliseconds(5230);        //=> '5.2s'\nprettyMilliseconds(5230 - 3670); //=> '1.5s' // Not '1.6s'\n```\n\nThis is inherent to displaying rounded numbers, the same reason [rounded percentages don't always add up to 100%](https://help.surveymonkey.com/en/surveymonkey/analyze/percents-not-totaling/). Values are rounded independently, and rounding does not distribute over subtraction. `prettyMilliseconds(5230 - 3670)` correctly represents the true difference; it just won't always match subtracting the two rounded strings by eye.\n\n## Related\n\n- [pretty-ms-cli](https://github.com/sindresorhus/pretty-ms-cli) - CLI for this module\n- [parse-ms](https://github.com/sindresorhus/parse-ms) - Parse milliseconds into an object\n- [to-milliseconds](https://github.com/sindresorhus/to-milliseconds) - Convert an object of time properties to milliseconds\n- [parse-duration-ms](https://github.com/sindresorhus/parse-duration-ms) - Parse duration strings to milliseconds\n- [pretty-bytes](https://github.com/sindresorhus/pretty-bytes) - Convert bytes to a human readable string\n","publish_time":1791956041122,"_cnpm_publish_time":1791956041122,"dist-tags":{"latest":"10.0.0"}}