{"_id":"@axel669/timestring","name":"@axel669/timestring","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@axel669/timestring","version":"0.1.0","description":"Small library for parsing and generating simple timestrings.","main":"lib/main.mjs","scripts":{"test":"aegis tests/**/*.test.mjs","docs":"ipsen"},"keywords":[],"author":"","license":"MIT","devDependencies":{"@axel669/aegis":"^0.2.7","@axel669/ipsen":"^0.3.0"},"imports":{"#lib":"./lib/main.mjs"},"repository":{"type":"git","url":"git+https://github.com/axel669/lib.ipsen.git"},"gitHead":"b357156e3c37d389258a9c8cf3ea8fa6441538ee","bugs":{"url":"https://github.com/axel669/lib.ipsen/issues"},"homepage":"https://github.com/axel669/lib.ipsen#readme","_id":"@axel669/timestring@0.1.0","_nodeVersion":"18.12.1","_npmVersion":"8.5.3","dist":{"integrity":"sha512-dTF4AQeFOQsIl5WGfh4upAexlFwLJ1XR2YCCrCJdRKx1eZcDMng9b7qX+Yo1TkV0+5s6d6ketiAfBmMitEkDJQ==","shasum":"42e714410a6f727c0a99c30f760027f67158b376","tarball":"https://registry.npmjs.org/@axel669/timestring/-/timestring-0.1.0.tgz","fileCount":4,"unpackedSize":7873,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDWTj7Uvc83fjvzUJTYh/2R40SUs9+nVrTBF52BJvgcaAIhALWvKZ3hlyKlndBbknQJhKxZrki2irkrduv2rPTj+3Z0"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkDqWxACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpx9hAAl1siGL/8fMRs4P2RLAq3/DYuveeUEDIa8JYm4wOV8gXPatiq\r\na6DhNPf6Hay7pHqEDDI7OPiOYdAKyPWiuEpUaCm7X4AVmfatNt4xnAVGwNWp\r\nIEeJ1jhSZQ2wwb1tuWkdiPPMOw3VH4+XiQncfMQFkOX7PAerzAycFq3Qr3cb\r\nUeaYQCptLpTKRoylSF9QtG7dFAq/Ge0b1D3YBCkmGs8r+p/Uyv2uagvvtllK\r\nyj1KwvJL2GQgX4SUIBZ+7tv5xGR9fUrFM85AdcM9WLUH1kLaSC4zH7CIO5+E\r\n2yV6og6J1DaRhaOUIP254LyOx6vXmeyDDvGp7G/vuFzXA5U8vRCE2kXRIcvF\r\nPmgZzwhw2KStMe7obyYIvTX10+pD+Tjc3Iep+YqOUPdz64iuh3V6y+C7HXSs\r\n40CVil+d6z4drJ/GZyQqTW51QOWTuD+JFkU2stC8gncfx33tvEXn7Jkq4Op6\r\nEWCLBN2dTaUbTj3jErZJgKgvC4fo4YmbVh4KGfoCfvZx6mJpiit2wf1j0MwY\r\nTTRtQy7/UN2NAhwMkRbdR7qGjp9v7SbOT9mS42Sf6nTkHky1l2h4xFk6Zktv\r\nNL9EiCipO/D5Gh1CZ3DdMUgftoxO8gp90QQea3nt5fqE9gZSgLxLSaQhKdIX\r\nEfeco7qr7Fnm39C4qAoCIYPC0gMHDOVJu1c=\r\n=+SWP\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"axel669","email":"axel@axel669.net"},"directories":{},"maintainers":[{"name":"axel669","email":"axel@axel669.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/timestring_0.1.0_1678681521386_0.10611942925630657"},"_hasShrinkwrap":false}},"time":{"created":"2023-03-13T04:25:21.307Z","0.1.0":"2023-03-13T04:25:21.516Z","modified":"2023-03-13T04:25:21.711Z"},"maintainers":[{"name":"axel669","email":"axel@axel669.net"}],"description":"Small library for parsing and generating simple timestrings.","homepage":"https://github.com/axel669/lib.ipsen#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/axel669/lib.ipsen.git"},"bugs":{"url":"https://github.com/axel669/lib.ipsen/issues"},"license":"MIT","readme":"\n# Timestring\n\nSmall library for parsing and generating simple timestrings.\n\n## Installation\n```bash\npnpm add @axel669/timestring\n```\n\n## Usage\n\n### parse(string)\nReturns the number of milliseconds of the combined parsed time parts.  \nTime Part Format: `<time value><unit>` (`\"5m\"`, `\"1w\"`, `\"150ms\"`, etc)  \nThe string can have any number of time parts, and time parts with the same unit\nwill be added together. Any part of the string that isn't a time part will be\nignored.\n\n#### Supported Units\n- `w` - Weeks\n- `d` - Days\n- `h` - Hours\n- `m` - Minutes\n- `s` - Seconds\n- `ms` - Milliseconds\n\n#### Example\n```js\nimport tstring from \"@axel669/timestring\"\n\nconst duration = tstring.parse(\"15m 30s\")\n```\n\n### stringify(time, options)\nGenerates a time string from the time given, with options to control the output.\n\n#### options\n- #### options.format\n    > default: `\"short\"`.\n    The format to use for the units in the time string. Currently accepts\n    `\"short\"` and `\"long\"`. Long format will use plurals when appropriate.\n    ```js\n    // \"1s 337ms\"\n    tstring.stringify(1337)\n    // \"1 second, 337 miliseconds\"\n    tstring.stringify(1337, { format: \"long\" })\n    ```\n\n- #### options.returnError\n    > default: `false`\n    If `true`, stringify will return errors instead of throwing them.\n\n- #### options.show0s\n    > default: `false`\n    If `true`, the output will include every unit the formatter knows, putting\n    0s where necessary.\n    ```js\n    // \"0w 0d 0h 0m 1s 337ms\"\n    tstring.stringify(1337, { show0s: true })\n    // \"0 weeks, 0 days, 0 hours, 0 minutes, 1 second, 337 miliseconds\"\n    tstring.stringify(1337, { format: \"long\", show0s: true })\n    ```\n\n- #### options.sep\n    If given, will replace the normal separator for different parts in the time\n    string (`\" \"` for short format, `\", \"` for long format).\n    ```js\n    // \"1s|337ms\"\n    tstring.stringify(1337, { sep: \"|\" })\n    // \"0 weeks/0 days/0 hours/0 minutes/1 second/337 miliseconds\"\n    tstring.stringify(1337, { format: \"long\", sep: \"/\" })\n    ```","readmeFilename":"readme.md"}