@samual/duration
Advanced tools
+77
| import type { LaxPartial } from "@samual/types"; | ||
| /** | ||
| * A duration of time. | ||
| * | ||
| * All properties are optional and must be set to | ||
| * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) or an integer | ||
| * (be able to pass | ||
| * [`Number.isInteger()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)). | ||
| * Absent properties and properties set to `undefined` are treated the same. | ||
| * More units of time will be added in the future. | ||
| * | ||
| * @example Basic Usage | ||
| * ```ts | ||
| * import type { Duration } from "@samual/duration" | ||
| * | ||
| * let duration: Duration = { milliseconds: Date.now() } | ||
| * ``` | ||
| */ | ||
| export type Duration = LaxPartial<{ | ||
| /** | ||
| * The number of years in the duration. Same as 365 days. | ||
| * | ||
| * Must be set to | ||
| * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) or an | ||
| * integer (be able to pass | ||
| * [`Number.isInteger()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)). | ||
| */ | ||
| years: number; | ||
| /** | ||
| * The number of days in the duration. Same as 24 hours | ||
| * | ||
| * Must be set to | ||
| * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) or an | ||
| * integer (be able to pass | ||
| * [`Number.isInteger()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)). | ||
| */ | ||
| days: number; | ||
| /** | ||
| * The number of hours in the duration. Same as 60 minutes | ||
| * | ||
| * Must be set to | ||
| * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) or an | ||
| * integer (be able to pass | ||
| * [`Number.isInteger()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)). | ||
| */ | ||
| hours: number; | ||
| /** | ||
| * The number of minutes in the duration. Same as 60 seconds | ||
| * | ||
| * Must be set to | ||
| * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) or an | ||
| * integer (be able to pass | ||
| * [`Number.isInteger()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)). | ||
| */ | ||
| minutes: number; | ||
| /** | ||
| * The number of seconds in the duration. Same as 1000 milliseconds | ||
| * | ||
| * Must be set to | ||
| * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) or an | ||
| * integer (be able to pass | ||
| * [`Number.isInteger()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)). | ||
| */ | ||
| seconds: number; | ||
| /** | ||
| * The number of milliseconds in the duration. | ||
| * | ||
| * Must be set to | ||
| * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) or an | ||
| * integer (be able to pass | ||
| * [`Number.isInteger()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)). | ||
| */ | ||
| milliseconds: number; | ||
| }>; | ||
| export { DurationError } from "./DurationError"; | ||
| export { formatDuration, FormatDurationError, FormatEmptyDurationError, FormatNonIntegerDurationError, type FormatDurationOptions } from "./formatDuration"; | ||
| export { normalizeDuration, NormalizeDurationError, NormalizeNonIntegerDurationError } from "./normalizeDuration"; |
| export { DurationError } from "./DurationError.js" | ||
| export { | ||
| FormatDurationError, | ||
| FormatEmptyDurationError, | ||
| FormatNonIntegerDurationError, | ||
| formatDuration | ||
| } from "./formatDuration.js" | ||
| export { NormalizeDurationError, NormalizeNonIntegerDurationError, normalizeDuration } from "./normalizeDuration.js" |
@@ -15,3 +15,3 @@ /** | ||
| import { DurationError } from "./DurationError"; | ||
| import type { Duration } from "./index"; | ||
| import type { Duration } from "./default"; | ||
| /** | ||
@@ -18,0 +18,0 @@ * Error that can be thrown by {@linkcode formatDuration()}. |
@@ -17,3 +17,3 @@ /** | ||
| import { DurationError } from "./DurationError"; | ||
| import type { Duration } from "./index"; | ||
| import type { Duration } from "./default"; | ||
| /** | ||
@@ -20,0 +20,0 @@ * Error that can be thrown by {@linkcode normalizeDuration()}. |
+3
-3
| { | ||
| "name": "@samual/duration", | ||
| "version": "0.0.1-fd6847c", | ||
| "version": "0.0.1", | ||
| "description": "Normalize and format durations of time.", | ||
@@ -23,6 +23,6 @@ "keywords": [ | ||
| "engines": { | ||
| "node": "^20.10 || >=22" | ||
| "node": "^20.10 || ^22 || >=24" | ||
| }, | ||
| "exports": { | ||
| ".": "./index.js", | ||
| ".": "./default.js", | ||
| "./DurationError": "./DurationError.js", | ||
@@ -29,0 +29,0 @@ "./formatDuration": "./formatDuration.js", |
-77
| import type { LaxPartial } from "@samual/types"; | ||
| /** | ||
| * A duration of time. | ||
| * | ||
| * All properties are optional and must be set to | ||
| * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) or an integer | ||
| * (be able to pass | ||
| * [`Number.isInteger()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)). | ||
| * Absent properties and properties set to `undefined` are treated the same. | ||
| * More units of time will be added in the future. | ||
| * | ||
| * @example Basic Usage | ||
| * ```ts | ||
| * import type { Duration } from "@samual/duration" | ||
| * | ||
| * let duration: Duration = { milliseconds: Date.now() } | ||
| * ``` | ||
| */ | ||
| export type Duration = LaxPartial<{ | ||
| /** | ||
| * The number of years in the duration. Same as 365 days. | ||
| * | ||
| * Must be set to | ||
| * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) or an | ||
| * integer (be able to pass | ||
| * [`Number.isInteger()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)). | ||
| */ | ||
| years: number; | ||
| /** | ||
| * The number of days in the duration. Same as 24 hours | ||
| * | ||
| * Must be set to | ||
| * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) or an | ||
| * integer (be able to pass | ||
| * [`Number.isInteger()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)). | ||
| */ | ||
| days: number; | ||
| /** | ||
| * The number of hours in the duration. Same as 60 minutes | ||
| * | ||
| * Must be set to | ||
| * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) or an | ||
| * integer (be able to pass | ||
| * [`Number.isInteger()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)). | ||
| */ | ||
| hours: number; | ||
| /** | ||
| * The number of minutes in the duration. Same as 60 seconds | ||
| * | ||
| * Must be set to | ||
| * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) or an | ||
| * integer (be able to pass | ||
| * [`Number.isInteger()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)). | ||
| */ | ||
| minutes: number; | ||
| /** | ||
| * The number of seconds in the duration. Same as 1000 milliseconds | ||
| * | ||
| * Must be set to | ||
| * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) or an | ||
| * integer (be able to pass | ||
| * [`Number.isInteger()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)). | ||
| */ | ||
| seconds: number; | ||
| /** | ||
| * The number of milliseconds in the duration. | ||
| * | ||
| * Must be set to | ||
| * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) or an | ||
| * integer (be able to pass | ||
| * [`Number.isInteger()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)). | ||
| */ | ||
| milliseconds: number; | ||
| }>; | ||
| export { DurationError } from "./DurationError"; | ||
| export { formatDuration, FormatDurationError, FormatEmptyDurationError, FormatNonIntegerDurationError, type FormatDurationOptions } from "./formatDuration"; | ||
| export { normalizeDuration, NormalizeDurationError, NormalizeNonIntegerDurationError } from "./normalizeDuration"; |
-8
| export { DurationError } from "./DurationError.js" | ||
| export { | ||
| FormatDurationError, | ||
| FormatEmptyDurationError, | ||
| FormatNonIntegerDurationError, | ||
| formatDuration | ||
| } from "./formatDuration.js" | ||
| export { NormalizeDurationError, NormalizeNonIntegerDurationError, normalizeDuration } from "./normalizeDuration.js" |
26604
0.02%