{"_id":"pretty-ms@9.3.1","bugs":{"url":"https://github.com/sindresorhus/pretty-ms/issues"},"dist":{"shasum":"7b58d8fbf376f01602ff05230358e8fa5e0f072b","tarball":"http://registry-npm.ywwl.com/pretty-ms/download/pretty-ms-9.3.1.tgz","fileCount":5,"integrity":"sha512-HzMy3Geq23nVALD/M2LliU+F+M+gVNsvkQWWqeBZ8HDiCgzo6YPJ/Omrmtq24EFrIsk0a3EkQGEd7bDOo+IhGA==","signatures":[{"sig":"MEUCIQCFu4hNhfsbCFztVX/l5+ccnypCagILevUAhBIMjgUYxAIga1c0QL8OlRfrJEU9SyWx3DlvbL1Dgk2sg3UUy52gEOU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDuKcf0zFv/9gi/IYD+WT4R8biVbYYKbVPkXB5rU6Mr9wIhALk/azMuVjVzzxyvgTCQwqS1cgYOb8COfaaj62p4VUWr"}],"unpackedSize":15689,"size":4863,"noattachment":false,"key":"/pretty-ms/-/pretty-ms-9.3.1.tgz"},"name":"pretty-ms","type":"module","types":"./index.d.ts","author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"engines":{"node":">=18"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"e9e798bce63bbe4a4dd033e3ddca6f9243970375","license":"MIT","scripts":{"test":"xo && ava && tsd"},"version":"9.3.1","_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.0.1","description":"Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`","directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"sideEffects":false,"_nodeVersion":"22.23.1","dependencies":{"parse-ms":"^4.0.0"},"_hasShrinkwrap":false,"devDependencies":{"xo":"^0.59.3","ava":"^6.2.0","tsd":"^0.31.2"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pretty-ms_9.3.1_1787920324382_0.7639051141514432"},"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\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\n##### millisecondsDecimalDigits\n\nType: `number`\\\nDefault: `0`\n\nNumber of digits to appear after the milliseconds decimal point.\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.\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\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`\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\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\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\n## FAQ\n\n### Why doesn't this package support months or years?\n\nThis package formats time durations, not calendar dates. Months (28-31 days) and years (365-366 days) have variable lengths, making duration calculations ambiguous. Days are the largest unit since they're 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":1787920324471,"_cnpm_publish_time":1787920324471,"dist-tags":{"latest":"10.0.0"}}