🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@arcjet/duration

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arcjet/duration - npm Package Compare versions

Comparing version
1.3.0
to
1.3.1
+5
-5
package.json
{
"name": "@arcjet/duration",
"version": "1.3.0",
"version": "1.3.1",
"description": "Arcjet utilities for parsing duration strings",

@@ -47,7 +47,7 @@ "keywords": [

"devDependencies": {
"@arcjet/eslint-config": "1.3.0",
"@arcjet/rollup-config": "1.3.0",
"@rollup/wasm-node": "4.57.1",
"@arcjet/eslint-config": "1.3.1",
"@arcjet/rollup-config": "1.3.1",
"@rollup/wasm-node": "4.59.0",
"@types/node": "24.11.0",
"eslint": "9.39.2",
"eslint": "9.39.3",
"typescript": "5.9.3"

@@ -54,0 +54,0 @@ },

@@ -0,1 +1,3 @@

<!-- trunk-ignore-all(markdownlint/MD001) -->
<a href="https://arcjet.com" target="_arcjet-home">

@@ -47,3 +49,3 @@ <picture>

## Example
## Use

@@ -57,2 +59,41 @@ ```ts

## API
This package exports the identifier
[`parse`][api-parse].
There is no default export.
This package does not export [TypeScript][] types.
### `parse(value)`
Parses a duration into a number representing seconds while ensuring the value
fits within an unsigned 32-bit integer.
If you pass a number, it is validated and returned as-is.
If you pass a string, it must be in the form of digits followed by a unit.
Supported units are `s` (seconds),
`m` (minutes),
`h` (hours),
and `d` (days).
###### Parameters
- `value` (`number` or `string`)
— the duration to parse
###### Returns
Parsed seconds (`number`).
###### Example
```ts
console.log(parse("1s")); // => 1
console.log(parse("1m")); // => 60
console.log(parse("1h")); // => 3600
console.log(parse("1d")); // => 86400
```
## License

@@ -66,2 +107,3 @@

[api-parse]: #parsevalue
[arcjet]: https://arcjet.com

@@ -72,1 +114,2 @@ [go-parse-duration-license]: https://github.com/golang/go/blob/c18ddc84e/LICENSE

[github-vercel-ms]: https://github.com/vercel/ms
[typescript]: https://www.typescriptlang.org/