1.1.0 • Published 3 years ago

ts-duration v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

ts-duration

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`