{"_id":"@akshitkrnagpal/ms","name":"@akshitkrnagpal/ms","dist-tags":{"latest":"3.0.0-fork.1"},"versions":{"3.0.0-fork.1":{"name":"@akshitkrnagpal/ms","version":"3.0.0-fork.1","description":"Tiny millisecond conversion utility","repository":{"type":"git","url":"git+https://github.com/akshikrnagpal/ms.git"},"main":"./dist/index.cjs","type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"}},"module":"./dist/index.mjs","types":"./dist/index.d.ts","sideEffects":false,"license":"MIT","engines":{"node":">=12.13"},"jest":{"preset":"ts-jest","testEnvironment":"node"},"prettier":"@vercel/style-guide/prettier","lint-staged":{"*":["prettier --ignore-unknown --write"],"*.{js,jsx,ts,tsx}":["eslint --max-warnings=0 --fix"]},"devDependencies":{"@edge-runtime/jest-environment":"1.1.0-beta.6","@types/jest":"27.0.1","@vercel/style-guide":"3.0.0","eslint":"8.12.0","husky":"7.0.2","jest":"27.1.1","lint-staged":"11.1.2","prettier":"2.6.2","ts-jest":"27.0.5","typescript":"4.6.3"},"scripts":{"test":"npm run test-nodejs && npm run test-edge","test-nodejs":"jest --env node","test-edge":"jest --env @edge-runtime/jest-environment","build":"scripts/build.js","eslint-check":"eslint --max-warnings=0 .","prettier-check":"prettier --check .","type-check":"tsc --noEmit","precommit":"lint-staged"},"bugs":{"url":"https://github.com/akshikrnagpal/ms/issues"},"homepage":"https://github.com/akshikrnagpal/ms#readme","_id":"@akshitkrnagpal/ms@3.0.0-fork.1","_integrity":"sha512-huhdTTDRzxXTpxv1gFCt0Xdky/XiyNDhrFhUHfCBupsVMS793S/RQJi8vaT2obHkTFJnU2/2JKQfFdi9RjZLOA==","_resolved":"/private/var/folders/2v/_p1s1r7934176t5qgqdg1vjc0000gn/T/bddb21d48bbce05da1749b0e2e972a05/akshitkrnagpal-ms-3.0.0-fork.1.tgz","_from":"file:akshitkrnagpal-ms-3.0.0-fork.1.tgz","_nodeVersion":"18.19.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-huhdTTDRzxXTpxv1gFCt0Xdky/XiyNDhrFhUHfCBupsVMS793S/RQJi8vaT2obHkTFJnU2/2JKQfFdi9RjZLOA==","shasum":"6f74433d1dc427695f49a7999d4222f8a3f6ff22","tarball":"https://registry.npmjs.org/@akshitkrnagpal/ms/-/ms-3.0.0-fork.1.tgz","fileCount":6,"unpackedSize":18527,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCb1IeGsZkNoXLOhkBF+6FlN1tD3oLU9nBi9bRJLmyq7AIgJ6swlidXPuDusSTLVOC7RjMx94nHrWoeYu9FzCxy2Iw="}]},"_npmUser":{"name":"akshitkrnagpal","email":"nagpalkrakshit@gmail.com"},"directories":{},"maintainers":[{"name":"akshitkrnagpal","email":"nagpalkrakshit@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ms_3.0.0-fork.1_1742315147554_0.7470021921475554"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-18T16:25:47.476Z","3.0.0-fork.1":"2025-03-18T16:25:47.751Z","modified":"2025-03-18T16:25:48.015Z"},"maintainers":[{"name":"akshitkrnagpal","email":"nagpalkrakshit@gmail.com"}],"description":"Tiny millisecond conversion utility","homepage":"https://github.com/akshikrnagpal/ms#readme","repository":{"type":"git","url":"git+https://github.com/akshikrnagpal/ms.git"},"bugs":{"url":"https://github.com/akshikrnagpal/ms/issues"},"license":"MIT","readme":"# ms\n\n![CI](https://github.com/vercel/ms/workflows/CI/badge.svg)\n![Edge Runtime Compatible](https://img.shields.io/badge/edge--runtime-%E2%9C%94%20compatible-black)\n\nUse this package to easily convert various time formats to milliseconds.\n\n## Examples\n\n<!-- prettier-ignore -->\n```js\nms('2 days')  // 172800000\nms('1d')      // 86400000\nms('10h')     // 36000000\nms('2.5 hrs') // 9000000\nms('2h')      // 7200000\nms('1m')      // 60000\nms('5s')      // 5000\nms('1y')      // 31557600000\nms('100')     // 100\nms('-3 days') // -259200000\nms('-1h')     // -3600000\nms('-200')    // -200\n```\n\n### Convert from Milliseconds\n\n<!-- prettier-ignore -->\n```js\nms(60000)             // \"1m\"\nms(2 * 60000)         // \"2m\"\nms(-3 * 60000)        // \"-3m\"\nms(ms('10 hours'))    // \"10h\"\n```\n\n### Time Format Written-Out\n\n<!-- prettier-ignore -->\n```js\nms(60000, { long: true })             // \"1 minute\"\nms(2 * 60000, { long: true })         // \"2 minutes\"\nms(-3 * 60000, { long: true })        // \"-3 minutes\"\nms(ms('10 hours'), { long: true })    // \"10 hours\"\n```\n\n## Features\n\n- Works both in [Node.js](https://nodejs.org) and in the browser\n- If a number is supplied to `ms`, a string with a unit is returned\n- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`)\n- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned\n\n## TypeScript support\n\nAs of `v3.0`, this package includes TypeScript definitions.\n\nFor added safety, we're using [Template Literal Types](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html) (added in [TypeScript 4.1](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-1.html)). This ensures that you don't accidentally pass `ms` values that it can't process.\n\nThis won't require you to do anything special in most situations, but you can also import the `StringValue` type from `ms` if you need to use it.\n\n```ts\nimport ms, { StringValue } from 'ms';\n\n// Using the exported type.\nfunction example(value: StringValue) {\n  ms(value);\n}\n\n// This function will only accept a string compatible with `ms`.\nexample('1 h');\n```\n\nIn this example, we use a [Type Assertion](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions) to coerce a `string`.\n\n```ts\nimport ms, { StringValue } from 'ms';\n\n// Type assertion with the exported type.\nfunction example(value: string) {\n  try {\n    // A string could be \"wider\" than the values accepted by `ms`, so we assert\n    // that our `value` is a `StringValue`.\n    //\n    // It's important to note that this can be dangerous (see below).\n    ms(value as StringValue);\n  } catch (error: Error) {\n    // Handle any errors from invalid values.\n    console.error(error);\n  }\n}\n\n// This function will accept any string, which may result in a bug.\nexample('any value');\n```\n\nYou may also create a custom Template Literal Type.\n\n```ts\nimport ms from 'ms';\n\ntype OnlyDaysAndWeeks = `${number} ${'days' | 'weeks'}`;\n\n// Using a custom Template Literal Type.\nfunction example(value: OnlyDaysAndWeeks) {\n  // The type of `value` is narrower than the values `ms` accepts, which is\n  // safe to use without coercion.\n  ms(value);\n}\n\n// This function will accept \"# days\" or \"# weeks\" only.\nexample('5.2 days');\n```\n\n## Advanced Usage\n\nAs of `v3.0`, you can import `parse` and `format` separately.\n\n```ts\nimport { parse, format } from 'ms';\n\nparse('1h'); // 3600000\n\nformat(2000); // \"2s\"\n```\n\nIf you want strict type checking for the input value, you can use `parseStrict`.\n\n```ts\nimport { parseStrict } from 'ms';\n\nparseStrict('1h'); // 3600000\n\nfunction example(s: string) {\n  return parseStrict(str); // tsc error\n}\n```\n\n## Edge Runtime Support\n\n`ms` is compatible with the [Edge Runtime](https://edge-runtime.vercel.app/). It can be used inside environments like [Vercel Edge Functions](https://vercel.com/edge) as follows:\n\n```js\n// Next.js (pages/api/edge.js) (npm i next@canary)\n// Other frameworks (api/edge.js) (npm i -g vercel@canary)\n\nimport ms from 'ms';\nconst start = Date.now();\n\nexport default (req) => {\n  return new Response(`Alive since ${ms(Date.now() - start)}`);\n};\n\nexport const config = {\n  runtime: 'experimental-edge',\n};\n```\n\n## Related Packages\n\n- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time.\n\n## Caught a Bug?\n\n1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device\n2. Link the package to the global module directory: `npm link`\n3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms!\n\nAs always, you can run the tests using: `npm test`\n","readmeFilename":"readme.md","_rev":"1-a88a3c1f1b0a509814b919258ba9c63b"}