@chainflip/utils 0.11.3 → 2.1.0-beta.0

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.
Files changed (71) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  2. package/dist/addresses.cjs +15 -40
  3. package/dist/addresses.d.ts +4 -3
  4. package/dist/addresses.js +14 -15
  5. package/dist/assertion.cjs +23 -82
  6. package/dist/assertion.d.ts +3 -2
  7. package/dist/assertion.js +32 -22
  8. package/dist/async.cjs +96 -115
  9. package/dist/async.d.ts +24 -21
  10. package/dist/async.js +92 -87
  11. package/dist/base58.cjs +9 -93
  12. package/dist/base58.d.ts +4 -4
  13. package/dist/base58.js +9 -13
  14. package/dist/bytes.cjs +49 -97
  15. package/dist/bytes.d.ts +4 -4
  16. package/dist/bytes.js +51 -15
  17. package/dist/chainflip.cjs +428 -327
  18. package/dist/chainflip.d.ts +188 -185
  19. package/dist/chainflip.js +425 -41
  20. package/dist/consts.cjs +306 -277
  21. package/dist/consts.d.ts +18 -17
  22. package/dist/consts.js +296 -243
  23. package/dist/date.cjs +74 -131
  24. package/dist/date.d.ts +9 -8
  25. package/dist/date.js +60 -95
  26. package/dist/guard.cjs +28 -63
  27. package/dist/guard.d.ts +10 -9
  28. package/dist/guard.js +17 -28
  29. package/dist/math.cjs +7 -32
  30. package/dist/math.d.ts +3 -2
  31. package/dist/math.js +6 -7
  32. package/dist/number.cjs +5 -29
  33. package/dist/number.d.ts +4 -4
  34. package/dist/number.js +5 -5
  35. package/dist/ss58.cjs +62 -794
  36. package/dist/ss58.d.ts +12 -9
  37. package/dist/ss58.js +59 -712
  38. package/dist/string.cjs +29 -66
  39. package/dist/string.d.ts +4 -4
  40. package/dist/string.js +20 -33
  41. package/dist/tickMath.cjs +32 -232
  42. package/dist/tickMath.d.ts +7 -6
  43. package/dist/tickMath.js +24 -29
  44. package/dist/types.cjs +0 -18
  45. package/dist/types.d.ts +35 -34
  46. package/dist/types.js +1 -0
  47. package/dist/url.cjs +16 -37
  48. package/dist/url.d.ts +5 -4
  49. package/dist/url.js +16 -13
  50. package/package.json +5 -5
  51. package/dist/addresses.d.cts +0 -6
  52. package/dist/assertion.d.cts +0 -11
  53. package/dist/async.d.cts +0 -33
  54. package/dist/base58.d.cts +0 -8
  55. package/dist/bytes.d.cts +0 -11
  56. package/dist/chainflip.d.cts +0 -236
  57. package/dist/chunk-3P6TXYEI.js +0 -15
  58. package/dist/chunk-HBIFE4XN.js +0 -29
  59. package/dist/chunk-LJJH7U4M.js +0 -302
  60. package/dist/chunk-XGNPN5CY.js +0 -61
  61. package/dist/chunk-ZHIKNZLU.js +0 -66
  62. package/dist/consts.d.cts +0 -33
  63. package/dist/date.d.cts +0 -26
  64. package/dist/guard.d.cts +0 -23
  65. package/dist/math.d.cts +0 -4
  66. package/dist/number.d.cts +0 -6
  67. package/dist/ss58.d.cts +0 -14
  68. package/dist/string.d.cts +0 -16
  69. package/dist/tickMath.d.cts +0 -15
  70. package/dist/types.d.cts +0 -41
  71. package/dist/url.d.cts +0 -6
package/dist/date.cjs CHANGED
@@ -1,137 +1,80 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/date.ts
21
- var date_exports = {};
22
- __export(date_exports, {
23
- addUtcDays: () => addUtcDays,
24
- differenceInTimeAgo: () => differenceInTimeAgo,
25
- differenceInUtcDays: () => differenceInUtcDays,
26
- eachUtcDayOfInterval: () => eachUtcDayOfInterval,
27
- formatTimestamp: () => formatTimestamp,
28
- formatTimestampShort: () => formatTimestampShort,
29
- fromUnixTime: () => fromUnixTime,
30
- intervalToDurationWords: () => intervalToDurationWords,
31
- subUtcDays: () => subUtcDays,
32
- toEndOfUtcDay: () => toEndOfUtcDay,
33
- toEndOfUtcDayString: () => toEndOfUtcDayString,
34
- toISODateString: () => toISODateString,
35
- toStartOfUtcDay: () => toStartOfUtcDay,
36
- toStartOfUtcDayString: () => toStartOfUtcDayString
37
- });
38
- module.exports = __toCommonJS(date_exports);
39
- var import_utc = require("@date-fns/utc");
40
- var import_date_fns = require("date-fns");
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_guard = require('./guard.cjs');
3
+ let _date_fns_utc = require("@date-fns/utc");
4
+ let date_fns = require("date-fns");
41
5
 
42
- // src/guard.ts
43
- var createIsGuard = (type) => (value) => typeof value === type;
44
- var isString = createIsGuard("string");
45
- var isNumber = createIsGuard("number");
46
- var isBigInt = createIsGuard("bigint");
47
- var isBoolean = createIsGuard("boolean");
48
- var isSymbol = createIsGuard("symbol");
49
- var isObject = createIsGuard("object");
50
- var isUndefined = createIsGuard("undefined");
51
- var isNullish = (value) => value == null;
52
-
53
- // src/date.ts
54
- var pluralize = (word, numb) => numb !== 1 ? `${word}s` : word;
55
- var pad = (number) => String(number).padStart(2, "0");
56
- var toISODateString = (date) => date.toISOString().slice(0, 10);
57
- var fromUnixTime = (time) => {
58
- const date = new Date(Number(time) * 1e3);
59
- if (Number.isNaN(date.valueOf())) {
60
- throw new Error("date is invalid");
61
- }
62
- return date;
6
+ //#region src/date.ts
7
+ const pluralize = (word, numb) => numb !== 1 ? `${word}s` : word;
8
+ const pad = (number) => String(number).padStart(2, "0");
9
+ const toISODateString = (date) => date.toISOString().slice(0, 10);
10
+ const fromUnixTime = (time) => {
11
+ const date = /* @__PURE__ */ new Date(Number(time) * 1e3);
12
+ if (Number.isNaN(date.valueOf())) throw new Error("date is invalid");
13
+ return date;
63
14
  };
64
- var formatTimestamp = (timestamp, locale = void 0, timeZone = void 0) => new Date(timestamp).toLocaleString(locale, {
65
- timeZone,
66
- weekday: "short",
67
- month: "short",
68
- day: "numeric",
69
- year: "numeric",
70
- timeZoneName: "short",
71
- hour: "numeric",
72
- minute: "numeric",
73
- second: "numeric"
15
+ const formatTimestamp = (timestamp, locale = void 0, timeZone = void 0) => new Date(timestamp).toLocaleString(locale, {
16
+ timeZone,
17
+ weekday: "short",
18
+ month: "short",
19
+ day: "numeric",
20
+ year: "numeric",
21
+ timeZoneName: "short",
22
+ hour: "numeric",
23
+ minute: "numeric",
24
+ second: "numeric"
74
25
  });
75
- var formatTimestampShort = (timestamp, locale = void 0, timeZone = void 0) => new Date(timestamp).toLocaleString(locale, {
76
- timeZone,
77
- month: "numeric",
78
- day: "numeric",
79
- year: "numeric",
80
- hour: "numeric",
81
- minute: "numeric",
82
- second: "numeric"
26
+ const formatTimestampShort = (timestamp, locale = void 0, timeZone = void 0) => new Date(timestamp).toLocaleString(locale, {
27
+ timeZone,
28
+ month: "numeric",
29
+ day: "numeric",
30
+ year: "numeric",
31
+ hour: "numeric",
32
+ minute: "numeric",
33
+ second: "numeric"
83
34
  });
84
- var differenceInTimeAgo = (time, ago = true, endTime = (/* @__PURE__ */ new Date()).toISOString()) => {
85
- const end = new Date(endTime);
86
- const timeNumber = Date.parse(time);
87
- const seconds = (0, import_date_fns.differenceInSeconds)(end, timeNumber);
88
- if (seconds < 60) return `${seconds} sec${ago ? " ago" : ""}`;
89
- const minutes = (0, import_date_fns.differenceInMinutes)(end, timeNumber);
90
- if (minutes < 60) return `${minutes} min${ago ? " ago" : ""}`;
91
- const hours = (0, import_date_fns.differenceInHours)(end, timeNumber);
92
- if (hours < 48) return `${hours} ${pluralize("hour", hours)}${ago ? " ago" : ""}`;
93
- const days = (0, import_date_fns.differenceInDays)(end, timeNumber);
94
- return `${days} days${ago ? " ago" : ""}`;
35
+ const differenceInTimeAgo = (time, ago = true, endTime = (/* @__PURE__ */ new Date()).toISOString()) => {
36
+ const end = new Date(endTime);
37
+ const timeNumber = Date.parse(time);
38
+ const seconds = (0, date_fns.differenceInSeconds)(end, timeNumber);
39
+ if (seconds < 60) return `${seconds} sec${ago ? " ago" : ""}`;
40
+ const minutes = (0, date_fns.differenceInMinutes)(end, timeNumber);
41
+ if (minutes < 60) return `${minutes} min${ago ? " ago" : ""}`;
42
+ const hours = (0, date_fns.differenceInHours)(end, timeNumber);
43
+ if (hours < 48) return `${hours} ${pluralize("hour", hours)}${ago ? " ago" : ""}`;
44
+ return `${(0, date_fns.differenceInDays)(end, timeNumber)} days${ago ? " ago" : ""}`;
95
45
  };
96
- var intervalToDurationWords = (interval) => {
97
- if (isNullish(interval.start) || isNullish(interval.end)) return "??";
98
- if (interval.end === 0) return "??";
99
- const duration = (0, import_date_fns.intervalToDuration)(interval);
100
- if (duration.months) return ">1 month";
101
- if (duration.days) {
102
- return `${pad(duration.days)}${duration.days === 1 ? "day" : "days"} ${pad(
103
- duration.hours ?? 0
104
- )}h ${pad(duration.minutes ?? 0)}min ${pad(duration.seconds ?? 0)}s`;
105
- }
106
- if (duration.hours) {
107
- return `${pad(duration.hours)}h ${pad(duration.minutes ?? 0)}min ${pad(duration.seconds ?? 0)}s`;
108
- }
109
- if (duration.minutes) return `${pad(duration.minutes)}min ${pad(duration.seconds ?? 0)}s`;
110
- if (duration.seconds) return `${pad(duration.seconds)}s`;
111
- return "A few seconds";
46
+ const intervalToDurationWords = (interval) => {
47
+ if (require_guard.isNullish(interval.start) || require_guard.isNullish(interval.end)) return "??";
48
+ if (interval.end === 0) return "??";
49
+ const duration = (0, date_fns.intervalToDuration)(interval);
50
+ if (duration.months) return ">1 month";
51
+ if (duration.days) return `${pad(duration.days)}${duration.days === 1 ? "day" : "days"} ${pad(duration.hours ?? 0)}h ${pad(duration.minutes ?? 0)}min ${pad(duration.seconds ?? 0)}s`;
52
+ if (duration.hours) return `${pad(duration.hours)}h ${pad(duration.minutes ?? 0)}min ${pad(duration.seconds ?? 0)}s`;
53
+ if (duration.minutes) return `${pad(duration.minutes)}min ${pad(duration.seconds ?? 0)}s`;
54
+ if (duration.seconds) return `${pad(duration.seconds)}s`;
55
+ return "A few seconds";
112
56
  };
113
- var subUtcDays = (date, days) => (0, import_date_fns.subDays)(date, days, { in: import_utc.utc });
114
- var addUtcDays = (date, days) => (0, import_date_fns.addDays)(date, days, { in: import_utc.utc });
115
- var toStartOfUtcDay = (date) => (0, import_date_fns.startOfDay)(date, { in: import_utc.utc });
116
- var toStartOfUtcDayString = (date) => toStartOfUtcDay(date).toISOString();
117
- var toEndOfUtcDay = (date) => (0, import_date_fns.endOfDay)(date, { in: import_utc.utc });
118
- var toEndOfUtcDayString = (date) => toEndOfUtcDay(date).toISOString();
119
- var differenceInUtcDays = (interval) => (0, import_date_fns.differenceInDays)(interval.end, interval.start, { in: import_utc.utc });
120
- var eachUtcDayOfInterval = (interval) => (0, import_date_fns.eachDayOfInterval)(interval, { in: import_utc.utc });
121
- // Annotate the CommonJS export names for ESM import in node:
122
- 0 && (module.exports = {
123
- addUtcDays,
124
- differenceInTimeAgo,
125
- differenceInUtcDays,
126
- eachUtcDayOfInterval,
127
- formatTimestamp,
128
- formatTimestampShort,
129
- fromUnixTime,
130
- intervalToDurationWords,
131
- subUtcDays,
132
- toEndOfUtcDay,
133
- toEndOfUtcDayString,
134
- toISODateString,
135
- toStartOfUtcDay,
136
- toStartOfUtcDayString
137
- });
57
+ const subUtcDays = (date, days) => (0, date_fns.subDays)(date, days, { in: _date_fns_utc.utc });
58
+ const addUtcDays = (date, days) => (0, date_fns.addDays)(date, days, { in: _date_fns_utc.utc });
59
+ const toStartOfUtcDay = (date) => (0, date_fns.startOfDay)(date, { in: _date_fns_utc.utc });
60
+ const toStartOfUtcDayString = (date) => toStartOfUtcDay(date).toISOString();
61
+ const toEndOfUtcDay = (date) => (0, date_fns.endOfDay)(date, { in: _date_fns_utc.utc });
62
+ const toEndOfUtcDayString = (date) => toEndOfUtcDay(date).toISOString();
63
+ const differenceInUtcDays = (interval) => (0, date_fns.differenceInDays)(interval.end, interval.start, { in: _date_fns_utc.utc });
64
+ const eachUtcDayOfInterval = (interval) => (0, date_fns.eachDayOfInterval)(interval, { in: _date_fns_utc.utc });
65
+
66
+ //#endregion
67
+ exports.addUtcDays = addUtcDays;
68
+ exports.differenceInTimeAgo = differenceInTimeAgo;
69
+ exports.differenceInUtcDays = differenceInUtcDays;
70
+ exports.eachUtcDayOfInterval = eachUtcDayOfInterval;
71
+ exports.formatTimestamp = formatTimestamp;
72
+ exports.formatTimestampShort = formatTimestampShort;
73
+ exports.fromUnixTime = fromUnixTime;
74
+ exports.intervalToDurationWords = intervalToDurationWords;
75
+ exports.subUtcDays = subUtcDays;
76
+ exports.toEndOfUtcDay = toEndOfUtcDay;
77
+ exports.toEndOfUtcDayString = toEndOfUtcDayString;
78
+ exports.toISODateString = toISODateString;
79
+ exports.toStartOfUtcDay = toStartOfUtcDay;
80
+ exports.toStartOfUtcDayString = toStartOfUtcDayString;
package/dist/date.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { UTCDate } from '@date-fns/utc';
2
- import { Interval, DateArg } from 'date-fns';
1
+ import { UTCDate } from "@date-fns/utc";
2
+ import { DateArg, Interval } from "date-fns";
3
3
 
4
+ //#region src/date.d.ts
4
5
  declare const toISODateString: (date: Date) => string;
5
6
  declare const fromUnixTime: (time: string | number) => Date;
6
7
  declare const formatTimestamp: (timestamp: string, locale?: string | undefined, timeZone?: undefined | "UTC") => string;
@@ -15,12 +16,12 @@ declare const toStartOfUtcDayString: (date: FNSDate) => string;
15
16
  declare const toEndOfUtcDay: (date: FNSDate) => UTCDate;
16
17
  declare const toEndOfUtcDayString: (date: FNSDate) => string;
17
18
  declare const differenceInUtcDays: (interval: {
18
- start: FNSDate;
19
- end: FNSDate;
19
+ start: FNSDate;
20
+ end: FNSDate;
20
21
  }) => number;
21
22
  declare const eachUtcDayOfInterval: (interval: {
22
- start: FNSDate;
23
- end: FNSDate;
23
+ start: FNSDate;
24
+ end: FNSDate;
24
25
  }) => UTCDate[];
25
-
26
- export { addUtcDays, differenceInTimeAgo, differenceInUtcDays, eachUtcDayOfInterval, formatTimestamp, formatTimestampShort, fromUnixTime, intervalToDurationWords, subUtcDays, toEndOfUtcDay, toEndOfUtcDayString, toISODateString, toStartOfUtcDay, toStartOfUtcDayString };
26
+ //#endregion
27
+ export { addUtcDays, differenceInTimeAgo, differenceInUtcDays, eachUtcDayOfInterval, formatTimestamp, formatTimestampShort, fromUnixTime, intervalToDurationWords, subUtcDays, toEndOfUtcDay, toEndOfUtcDayString, toISODateString, toStartOfUtcDay, toStartOfUtcDayString };
package/dist/date.js CHANGED
@@ -1,101 +1,66 @@
1
- import {
2
- isNullish
3
- } from "./chunk-HBIFE4XN.js";
4
-
5
- // src/date.ts
1
+ import { isNullish } from "./guard.js";
6
2
  import { utc } from "@date-fns/utc";
7
- import {
8
- differenceInDays,
9
- differenceInHours,
10
- differenceInMinutes,
11
- differenceInSeconds,
12
- intervalToDuration,
13
- eachDayOfInterval,
14
- endOfDay,
15
- startOfDay,
16
- subDays,
17
- addDays
18
- } from "date-fns";
19
- var pluralize = (word, numb) => numb !== 1 ? `${word}s` : word;
20
- var pad = (number) => String(number).padStart(2, "0");
21
- var toISODateString = (date) => date.toISOString().slice(0, 10);
22
- var fromUnixTime = (time) => {
23
- const date = new Date(Number(time) * 1e3);
24
- if (Number.isNaN(date.valueOf())) {
25
- throw new Error("date is invalid");
26
- }
27
- return date;
3
+ import { addDays, differenceInDays, differenceInHours, differenceInMinutes, differenceInSeconds, eachDayOfInterval, endOfDay, intervalToDuration, startOfDay, subDays } from "date-fns";
4
+
5
+ //#region src/date.ts
6
+ const pluralize = (word, numb) => numb !== 1 ? `${word}s` : word;
7
+ const pad = (number) => String(number).padStart(2, "0");
8
+ const toISODateString = (date) => date.toISOString().slice(0, 10);
9
+ const fromUnixTime = (time) => {
10
+ const date = /* @__PURE__ */ new Date(Number(time) * 1e3);
11
+ if (Number.isNaN(date.valueOf())) throw new Error("date is invalid");
12
+ return date;
28
13
  };
29
- var formatTimestamp = (timestamp, locale = void 0, timeZone = void 0) => new Date(timestamp).toLocaleString(locale, {
30
- timeZone,
31
- weekday: "short",
32
- month: "short",
33
- day: "numeric",
34
- year: "numeric",
35
- timeZoneName: "short",
36
- hour: "numeric",
37
- minute: "numeric",
38
- second: "numeric"
14
+ const formatTimestamp = (timestamp, locale = void 0, timeZone = void 0) => new Date(timestamp).toLocaleString(locale, {
15
+ timeZone,
16
+ weekday: "short",
17
+ month: "short",
18
+ day: "numeric",
19
+ year: "numeric",
20
+ timeZoneName: "short",
21
+ hour: "numeric",
22
+ minute: "numeric",
23
+ second: "numeric"
39
24
  });
40
- var formatTimestampShort = (timestamp, locale = void 0, timeZone = void 0) => new Date(timestamp).toLocaleString(locale, {
41
- timeZone,
42
- month: "numeric",
43
- day: "numeric",
44
- year: "numeric",
45
- hour: "numeric",
46
- minute: "numeric",
47
- second: "numeric"
25
+ const formatTimestampShort = (timestamp, locale = void 0, timeZone = void 0) => new Date(timestamp).toLocaleString(locale, {
26
+ timeZone,
27
+ month: "numeric",
28
+ day: "numeric",
29
+ year: "numeric",
30
+ hour: "numeric",
31
+ minute: "numeric",
32
+ second: "numeric"
48
33
  });
49
- var differenceInTimeAgo = (time, ago = true, endTime = (/* @__PURE__ */ new Date()).toISOString()) => {
50
- const end = new Date(endTime);
51
- const timeNumber = Date.parse(time);
52
- const seconds = differenceInSeconds(end, timeNumber);
53
- if (seconds < 60) return `${seconds} sec${ago ? " ago" : ""}`;
54
- const minutes = differenceInMinutes(end, timeNumber);
55
- if (minutes < 60) return `${minutes} min${ago ? " ago" : ""}`;
56
- const hours = differenceInHours(end, timeNumber);
57
- if (hours < 48) return `${hours} ${pluralize("hour", hours)}${ago ? " ago" : ""}`;
58
- const days = differenceInDays(end, timeNumber);
59
- return `${days} days${ago ? " ago" : ""}`;
34
+ const differenceInTimeAgo = (time, ago = true, endTime = (/* @__PURE__ */ new Date()).toISOString()) => {
35
+ const end = new Date(endTime);
36
+ const timeNumber = Date.parse(time);
37
+ const seconds = differenceInSeconds(end, timeNumber);
38
+ if (seconds < 60) return `${seconds} sec${ago ? " ago" : ""}`;
39
+ const minutes = differenceInMinutes(end, timeNumber);
40
+ if (minutes < 60) return `${minutes} min${ago ? " ago" : ""}`;
41
+ const hours = differenceInHours(end, timeNumber);
42
+ if (hours < 48) return `${hours} ${pluralize("hour", hours)}${ago ? " ago" : ""}`;
43
+ return `${differenceInDays(end, timeNumber)} days${ago ? " ago" : ""}`;
60
44
  };
61
- var intervalToDurationWords = (interval) => {
62
- if (isNullish(interval.start) || isNullish(interval.end)) return "??";
63
- if (interval.end === 0) return "??";
64
- const duration = intervalToDuration(interval);
65
- if (duration.months) return ">1 month";
66
- if (duration.days) {
67
- return `${pad(duration.days)}${duration.days === 1 ? "day" : "days"} ${pad(
68
- duration.hours ?? 0
69
- )}h ${pad(duration.minutes ?? 0)}min ${pad(duration.seconds ?? 0)}s`;
70
- }
71
- if (duration.hours) {
72
- return `${pad(duration.hours)}h ${pad(duration.minutes ?? 0)}min ${pad(duration.seconds ?? 0)}s`;
73
- }
74
- if (duration.minutes) return `${pad(duration.minutes)}min ${pad(duration.seconds ?? 0)}s`;
75
- if (duration.seconds) return `${pad(duration.seconds)}s`;
76
- return "A few seconds";
77
- };
78
- var subUtcDays = (date, days) => subDays(date, days, { in: utc });
79
- var addUtcDays = (date, days) => addDays(date, days, { in: utc });
80
- var toStartOfUtcDay = (date) => startOfDay(date, { in: utc });
81
- var toStartOfUtcDayString = (date) => toStartOfUtcDay(date).toISOString();
82
- var toEndOfUtcDay = (date) => endOfDay(date, { in: utc });
83
- var toEndOfUtcDayString = (date) => toEndOfUtcDay(date).toISOString();
84
- var differenceInUtcDays = (interval) => differenceInDays(interval.end, interval.start, { in: utc });
85
- var eachUtcDayOfInterval = (interval) => eachDayOfInterval(interval, { in: utc });
86
- export {
87
- addUtcDays,
88
- differenceInTimeAgo,
89
- differenceInUtcDays,
90
- eachUtcDayOfInterval,
91
- formatTimestamp,
92
- formatTimestampShort,
93
- fromUnixTime,
94
- intervalToDurationWords,
95
- subUtcDays,
96
- toEndOfUtcDay,
97
- toEndOfUtcDayString,
98
- toISODateString,
99
- toStartOfUtcDay,
100
- toStartOfUtcDayString
45
+ const intervalToDurationWords = (interval) => {
46
+ if (isNullish(interval.start) || isNullish(interval.end)) return "??";
47
+ if (interval.end === 0) return "??";
48
+ const duration = intervalToDuration(interval);
49
+ if (duration.months) return ">1 month";
50
+ if (duration.days) return `${pad(duration.days)}${duration.days === 1 ? "day" : "days"} ${pad(duration.hours ?? 0)}h ${pad(duration.minutes ?? 0)}min ${pad(duration.seconds ?? 0)}s`;
51
+ if (duration.hours) return `${pad(duration.hours)}h ${pad(duration.minutes ?? 0)}min ${pad(duration.seconds ?? 0)}s`;
52
+ if (duration.minutes) return `${pad(duration.minutes)}min ${pad(duration.seconds ?? 0)}s`;
53
+ if (duration.seconds) return `${pad(duration.seconds)}s`;
54
+ return "A few seconds";
101
55
  };
56
+ const subUtcDays = (date, days) => subDays(date, days, { in: utc });
57
+ const addUtcDays = (date, days) => addDays(date, days, { in: utc });
58
+ const toStartOfUtcDay = (date) => startOfDay(date, { in: utc });
59
+ const toStartOfUtcDayString = (date) => toStartOfUtcDay(date).toISOString();
60
+ const toEndOfUtcDay = (date) => endOfDay(date, { in: utc });
61
+ const toEndOfUtcDayString = (date) => toEndOfUtcDay(date).toISOString();
62
+ const differenceInUtcDays = (interval) => differenceInDays(interval.end, interval.start, { in: utc });
63
+ const eachUtcDayOfInterval = (interval) => eachDayOfInterval(interval, { in: utc });
64
+
65
+ //#endregion
66
+ export { addUtcDays, differenceInTimeAgo, differenceInUtcDays, eachUtcDayOfInterval, formatTimestamp, formatTimestampShort, fromUnixTime, intervalToDurationWords, subUtcDays, toEndOfUtcDay, toEndOfUtcDayString, toISODateString, toStartOfUtcDay, toStartOfUtcDayString };
package/dist/guard.cjs CHANGED
@@ -1,64 +1,29 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
1
 
20
- // src/guard.ts
21
- var guard_exports = {};
22
- __export(guard_exports, {
23
- isBigInt: () => isBigInt,
24
- isBoolean: () => isBoolean,
25
- isFullfilled: () => isFullfilled,
26
- isNotNullish: () => isNotNullish,
27
- isNullish: () => isNullish,
28
- isNumber: () => isNumber,
29
- isObject: () => isObject,
30
- isRejected: () => isRejected,
31
- isString: () => isString,
32
- isSymbol: () => isSymbol,
33
- isTruthy: () => isTruthy,
34
- isUndefined: () => isUndefined
35
- });
36
- module.exports = __toCommonJS(guard_exports);
37
- var createIsGuard = (type) => (value) => typeof value === type;
38
- var isString = createIsGuard("string");
39
- var isNumber = createIsGuard("number");
40
- var isBigInt = createIsGuard("bigint");
41
- var isBoolean = createIsGuard("boolean");
42
- var isSymbol = createIsGuard("symbol");
43
- var isObject = createIsGuard("object");
44
- var isUndefined = createIsGuard("undefined");
45
- var isNotNullish = (value) => value != null;
46
- var isNullish = (value) => value == null;
47
- var isTruthy = (value) => Boolean(value);
48
- var isFullfilled = (value) => value.status === "fulfilled";
49
- var isRejected = (value) => value.status === "rejected";
50
- // Annotate the CommonJS export names for ESM import in node:
51
- 0 && (module.exports = {
52
- isBigInt,
53
- isBoolean,
54
- isFullfilled,
55
- isNotNullish,
56
- isNullish,
57
- isNumber,
58
- isObject,
59
- isRejected,
60
- isString,
61
- isSymbol,
62
- isTruthy,
63
- isUndefined
64
- });
2
+ //#region src/guard.ts
3
+ const createIsGuard = (type) => (value) => typeof value === type;
4
+ const isString = createIsGuard("string");
5
+ const isNumber = createIsGuard("number");
6
+ const isBigInt = createIsGuard("bigint");
7
+ const isBoolean = createIsGuard("boolean");
8
+ const isSymbol = createIsGuard("symbol");
9
+ const isObject = createIsGuard("object");
10
+ const isUndefined = createIsGuard("undefined");
11
+ const isNotNullish = (value) => value != null;
12
+ const isNullish = (value) => value == null;
13
+ const isTruthy = (value) => Boolean(value);
14
+ const isFullfilled = (value) => value.status === "fulfilled";
15
+ const isRejected = (value) => value.status === "rejected";
16
+
17
+ //#endregion
18
+ exports.isBigInt = isBigInt;
19
+ exports.isBoolean = isBoolean;
20
+ exports.isFullfilled = isFullfilled;
21
+ exports.isNotNullish = isNotNullish;
22
+ exports.isNullish = isNullish;
23
+ exports.isNumber = isNumber;
24
+ exports.isObject = isObject;
25
+ exports.isRejected = isRejected;
26
+ exports.isString = isString;
27
+ exports.isSymbol = isSymbol;
28
+ exports.isTruthy = isTruthy;
29
+ exports.isUndefined = isUndefined;
package/dist/guard.d.ts CHANGED
@@ -1,11 +1,12 @@
1
+ //#region src/guard.d.ts
1
2
  type TypeMap = {
2
- string: string;
3
- number: number;
4
- bigint: bigint;
5
- boolean: boolean;
6
- symbol: symbol;
7
- object: object;
8
- undefined: undefined;
3
+ string: string;
4
+ number: number;
5
+ bigint: bigint;
6
+ boolean: boolean;
7
+ symbol: symbol;
8
+ object: object;
9
+ undefined: undefined;
9
10
  };
10
11
  declare const isString: (value: unknown) => value is TypeMap["string"];
11
12
  declare const isNumber: (value: unknown) => value is TypeMap["number"];
@@ -19,5 +20,5 @@ declare const isNullish: (value: unknown) => value is null | undefined;
19
20
  declare const isTruthy: <T>(value: T | null | undefined) => value is T;
20
21
  declare const isFullfilled: <T>(value: PromiseSettledResult<T>) => value is PromiseFulfilledResult<T>;
21
22
  declare const isRejected: <T>(value: PromiseSettledResult<T>) => value is PromiseRejectedResult;
22
-
23
- export { type TypeMap, isBigInt, isBoolean, isFullfilled, isNotNullish, isNullish, isNumber, isObject, isRejected, isString, isSymbol, isTruthy, isUndefined };
23
+ //#endregion
24
+ export { TypeMap, isBigInt, isBoolean, isFullfilled, isNotNullish, isNullish, isNumber, isObject, isRejected, isString, isSymbol, isTruthy, isUndefined };
package/dist/guard.js CHANGED
@@ -1,28 +1,17 @@
1
- import {
2
- isBigInt,
3
- isBoolean,
4
- isFullfilled,
5
- isNotNullish,
6
- isNullish,
7
- isNumber,
8
- isObject,
9
- isRejected,
10
- isString,
11
- isSymbol,
12
- isTruthy,
13
- isUndefined
14
- } from "./chunk-HBIFE4XN.js";
15
- export {
16
- isBigInt,
17
- isBoolean,
18
- isFullfilled,
19
- isNotNullish,
20
- isNullish,
21
- isNumber,
22
- isObject,
23
- isRejected,
24
- isString,
25
- isSymbol,
26
- isTruthy,
27
- isUndefined
28
- };
1
+ //#region src/guard.ts
2
+ const createIsGuard = (type) => (value) => typeof value === type;
3
+ const isString = createIsGuard("string");
4
+ const isNumber = createIsGuard("number");
5
+ const isBigInt = createIsGuard("bigint");
6
+ const isBoolean = createIsGuard("boolean");
7
+ const isSymbol = createIsGuard("symbol");
8
+ const isObject = createIsGuard("object");
9
+ const isUndefined = createIsGuard("undefined");
10
+ const isNotNullish = (value) => value != null;
11
+ const isNullish = (value) => value == null;
12
+ const isTruthy = (value) => Boolean(value);
13
+ const isFullfilled = (value) => value.status === "fulfilled";
14
+ const isRejected = (value) => value.status === "rejected";
15
+
16
+ //#endregion
17
+ export { isBigInt, isBoolean, isFullfilled, isNotNullish, isNullish, isNumber, isObject, isRejected, isString, isSymbol, isTruthy, isUndefined };
package/dist/math.cjs CHANGED
@@ -1,33 +1,8 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
1
 
20
- // src/math.ts
21
- var math_exports = {};
22
- __export(math_exports, {
23
- average: () => average,
24
- sum: () => sum
25
- });
26
- module.exports = __toCommonJS(math_exports);
27
- var sum = (arr) => arr.reduce((a, b) => a + b, 0);
28
- var average = (arr) => sum(arr) / arr.length;
29
- // Annotate the CommonJS export names for ESM import in node:
30
- 0 && (module.exports = {
31
- average,
32
- sum
33
- });
2
+ //#region src/math.ts
3
+ const sum = (arr) => arr.reduce((a, b) => a + b, 0);
4
+ const average = (arr) => sum(arr) / arr.length;
5
+
6
+ //#endregion
7
+ exports.average = average;
8
+ exports.sum = sum;
package/dist/math.d.ts CHANGED
@@ -1,4 +1,5 @@
1
+ //#region src/math.d.ts
1
2
  declare const sum: (arr: number[]) => number;
2
3
  declare const average: (arr: number[]) => number;
3
-
4
- export { average, sum };
4
+ //#endregion
5
+ export { average, sum };
package/dist/math.js CHANGED
@@ -1,7 +1,6 @@
1
- // src/math.ts
2
- var sum = (arr) => arr.reduce((a, b) => a + b, 0);
3
- var average = (arr) => sum(arr) / arr.length;
4
- export {
5
- average,
6
- sum
7
- };
1
+ //#region src/math.ts
2
+ const sum = (arr) => arr.reduce((a, b) => a + b, 0);
3
+ const average = (arr) => sum(arr) / arr.length;
4
+
5
+ //#endregion
6
+ export { average, sum };