qstd 0.3.65 → 0.3.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client/index.cjs
CHANGED
|
@@ -281,8 +281,14 @@ var formatDuration = (value, options = {}) => {
|
|
|
281
281
|
showMs = false,
|
|
282
282
|
spaces = true
|
|
283
283
|
} = options;
|
|
284
|
+
const isMs = unit === "ms";
|
|
284
285
|
const isSeconds = unit === "seconds" || unit === "secs" || unit === "ss";
|
|
285
286
|
const isMinutes = unit === "minutes" || unit === "mins" || unit === "mm";
|
|
287
|
+
if (!isMs && !isSeconds && !isMinutes) {
|
|
288
|
+
throw new Error(
|
|
289
|
+
`Invalid unit "${unit}". Use "ms", "seconds" (or "secs"/"ss"), or "minutes" (or "mins"/"mm").`
|
|
290
|
+
);
|
|
291
|
+
}
|
|
286
292
|
const ms = isSeconds ? value * 1e3 : isMinutes ? value * 60 * 1e3 : value;
|
|
287
293
|
const absMs = Math.abs(ms);
|
|
288
294
|
const totalSeconds = Math.floor(absMs / 1e3);
|
package/dist/client/index.js
CHANGED
|
@@ -274,8 +274,14 @@ var formatDuration = (value, options = {}) => {
|
|
|
274
274
|
showMs = false,
|
|
275
275
|
spaces = true
|
|
276
276
|
} = options;
|
|
277
|
+
const isMs = unit === "ms";
|
|
277
278
|
const isSeconds = unit === "seconds" || unit === "secs" || unit === "ss";
|
|
278
279
|
const isMinutes = unit === "minutes" || unit === "mins" || unit === "mm";
|
|
280
|
+
if (!isMs && !isSeconds && !isMinutes) {
|
|
281
|
+
throw new Error(
|
|
282
|
+
`Invalid unit "${unit}". Use "ms", "seconds" (or "secs"/"ss"), or "minutes" (or "mins"/"mm").`
|
|
283
|
+
);
|
|
284
|
+
}
|
|
279
285
|
const ms = isSeconds ? value * 1e3 : isMinutes ? value * 60 * 1e3 : value;
|
|
280
286
|
const absMs = Math.abs(ms);
|
|
281
287
|
const totalSeconds = Math.floor(absMs / 1e3);
|
package/dist/server/index.cjs
CHANGED
|
@@ -293,8 +293,14 @@ var formatDuration = (value, options = {}) => {
|
|
|
293
293
|
showMs = false,
|
|
294
294
|
spaces = true
|
|
295
295
|
} = options;
|
|
296
|
+
const isMs = unit === "ms";
|
|
296
297
|
const isSeconds = unit === "seconds" || unit === "secs" || unit === "ss";
|
|
297
298
|
const isMinutes = unit === "minutes" || unit === "mins" || unit === "mm";
|
|
299
|
+
if (!isMs && !isSeconds && !isMinutes) {
|
|
300
|
+
throw new Error(
|
|
301
|
+
`Invalid unit "${unit}". Use "ms", "seconds" (or "secs"/"ss"), or "minutes" (or "mins"/"mm").`
|
|
302
|
+
);
|
|
303
|
+
}
|
|
298
304
|
const ms = isSeconds ? value * 1e3 : isMinutes ? value * 60 * 1e3 : value;
|
|
299
305
|
const absMs = Math.abs(ms);
|
|
300
306
|
const totalSeconds = Math.floor(absMs / 1e3);
|
package/dist/server/index.js
CHANGED
|
@@ -285,8 +285,14 @@ var formatDuration = (value, options = {}) => {
|
|
|
285
285
|
showMs = false,
|
|
286
286
|
spaces = true
|
|
287
287
|
} = options;
|
|
288
|
+
const isMs = unit === "ms";
|
|
288
289
|
const isSeconds = unit === "seconds" || unit === "secs" || unit === "ss";
|
|
289
290
|
const isMinutes = unit === "minutes" || unit === "mins" || unit === "mm";
|
|
291
|
+
if (!isMs && !isSeconds && !isMinutes) {
|
|
292
|
+
throw new Error(
|
|
293
|
+
`Invalid unit "${unit}". Use "ms", "seconds" (or "secs"/"ss"), or "minutes" (or "mins"/"mm").`
|
|
294
|
+
);
|
|
295
|
+
}
|
|
290
296
|
const ms = isSeconds ? value * 1e3 : isMinutes ? value * 60 * 1e3 : value;
|
|
291
297
|
const absMs = Math.abs(ms);
|
|
292
298
|
const totalSeconds = Math.floor(absMs / 1e3);
|
package/dist/shared/time.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Locale } from "date-fns";
|
|
2
2
|
type DurationFormat = "compact" | "full" | "clock" | "fractional";
|
|
3
|
-
|
|
4
|
-
type
|
|
3
|
+
/** Suggested units - aliases like 'ss', 'secs', 'mm', 'mins' are also accepted */
|
|
4
|
+
type DurationUnit = "ms" | "seconds" | "minutes" | (string & {});
|
|
5
5
|
type DurationOptions = {
|
|
6
6
|
/** Format style: 'compact' (1h 2m), 'full' (1 hour 2 minutes), 'clock' (01:02:03), 'fractional' (1.4s, 1m4.4s) */
|
|
7
7
|
format?: DurationFormat;
|
|
8
8
|
/** Input unit: 'ms' (milliseconds, default), 'seconds' (or 'secs'/'ss'), or 'minutes' (or 'mins'/'mm'). Use 'seconds' for audio/video currentTime. */
|
|
9
|
-
unit?:
|
|
9
|
+
unit?: DurationUnit;
|
|
10
10
|
/** Show zero values for intermediate units (e.g., "1h 0m 30s" vs "1h 30s") */
|
|
11
11
|
showZero?: boolean;
|
|
12
12
|
/** Include milliseconds in compact format (e.g., "1s 200ms") */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/shared/time.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAMvC,KAAK,cAAc,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;AAClE,KAAK,YAAY,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/shared/time.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAMvC,KAAK,cAAc,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;AAClE,kFAAkF;AAClF,KAAK,YAAY,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEjE,KAAK,eAAe,GAAG;IACrB,kHAAkH;IAClH,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,sJ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