@arcjet/duration
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-alpha.34 • Public • Published
Arcjet Logo

@arcjet/duration

npm badge

Arcjet utilities for parsing duration strings.

Installation

npm install -S @arcjet/duration

Example

import { parse } from "@arcjet/duration";

const seconds = parse("1h");
console.log(seconds); // prints 3600

Implementation

The implementation of this library is based on the ParseDuration function in the Go stdlib. Originally licensed BSD-3.0 with the license included in our source code.

We've chosen the approach of porting this to TypeScript because our protocol operates exclusively on unsigned 32-bit integers representing seconds. However, we don't want to require our SDK users to manually calculate seconds. By providing this utility, our SDK can accept duration strings and numbers while normalizing the values for our protocol.

License

Licensed under the Apache License, Version 2.0.

Readme

Keywords

none

Package Sidebar

Install

npm i @arcjet/duration

Homepage

arcjet.com

Weekly Downloads

6,319

Version

1.0.0-alpha.34

License

Apache-2.0

Unpacked Size

20.6 kB

Total Files

5

Last publish

Collaborators

  • blaine-arcjet
  • davidmytton