@choksheak/ts-utils 0.3.6 → 0.3.7
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/arrayBuffer.cjs +39 -10
- package/arrayBuffer.min.cjs +1 -1
- package/arrayBuffer.min.cjs.map +1 -1
- package/arrayBuffer.min.mjs +1 -1
- package/arrayBuffer.min.mjs.map +1 -1
- package/arrayBuffer.mjs +10 -7
- package/asNumber.cjs +38 -6
- package/asNumber.min.cjs +1 -1
- package/asNumber.min.cjs.map +1 -1
- package/asNumber.min.mjs +1 -1
- package/asNumber.min.mjs.map +1 -1
- package/asNumber.mjs +11 -4
- package/assert.cjs +27 -4
- package/assert.min.cjs +1 -1
- package/assert.min.cjs.map +1 -1
- package/assert.min.mjs +1 -1
- package/assert.min.mjs.map +1 -1
- package/assert.mjs +0 -2
- package/base64Url.cjs +29 -5
- package/base64Url.min.cjs +1 -1
- package/base64Url.min.cjs.map +1 -1
- package/base64Url.min.mjs +1 -1
- package/base64Url.min.mjs.map +1 -1
- package/base64Url.mjs +0 -2
- package/capLength.cjs +71 -7
- package/capLength.min.cjs +5 -1
- package/capLength.min.cjs.map +1 -1
- package/capLength.min.mjs +5 -1
- package/capLength.min.mjs.map +1 -1
- package/capLength.mjs +41 -4
- package/concatIterators.cjs +27 -4
- package/concatIterators.min.cjs +1 -1
- package/concatIterators.min.cjs.map +1 -1
- package/concatIterators.min.mjs +1 -1
- package/concatIterators.min.mjs.map +1 -1
- package/concatIterators.mjs +0 -2
- package/dateTimeStr.cjs +119 -31
- package/dateTimeStr.min.cjs +1 -1
- package/dateTimeStr.min.cjs.map +1 -1
- package/dateTimeStr.min.mjs +1 -1
- package/dateTimeStr.min.mjs.map +1 -1
- package/dateTimeStr.mjs +69 -17
- package/duration.cjs +188 -24
- package/duration.min.cjs +1 -1
- package/duration.min.cjs.map +1 -1
- package/duration.min.mjs +1 -1
- package/duration.min.mjs.map +1 -1
- package/duration.mjs +144 -14
- package/getEnv.cjs +31 -7
- package/getEnv.min.cjs +1 -1
- package/getEnv.min.cjs.map +1 -1
- package/getEnv.min.mjs +1 -1
- package/getEnv.min.mjs.map +1 -1
- package/getEnv.mjs +0 -2
- package/isEmpty.cjs +46 -8
- package/isEmpty.min.cjs +1 -1
- package/isEmpty.min.cjs.map +1 -1
- package/isEmpty.min.mjs +1 -1
- package/isEmpty.min.mjs.map +1 -1
- package/isEmpty.mjs +19 -6
- package/isPromise.cjs +29 -5
- package/isPromise.min.cjs +1 -1
- package/isPromise.min.cjs.map +1 -1
- package/isPromise.min.mjs +1 -1
- package/isPromise.min.mjs.map +1 -1
- package/isPromise.mjs +0 -2
- package/kvStore.cjs +353 -15
- package/kvStore.min.cjs +1 -1
- package/kvStore.min.cjs.map +1 -1
- package/kvStore.min.mjs +1 -1
- package/kvStore.min.mjs.map +1 -1
- package/kvStore.mjs +319 -12
- package/localStore.cjs +264 -15
- package/localStore.min.cjs +1 -1
- package/localStore.min.cjs.map +1 -1
- package/localStore.min.mjs +1 -1
- package/localStore.min.mjs.map +1 -1
- package/localStore.mjs +230 -12
- package/mean.cjs +48 -8
- package/mean.min.cjs +1 -1
- package/mean.min.cjs.map +1 -1
- package/mean.min.mjs +1 -1
- package/mean.min.mjs.map +1 -1
- package/mean.mjs +18 -5
- package/median.cjs +41 -7
- package/median.min.cjs +1 -1
- package/median.min.cjs.map +1 -1
- package/median.min.mjs +1 -1
- package/median.min.mjs.map +1 -1
- package/median.mjs +11 -4
- package/nonEmpty.cjs +48 -8
- package/nonEmpty.min.cjs +1 -1
- package/nonEmpty.min.cjs.map +1 -1
- package/nonEmpty.min.mjs +1 -1
- package/nonEmpty.min.mjs.map +1 -1
- package/nonEmpty.mjs +19 -6
- package/nonNil.cjs +27 -4
- package/nonNil.min.cjs +1 -1
- package/nonNil.min.cjs.map +1 -1
- package/nonNil.min.mjs +1 -1
- package/nonNil.min.mjs.map +1 -1
- package/nonNil.mjs +0 -2
- package/package.json +1 -257
- package/round.cjs +32 -6
- package/round.min.cjs +1 -1
- package/round.min.cjs.map +1 -1
- package/round.min.mjs +1 -1
- package/round.min.mjs.map +1 -1
- package/round.mjs +5 -4
- package/roundToString.cjs +35 -7
- package/roundToString.min.cjs +1 -1
- package/roundToString.min.cjs.map +1 -1
- package/roundToString.min.mjs +1 -1
- package/roundToString.min.mjs.map +1 -1
- package/roundToString.mjs +5 -4
- package/safeBtoa.cjs +27 -4
- package/safeBtoa.min.cjs +1 -1
- package/safeBtoa.min.cjs.map +1 -1
- package/safeBtoa.min.mjs +1 -1
- package/safeBtoa.min.mjs.map +1 -1
- package/safeBtoa.mjs +0 -2
- package/sha256.cjs +34 -8
- package/sha256.min.cjs +1 -1
- package/sha256.min.cjs.map +1 -1
- package/sha256.min.mjs +1 -1
- package/sha256.min.mjs.map +1 -1
- package/sha256.mjs +7 -6
- package/sleep.cjs +27 -4
- package/sleep.min.cjs +1 -1
- package/sleep.min.cjs.map +1 -1
- package/sleep.min.mjs +1 -1
- package/sleep.min.mjs.map +1 -1
- package/sleep.mjs +0 -2
- package/storageAdapter.cjs +18 -1
- package/storageAdapter.min.cjs +2 -1
- package/storageAdapter.min.cjs.map +1 -1
- package/sum.cjs +45 -5
- package/sum.min.cjs +1 -1
- package/sum.min.cjs.map +1 -1
- package/sum.min.mjs +1 -1
- package/sum.min.mjs.map +1 -1
- package/sum.mjs +18 -5
- package/timeConstants.cjs +69 -35
- package/timeConstants.min.cjs +1 -1
- package/timeConstants.min.cjs.map +1 -1
- package/timeConstants.min.mjs +1 -1
- package/timeConstants.min.mjs.map +1 -1
- package/timeConstants.mjs +15 -19
- package/timer.cjs +180 -7
- package/timer.min.cjs +1 -1
- package/timer.min.cjs.map +1 -1
- package/timer.min.mjs +1 -1
- package/timer.min.mjs.map +1 -1
- package/timer.mjs +154 -8
- package/toReadableString.cjs +68 -6
- package/toReadableString.min.cjs +5 -1
- package/toReadableString.min.cjs.map +1 -1
- package/toReadableString.min.mjs +5 -1
- package/toReadableString.min.mjs.map +1 -1
- package/toReadableString.mjs +41 -4
- package/chunk-22JDWCOS.min.cjs +0 -2
- package/chunk-22JDWCOS.min.cjs.map +0 -1
- package/chunk-244NBT4Q.min.mjs +0 -2
- package/chunk-244NBT4Q.min.mjs.map +0 -1
- package/chunk-27MBP3ES.min.cjs +0 -2
- package/chunk-27MBP3ES.min.cjs.map +0 -1
- package/chunk-34ENP2B3.min.mjs +0 -438
- package/chunk-34ENP2B3.min.mjs.map +0 -1
- package/chunk-3EBQ2GO2.min.cjs +0 -2
- package/chunk-3EBQ2GO2.min.cjs.map +0 -1
- package/chunk-4GLOLTJ5.cjs +0 -167
- package/chunk-6TQBMXTL.min.cjs +0 -2
- package/chunk-6TQBMXTL.min.cjs.map +0 -1
- package/chunk-AWZBCFMG.min.cjs +0 -2
- package/chunk-AWZBCFMG.min.cjs.map +0 -1
- package/chunk-AXNETZET.cjs +0 -20
- package/chunk-BKZM6NWX.min.cjs +0 -2
- package/chunk-BKZM6NWX.min.cjs.map +0 -1
- package/chunk-BZKQXX3A.cjs +0 -40
- package/chunk-CERFUU5I.cjs +0 -93
- package/chunk-CSTKFJ6G.mjs +0 -239
- package/chunk-DUN4UY2Q.cjs +0 -239
- package/chunk-EDJJUP4K.min.cjs +0 -6
- package/chunk-EDJJUP4K.min.cjs.map +0 -1
- package/chunk-FFNQBZH5.cjs +0 -14
- package/chunk-FZZRSHSH.min.mjs +0 -6
- package/chunk-FZZRSHSH.min.mjs.map +0 -1
- package/chunk-GAP2HS5M.min.cjs +0 -2
- package/chunk-GAP2HS5M.min.cjs.map +0 -1
- package/chunk-GLYMAPS4.min.mjs +0 -2
- package/chunk-GLYMAPS4.min.mjs.map +0 -1
- package/chunk-I65KPVMO.min.cjs +0 -438
- package/chunk-I65KPVMO.min.cjs.map +0 -1
- package/chunk-ILGTU46T.cjs +0 -39
- package/chunk-IOKRXHKE.min.mjs +0 -2
- package/chunk-IOKRXHKE.min.mjs.map +0 -1
- package/chunk-ISP4SMRC.min.cjs +0 -2
- package/chunk-ISP4SMRC.min.cjs.map +0 -1
- package/chunk-KETP5HBF.cjs +0 -24
- package/chunk-KLHNGJ4Y.min.mjs +0 -2
- package/chunk-KLHNGJ4Y.min.mjs.map +0 -1
- package/chunk-KMNTU3DJ.mjs +0 -45
- package/chunk-LDVEXETI.cjs +0 -45
- package/chunk-LZENHV35.min.cjs +0 -2
- package/chunk-LZENHV35.min.cjs.map +0 -1
- package/chunk-M5PIM2HB.mjs +0 -42
- package/chunk-M6PYQYOX.mjs +0 -39
- package/chunk-MN5EYNZN.min.mjs +0 -2
- package/chunk-MN5EYNZN.min.mjs.map +0 -1
- package/chunk-NRIBJ2OJ.mjs +0 -16031
- package/chunk-NVLYXWLX.cjs +0 -32
- package/chunk-O352F2MT.mjs +0 -24
- package/chunk-O6B2TKFK.min.mjs +0 -2
- package/chunk-O6B2TKFK.min.mjs.map +0 -1
- package/chunk-OGF34H4T.min.cjs +0 -2
- package/chunk-OGF34H4T.min.cjs.map +0 -1
- package/chunk-OXSWWWOM.min.mjs +0 -2
- package/chunk-OXSWWWOM.min.mjs.map +0 -1
- package/chunk-PRUGHVRT.mjs +0 -14
- package/chunk-Q4WCMSOW.min.mjs +0 -2
- package/chunk-Q4WCMSOW.min.mjs.map +0 -1
- package/chunk-QH74JZCK.mjs +0 -9
- package/chunk-QNNJNLGK.min.cjs +0 -2
- package/chunk-QNNJNLGK.min.cjs.map +0 -1
- package/chunk-QWCFN7ZM.mjs +0 -15
- package/chunk-SDM2OPT6.mjs +0 -32
- package/chunk-SHKRZCF2.cjs +0 -16031
- package/chunk-SJDJDNDN.min.cjs +0 -2
- package/chunk-SJDJDNDN.min.cjs.map +0 -1
- package/chunk-SULNMALN.cjs +0 -328
- package/chunk-SV35RBZ7.min.mjs +0 -2
- package/chunk-SV35RBZ7.min.mjs.map +0 -1
- package/chunk-TJFYGFOW.mjs +0 -328
- package/chunk-UHRYBUUX.min.mjs +0 -2
- package/chunk-UHRYBUUX.min.mjs.map +0 -1
- package/chunk-UOU6IP3S.min.mjs +0 -2
- package/chunk-UOU6IP3S.min.mjs.map +0 -1
- package/chunk-V76XVNZ5.mjs +0 -20
- package/chunk-VFYQ7I5V.min.mjs +0 -2
- package/chunk-VFYQ7I5V.min.mjs.map +0 -1
- package/chunk-VG7VV7J2.mjs +0 -167
- package/chunk-VJCV56DO.cjs +0 -15
- package/chunk-VREA6AKG.cjs +0 -9
- package/chunk-W5I6Y5FK.min.mjs +0 -2
- package/chunk-W5I6Y5FK.min.mjs.map +0 -1
- package/chunk-Y7MC73BZ.cjs +0 -42
- package/chunk-YVWROQKU.mjs +0 -40
- package/chunk-ZKIZ5SWK.min.cjs +0 -2
- package/chunk-ZKIZ5SWK.min.cjs.map +0 -1
- package/chunk-ZZZB7NJX.mjs +0 -93
- package/magic-string.es-4UY437WL.min.mjs +0 -14
- package/magic-string.es-4UY437WL.min.mjs.map +0 -1
- package/magic-string.es-OAQWZQTY.mjs +0 -1323
- package/magic-string.es-UE2UVQEL.cjs +0 -1323
- package/magic-string.es-X6DNUB6Y.min.cjs +0 -14
- package/magic-string.es-X6DNUB6Y.min.cjs.map +0 -1
package/duration.mjs
CHANGED
|
@@ -1,17 +1,147 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
// src/timeConstants.ts
|
|
2
|
+
var MS_PER_SECOND = 1e3;
|
|
3
|
+
var MS_PER_MINUTE = 6e4;
|
|
4
|
+
var MS_PER_HOUR = 36e5;
|
|
5
|
+
var MS_PER_DAY = 864e5;
|
|
6
|
+
var SECONDS_PER_MINUTE = 60;
|
|
7
|
+
var MINUTES_PER_HOUR = 60;
|
|
8
|
+
var HOURS_PER_DAY = 24;
|
|
9
|
+
|
|
10
|
+
// src/duration.ts
|
|
11
|
+
var DURATION_TYPE_SEQUENCE = [
|
|
12
|
+
"days",
|
|
13
|
+
"hours",
|
|
14
|
+
"minutes",
|
|
15
|
+
"seconds",
|
|
16
|
+
"milliseconds"
|
|
17
|
+
];
|
|
18
|
+
var DURATION_STYLE_SUFFIX_MAP = {
|
|
19
|
+
days: {
|
|
20
|
+
short: "day",
|
|
21
|
+
shorts: "days",
|
|
22
|
+
long: "day",
|
|
23
|
+
longs: "days",
|
|
24
|
+
narrow: "d"
|
|
25
|
+
},
|
|
26
|
+
hours: {
|
|
27
|
+
short: "hr",
|
|
28
|
+
shorts: "hrs",
|
|
29
|
+
long: "hour",
|
|
30
|
+
longs: "hours",
|
|
31
|
+
narrow: "h"
|
|
32
|
+
},
|
|
33
|
+
minutes: {
|
|
34
|
+
short: "min",
|
|
35
|
+
shorts: "mins",
|
|
36
|
+
long: "minute",
|
|
37
|
+
longs: "minutes",
|
|
38
|
+
narrow: "m"
|
|
39
|
+
},
|
|
40
|
+
seconds: {
|
|
41
|
+
short: "sec",
|
|
42
|
+
shorts: "secs",
|
|
43
|
+
long: "second",
|
|
44
|
+
longs: "seconds",
|
|
45
|
+
narrow: "s"
|
|
46
|
+
},
|
|
47
|
+
milliseconds: {
|
|
48
|
+
short: "ms",
|
|
49
|
+
shorts: "ms",
|
|
50
|
+
long: "millisecond",
|
|
51
|
+
longs: "milliseconds",
|
|
52
|
+
narrow: "ms"
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
function getDurationStyleForPlural(style) {
|
|
56
|
+
return style == "short" ? "shorts" : style === "long" ? "longs" : style;
|
|
57
|
+
}
|
|
58
|
+
function getValueAndUnitSeparator(style) {
|
|
59
|
+
return style === "narrow" ? "" : " ";
|
|
60
|
+
}
|
|
61
|
+
function getDurationTypeSeparator(style) {
|
|
62
|
+
return style === "narrow" ? " " : ", ";
|
|
63
|
+
}
|
|
64
|
+
function msToDuration(ms, durationTypeForZero) {
|
|
65
|
+
if (ms === 0) {
|
|
66
|
+
durationTypeForZero = durationTypeForZero ?? "milliseconds";
|
|
67
|
+
return { [durationTypeForZero]: 0 };
|
|
68
|
+
}
|
|
69
|
+
const duration = {};
|
|
70
|
+
for (let i = 0; i < 1; i++) {
|
|
71
|
+
let seconds = Math.floor(ms / MS_PER_SECOND);
|
|
72
|
+
const millis = ms - seconds * MS_PER_SECOND;
|
|
73
|
+
if (millis > 0) {
|
|
74
|
+
duration["milliseconds"] = millis;
|
|
75
|
+
}
|
|
76
|
+
if (seconds === 0) {
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
let minutes = Math.floor(seconds / SECONDS_PER_MINUTE);
|
|
80
|
+
seconds -= minutes * SECONDS_PER_MINUTE;
|
|
81
|
+
if (seconds > 0) {
|
|
82
|
+
duration["seconds"] = seconds;
|
|
83
|
+
}
|
|
84
|
+
if (minutes === 0) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
let hours = Math.floor(minutes / MINUTES_PER_HOUR);
|
|
88
|
+
minutes -= hours * MINUTES_PER_HOUR;
|
|
89
|
+
if (minutes > 0) {
|
|
90
|
+
duration["minutes"] = minutes;
|
|
91
|
+
}
|
|
92
|
+
if (hours === 0) {
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
const days = Math.floor(hours / HOURS_PER_DAY);
|
|
96
|
+
hours -= days * HOURS_PER_DAY;
|
|
97
|
+
if (hours > 0) {
|
|
98
|
+
duration["hours"] = hours;
|
|
99
|
+
}
|
|
100
|
+
if (days > 0) {
|
|
101
|
+
duration["days"] = days;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return duration;
|
|
105
|
+
}
|
|
106
|
+
function durationToMs(duration) {
|
|
107
|
+
const daysMs = (duration.days ?? 0) * MS_PER_DAY;
|
|
108
|
+
const hoursMs = (duration.hours ?? 0) * MS_PER_HOUR;
|
|
109
|
+
const minsMs = (duration.minutes ?? 0) * MS_PER_MINUTE;
|
|
110
|
+
const secsMs = (duration.seconds ?? 0) * MS_PER_SECOND;
|
|
111
|
+
const msMs = duration.milliseconds ?? 0;
|
|
112
|
+
return daysMs + hoursMs + minsMs + secsMs + msMs;
|
|
113
|
+
}
|
|
114
|
+
function durationOrMsToMs(duration) {
|
|
115
|
+
return typeof duration === "number" ? duration : durationToMs(duration);
|
|
116
|
+
}
|
|
117
|
+
function formatDuration(duration, style) {
|
|
118
|
+
style = style ?? "short";
|
|
119
|
+
const stylePlural = getDurationStyleForPlural(style);
|
|
120
|
+
const space = getValueAndUnitSeparator(style);
|
|
121
|
+
const a = [];
|
|
122
|
+
for (const unit of DURATION_TYPE_SEQUENCE) {
|
|
123
|
+
const value = duration[unit];
|
|
124
|
+
if (value === void 0) continue;
|
|
125
|
+
const suffixMap = DURATION_STYLE_SUFFIX_MAP[unit];
|
|
126
|
+
const suffix = value === 1 ? suffixMap[style] : suffixMap[stylePlural];
|
|
127
|
+
a.push(value + space + suffix);
|
|
128
|
+
}
|
|
129
|
+
const separator = getDurationTypeSeparator(style);
|
|
130
|
+
return a.join(separator);
|
|
131
|
+
}
|
|
132
|
+
function readableDuration(ms, options) {
|
|
133
|
+
const duration = msToDuration(ms, options?.durationTypeForZero);
|
|
134
|
+
return formatDuration(duration, options?.style);
|
|
135
|
+
}
|
|
136
|
+
function elapsed(ms) {
|
|
137
|
+
if (ms > MS_PER_MINUTE) {
|
|
138
|
+
return readableDuration(ms);
|
|
139
|
+
}
|
|
140
|
+
if (ms > 100) {
|
|
141
|
+
return `${(ms / 1e3).toFixed(3)}s`;
|
|
142
|
+
}
|
|
143
|
+
return ms + "ms";
|
|
144
|
+
}
|
|
15
145
|
export {
|
|
16
146
|
DURATION_STYLE_SUFFIX_MAP,
|
|
17
147
|
DURATION_TYPE_SEQUENCE,
|
package/getEnv.cjs
CHANGED
|
@@ -1,20 +1,44 @@
|
|
|
1
|
-
"use strict";
|
|
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);
|
|
2
19
|
|
|
3
20
|
// src/getEnv.ts
|
|
21
|
+
var getEnv_exports = {};
|
|
22
|
+
__export(getEnv_exports, {
|
|
23
|
+
MissingEnvVarError: () => MissingEnvVarError,
|
|
24
|
+
getEnv: () => getEnv
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(getEnv_exports);
|
|
4
27
|
var MissingEnvVarError = class extends Error {
|
|
5
28
|
};
|
|
6
29
|
function getEnv(varName, defaultValue) {
|
|
7
30
|
try {
|
|
8
|
-
const value =
|
|
31
|
+
const value = process?.env?.[varName];
|
|
9
32
|
if (value) return value;
|
|
10
|
-
} catch
|
|
33
|
+
} catch {
|
|
11
34
|
}
|
|
12
35
|
if (typeof defaultValue !== "string") {
|
|
13
36
|
throw new MissingEnvVarError(`Missing process.env.${varName}`);
|
|
14
37
|
}
|
|
15
38
|
return defaultValue;
|
|
16
39
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
MissingEnvVarError,
|
|
43
|
+
getEnv
|
|
44
|
+
});
|
package/getEnv.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty
|
|
1
|
+
"use strict";var c=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var f=(t,n)=>{for(var s in n)c(t,s,{get:n[s],enumerable:!0})},l=(t,n,s,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of p(n))!g.call(t,e)&&e!==s&&c(t,e,{get:()=>n[e],enumerable:!(o=i(n,e))||o.enumerable});return t};var u=t=>l(c({},"__esModule",{value:!0}),t);var y={};f(y,{MissingEnvVarError:()=>r,getEnv:()=>x});module.exports=u(y);var r=class extends Error{};function x(t,n){try{let s=process?.env?.[t];if(s)return s}catch{}if(typeof n!="string")throw new r(`Missing process.env.${t}`);return n}0&&(module.exports={MissingEnvVarError,getEnv});
|
|
2
2
|
//# sourceMappingURL=getEnv.min.cjs.map
|
package/getEnv.min.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../src/getEnv.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\ndeclare const process: any;\n\nexport class MissingEnvVarError extends Error {}\n\n/**\n * Get an environment variable by name. If a default value is not given, and\n * the variable is empty or missing, throw MissingEnvVarError.\n *\n * If an empty string is acceptable, pass `defaultValue` as \"\".\n */\nexport function getEnv(varName: string, defaultValue?: string | null): string {\n try {\n const value = process?.env?.[varName];\n\n // This value should always be a string, unless the user sets it otherwise,\n // which is an unusual case.\n if (value) return value;\n } catch {\n // ignore\n }\n\n if (typeof defaultValue !== \"string\") {\n throw new MissingEnvVarError(`Missing process.env.${varName}`);\n }\n\n return defaultValue;\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,WAAAC,IAAA,eAAAC,EAAAJ,GAGO,IAAME,EAAN,cAAiC,KAAM,CAAC,EAQxC,SAASC,EAAOE,EAAiBC,EAAsC,CAC5E,GAAI,CACF,IAAMC,EAAQ,SAAS,MAAMF,CAAO,EAIpC,GAAIE,EAAO,OAAOA,CACpB,MAAQ,CAER,CAEA,GAAI,OAAOD,GAAiB,SAC1B,MAAM,IAAIJ,EAAmB,uBAAuBG,CAAO,EAAE,EAG/D,OAAOC,CACT","names":["getEnv_exports","__export","MissingEnvVarError","getEnv","__toCommonJS","varName","defaultValue","value"]}
|
package/getEnv.min.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
var t=class extends Error{};function r(n,s){try{let e=process?.env?.[n];if(e)return e}catch{}if(typeof s!="string")throw new t(`Missing process.env.${n}`);return s}export{t as MissingEnvVarError,r as getEnv};
|
|
2
2
|
//# sourceMappingURL=getEnv.min.mjs.map
|
package/getEnv.min.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/getEnv.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\ndeclare const process: any;\n\nexport class MissingEnvVarError extends Error {}\n\n/**\n * Get an environment variable by name. If a default value is not given, and\n * the variable is empty or missing, throw MissingEnvVarError.\n *\n * If an empty string is acceptable, pass `defaultValue` as \"\".\n */\nexport function getEnv(varName: string, defaultValue?: string | null): string {\n try {\n const value = process?.env?.[varName];\n\n // This value should always be a string, unless the user sets it otherwise,\n // which is an unusual case.\n if (value) return value;\n } catch {\n // ignore\n }\n\n if (typeof defaultValue !== \"string\") {\n throw new MissingEnvVarError(`Missing process.env.${varName}`);\n }\n\n return defaultValue;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/getEnv.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\ndeclare const process: any;\n\nexport class MissingEnvVarError extends Error {}\n\n/**\n * Get an environment variable by name. If a default value is not given, and\n * the variable is empty or missing, throw MissingEnvVarError.\n *\n * If an empty string is acceptable, pass `defaultValue` as \"\".\n */\nexport function getEnv(varName: string, defaultValue?: string | null): string {\n try {\n const value = process?.env?.[varName];\n\n // This value should always be a string, unless the user sets it otherwise,\n // which is an unusual case.\n if (value) return value;\n } catch {\n // ignore\n }\n\n if (typeof defaultValue !== \"string\") {\n throw new MissingEnvVarError(`Missing process.env.${varName}`);\n }\n\n return defaultValue;\n}\n"],"mappings":"AAGO,IAAMA,EAAN,cAAiC,KAAM,CAAC,EAQxC,SAASC,EAAOC,EAAiBC,EAAsC,CAC5E,GAAI,CACF,IAAMC,EAAQ,SAAS,MAAMF,CAAO,EAIpC,GAAIE,EAAO,OAAOA,CACpB,MAAQ,CAER,CAEA,GAAI,OAAOD,GAAiB,SAC1B,MAAM,IAAIH,EAAmB,uBAAuBE,CAAO,EAAE,EAG/D,OAAOC,CACT","names":["MissingEnvVarError","getEnv","varName","defaultValue","value"]}
|
package/getEnv.mjs
CHANGED
package/isEmpty.cjs
CHANGED
|
@@ -1,9 +1,47 @@
|
|
|
1
|
-
"use strict";
|
|
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);
|
|
2
19
|
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
20
|
+
// src/isEmpty.ts
|
|
21
|
+
var isEmpty_exports = {};
|
|
22
|
+
__export(isEmpty_exports, {
|
|
23
|
+
isEmpty: () => isEmpty
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(isEmpty_exports);
|
|
26
|
+
function isEmpty(t) {
|
|
27
|
+
if (!t) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
if (typeof t !== "object") {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if ("length" in t) {
|
|
34
|
+
return t.length === 0;
|
|
35
|
+
}
|
|
36
|
+
if ("size" in t) {
|
|
37
|
+
return t.size === 0;
|
|
38
|
+
}
|
|
39
|
+
for (const k in t) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
isEmpty
|
|
47
|
+
});
|
package/isEmpty.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(
|
|
1
|
+
"use strict";var t=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var l=(e,n)=>{for(var i in n)t(e,i,{get:n[i],enumerable:!0})},a=(e,n,i,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of o(n))!s.call(e,r)&&r!==i&&t(e,r,{get:()=>n[r],enumerable:!(u=f(n,r))||u.enumerable});return e};var c=e=>a(t({},"__esModule",{value:!0}),e);var b={};l(b,{isEmpty:()=>p});module.exports=c(b);function p(e){if(!e)return!0;if(typeof e!="object")return!1;if("length"in e)return e.length===0;if("size"in e)return e.size===0;for(let n in e)return!1;return!0}0&&(module.exports={isEmpty});
|
|
2
2
|
//# sourceMappingURL=isEmpty.min.cjs.map
|
package/isEmpty.min.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../src/isEmpty.ts"],"sourcesContent":["/**\n * Returns true if `t` is empty.\n */\nexport function isEmpty(t: unknown): boolean {\n // Anything falsy is considered empty.\n if (!t) {\n return true;\n }\n\n // Arrays are also of type `object`.\n if (typeof t !== \"object\") {\n return false;\n }\n\n // `length` includes arrays as well.\n if (\"length\" in t) {\n return t.length === 0;\n }\n\n // `size` is for Set, Map, Blob etc.\n if (\"size\" in t) {\n return t.size === 0;\n }\n\n // Super fast check for object emptiness.\n // https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object\n for (const k in t) {\n return false;\n }\n\n return true;\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAGO,SAASE,EAAQE,EAAqB,CAE3C,GAAI,CAACA,EACH,MAAO,GAIT,GAAI,OAAOA,GAAM,SACf,MAAO,GAIT,GAAI,WAAYA,EACd,OAAOA,EAAE,SAAW,EAItB,GAAI,SAAUA,EACZ,OAAOA,EAAE,OAAS,EAKpB,QAAWC,KAAKD,EACd,MAAO,GAGT,MAAO,EACT","names":["isEmpty_exports","__export","isEmpty","__toCommonJS","t","k"]}
|
package/isEmpty.min.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function r(e){if(!e)return!0;if(typeof e!="object")return!1;if("length"in e)return e.length===0;if("size"in e)return e.size===0;for(let n in e)return!1;return!0}export{r as isEmpty};
|
|
2
2
|
//# sourceMappingURL=isEmpty.min.mjs.map
|
package/isEmpty.min.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/isEmpty.ts"],"sourcesContent":["/**\n * Returns true if `t` is empty.\n */\nexport function isEmpty(t: unknown): boolean {\n // Anything falsy is considered empty.\n if (!t) {\n return true;\n }\n\n // Arrays are also of type `object`.\n if (typeof t !== \"object\") {\n return false;\n }\n\n // `length` includes arrays as well.\n if (\"length\" in t) {\n return t.length === 0;\n }\n\n // `size` is for Set, Map, Blob etc.\n if (\"size\" in t) {\n return t.size === 0;\n }\n\n // Super fast check for object emptiness.\n // https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object\n for (const k in t) {\n return false;\n }\n\n return true;\n}\n"],"mappings":"AAGO,SAASA,EAAQC,EAAqB,CAE3C,GAAI,CAACA,EACH,MAAO,GAIT,GAAI,OAAOA,GAAM,SACf,MAAO,GAIT,GAAI,WAAYA,EACd,OAAOA,EAAE,SAAW,EAItB,GAAI,SAAUA,EACZ,OAAOA,EAAE,OAAS,EAKpB,QAAWC,KAAKD,EACd,MAAO,GAGT,MAAO,EACT","names":["isEmpty","t","k"]}
|
package/isEmpty.mjs
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// src/isEmpty.ts
|
|
2
|
+
function isEmpty(t) {
|
|
3
|
+
if (!t) {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
if (typeof t !== "object") {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if ("length" in t) {
|
|
10
|
+
return t.length === 0;
|
|
11
|
+
}
|
|
12
|
+
if ("size" in t) {
|
|
13
|
+
return t.size === 0;
|
|
14
|
+
}
|
|
15
|
+
for (const k in t) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
7
20
|
export {
|
|
8
21
|
isEmpty
|
|
9
22
|
};
|
package/isPromise.cjs
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
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);
|
|
2
19
|
|
|
3
20
|
// src/isPromise.ts
|
|
21
|
+
var isPromise_exports = {};
|
|
22
|
+
__export(isPromise_exports, {
|
|
23
|
+
isNativePromise: () => isNativePromise,
|
|
24
|
+
isPromise: () => isPromise
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(isPromise_exports);
|
|
4
27
|
function isPromise(obj) {
|
|
5
28
|
if (!obj || typeof obj !== "object" && typeof obj !== "function") {
|
|
6
29
|
return false;
|
|
@@ -10,7 +33,8 @@ function isPromise(obj) {
|
|
|
10
33
|
function isNativePromise(obj) {
|
|
11
34
|
return obj instanceof Promise;
|
|
12
35
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
isNativePromise,
|
|
39
|
+
isPromise
|
|
40
|
+
});
|
package/isPromise.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(
|
|
1
|
+
"use strict";var t=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var c=(n,e)=>{for(var i in e)t(n,i,{get:e[i],enumerable:!0})},m=(n,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of u(e))!f.call(n,o)&&o!==i&&t(n,o,{get:()=>e[o],enumerable:!(r=s(e,o))||r.enumerable});return n};var p=n=>m(t({},"__esModule",{value:!0}),n);var w={};c(w,{isNativePromise:()=>k,isPromise:()=>P});module.exports=p(w);function P(n){return!n||typeof n!="object"&&typeof n!="function"?!1:"then"in n&&typeof n.then=="function"}function k(n){return n instanceof Promise}0&&(module.exports={isNativePromise,isPromise});
|
|
2
2
|
//# sourceMappingURL=isPromise.min.cjs.map
|
package/isPromise.min.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../src/isPromise.ts"],"sourcesContent":["/**\n * A type guard to check if an object is a Promise (or a \"thenable\"). It checks\n * if the object is not null, is an object, and has a callable .then method.\n *\n * Note that if the Promise expects a certain type like `Promise<T>`, there is\n * no way to validate the type of T unless we resolve the promise. This function\n * does not attempt to typecheck for T in any way.\n */\nexport function isPromise(obj: unknown): obj is Promise<unknown> {\n // Check if the object is defined and not null.\n if (!obj || (typeof obj !== \"object\" && typeof obj !== \"function\")) {\n return false;\n }\n\n // Check if the .then property is a function (callable).\n return \"then\" in obj && typeof obj.then === \"function\";\n}\n\n/**\n * A type guard to check if an object is a native Promise.\n *\n * Note that if the Promise expects a certain type like `Promise<T>`, there is\n * no way to validate the type of T unless we resolve the promise. This function\n * does not attempt to typecheck for T in any way.\n */\nexport function isNativePromise(obj: unknown): obj is Promise<unknown> {\n return obj instanceof Promise;\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,cAAAC,IAAA,eAAAC,EAAAJ,GAQO,SAASG,EAAUE,EAAuC,CAE/D,MAAI,CAACA,GAAQ,OAAOA,GAAQ,UAAY,OAAOA,GAAQ,WAC9C,GAIF,SAAUA,GAAO,OAAOA,EAAI,MAAS,UAC9C,CASO,SAASH,EAAgBG,EAAuC,CACrE,OAAOA,aAAe,OACxB","names":["isPromise_exports","__export","isNativePromise","isPromise","__toCommonJS","obj"]}
|
package/isPromise.min.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function e(n){return!n||typeof n!="object"&&typeof n!="function"?!1:"then"in n&&typeof n.then=="function"}function o(n){return n instanceof Promise}export{o as isNativePromise,e as isPromise};
|
|
2
2
|
//# sourceMappingURL=isPromise.min.mjs.map
|
package/isPromise.min.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/isPromise.ts"],"sourcesContent":["/**\n * A type guard to check if an object is a Promise (or a \"thenable\"). It checks\n * if the object is not null, is an object, and has a callable .then method.\n *\n * Note that if the Promise expects a certain type like `Promise<T>`, there is\n * no way to validate the type of T unless we resolve the promise. This function\n * does not attempt to typecheck for T in any way.\n */\nexport function isPromise(obj: unknown): obj is Promise<unknown> {\n // Check if the object is defined and not null.\n if (!obj || (typeof obj !== \"object\" && typeof obj !== \"function\")) {\n return false;\n }\n\n // Check if the .then property is a function (callable).\n return \"then\" in obj && typeof obj.then === \"function\";\n}\n\n/**\n * A type guard to check if an object is a native Promise.\n *\n * Note that if the Promise expects a certain type like `Promise<T>`, there is\n * no way to validate the type of T unless we resolve the promise. This function\n * does not attempt to typecheck for T in any way.\n */\nexport function isNativePromise(obj: unknown): obj is Promise<unknown> {\n return obj instanceof Promise;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/isPromise.ts"],"sourcesContent":["/**\n * A type guard to check if an object is a Promise (or a \"thenable\"). It checks\n * if the object is not null, is an object, and has a callable .then method.\n *\n * Note that if the Promise expects a certain type like `Promise<T>`, there is\n * no way to validate the type of T unless we resolve the promise. This function\n * does not attempt to typecheck for T in any way.\n */\nexport function isPromise(obj: unknown): obj is Promise<unknown> {\n // Check if the object is defined and not null.\n if (!obj || (typeof obj !== \"object\" && typeof obj !== \"function\")) {\n return false;\n }\n\n // Check if the .then property is a function (callable).\n return \"then\" in obj && typeof obj.then === \"function\";\n}\n\n/**\n * A type guard to check if an object is a native Promise.\n *\n * Note that if the Promise expects a certain type like `Promise<T>`, there is\n * no way to validate the type of T unless we resolve the promise. This function\n * does not attempt to typecheck for T in any way.\n */\nexport function isNativePromise(obj: unknown): obj is Promise<unknown> {\n return obj instanceof Promise;\n}\n"],"mappings":"AAQO,SAASA,EAAUC,EAAuC,CAE/D,MAAI,CAACA,GAAQ,OAAOA,GAAQ,UAAY,OAAOA,GAAQ,WAC9C,GAIF,SAAUA,GAAO,OAAOA,EAAI,MAAS,UAC9C,CASO,SAASC,EAAgBD,EAAuC,CACrE,OAAOA,aAAe,OACxB","names":["isPromise","obj","isNativePromise"]}
|