UNPKG

@chassisjs/hermes

Version:

Production-Ready TypeScript Outbox Pattern

37 lines 1.13 kB
import { assert } from './utils/assert.js'; export class Duration { _ms; constructor(_ms) { this._ms = _ms; } get value() { return this._ms; } get ms() { return this._ms; } static from(duration) { return new Duration(duration.ms); } static ofDays(hours) { assert(hours >= 0, `hours has to be greater or equal 0`); return new Duration(hours * 24 * 60 * 60 * 1000); } static ofHours(hours) { assert(hours >= 0, `hours has to be greater or equal 0`); return new Duration(hours * 60 * 60 * 1000); } static ofMinutes(minutes) { assert(minutes >= 0, `minutes has to be greater or equal 0`); return new Duration(minutes * 60 * 1000); } static ofSeconds(seconds) { assert(seconds >= 0, `seconds has to be greater or equal 0`); return new Duration(seconds * 1000); } static ofMiliseconds(miliseconds) { assert(miliseconds >= 0, `miliseconds has to be greater or equal 0`); return new Duration(miliseconds); } } //# sourceMappingURL=duration.js.map