ts-duration
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

ts-duration

NPM version

Type safe duration calculations in Javascript and Typescript! No more keeping track of units with silly variable names (I'm looking at you reallyLongVariableNameOfTimeDiffInMs 👀). This type is heavily inspired by the time.Duration type in Go (Golang).

Quick Start

Install with npm install ts-duration.

import { Duration } from 'ts-duration';

// ...

const a = Duration.millisecond(3500);
const b = Duration.second(4.2);
console.log(`${a} + ${b} = ${a.add(b)}`); // prints `3500ms + 4.2s = 7.7s`

Readme

Keywords

Package Sidebar

Install

npm i ts-duration

Weekly Downloads

776

Version

1.1.0

License

MIT

Unpacked Size

31.8 kB

Total Files

16

Last publish

Collaborators

  • hsson