qstd 0.1.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.
- package/CHANGELOG.md +23 -0
- package/README.md +127 -0
- package/dist/client/index.cjs +587 -0
- package/dist/client/index.d.cts +75 -0
- package/dist/client/index.d.ts +75 -0
- package/dist/client/index.js +577 -0
- package/dist/preset/index.cjs +475 -0
- package/dist/preset/index.d.cts +39 -0
- package/dist/preset/index.d.ts +39 -0
- package/dist/preset/index.js +473 -0
- package/dist/random-DMErOOdk.d.cts +447 -0
- package/dist/random-DMErOOdk.d.ts +447 -0
- package/dist/react/index.cjs +3155 -0
- package/dist/react/index.css +1566 -0
- package/dist/react/index.d.cts +21092 -0
- package/dist/react/index.d.ts +21092 -0
- package/dist/react/index.js +3128 -0
- package/dist/server/index.cjs +541 -0
- package/dist/server/index.d.cts +17 -0
- package/dist/server/index.d.ts +17 -0
- package/dist/server/index.js +527 -0
- package/package.json +111 -0
- package/panda.config.ts +68 -0
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var dateFns = require('date-fns');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// src/shared/list.ts
|
|
17
|
+
var list_exports = {};
|
|
18
|
+
__export(list_exports, {
|
|
19
|
+
chunk: () => chunk,
|
|
20
|
+
create: () => create,
|
|
21
|
+
partition: () => partition,
|
|
22
|
+
zipWith: () => zipWith
|
|
23
|
+
});
|
|
24
|
+
function zipWith(fn, ...arrays) {
|
|
25
|
+
if (arrays.length === 0) return [];
|
|
26
|
+
const minLength = Math.min(...arrays.map((arr) => arr.length));
|
|
27
|
+
const result = [];
|
|
28
|
+
for (let i = 0; i < minLength; i++) {
|
|
29
|
+
const args = arrays.map((arr) => arr[i]);
|
|
30
|
+
result.push(fn(...args));
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
var create = (size, fn) => fn ? Array(size).fill(null).map(fn) : Array(size).fill(null);
|
|
35
|
+
var partition = (xs, predicate) => xs.reduce(
|
|
36
|
+
([truthList, falseList], x) => {
|
|
37
|
+
const passes = predicate(x);
|
|
38
|
+
if (passes) truthList.push(x);
|
|
39
|
+
else falseList.push(x);
|
|
40
|
+
return [truthList, falseList];
|
|
41
|
+
},
|
|
42
|
+
[[], []]
|
|
43
|
+
);
|
|
44
|
+
var chunk = (list, chunkSize) => {
|
|
45
|
+
const totalChunks = Math.ceil(list.length / chunkSize);
|
|
46
|
+
return Array.from({ length: totalChunks }, (_, i) => {
|
|
47
|
+
const start = i * chunkSize;
|
|
48
|
+
const end = i * chunkSize + chunkSize;
|
|
49
|
+
return list.slice(start, end);
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/shared/dict.ts
|
|
54
|
+
var dict_exports = {};
|
|
55
|
+
__export(dict_exports, {
|
|
56
|
+
byteSizeOfObj: () => byteSizeOfObj,
|
|
57
|
+
exists: () => exists,
|
|
58
|
+
filter: () => filter,
|
|
59
|
+
isEmpty: () => isEmpty,
|
|
60
|
+
omit: () => omit,
|
|
61
|
+
partition: () => partition2,
|
|
62
|
+
pick: () => pick,
|
|
63
|
+
transform: () => transform
|
|
64
|
+
});
|
|
65
|
+
function byteSizeOfObj(o) {
|
|
66
|
+
const objectList = [];
|
|
67
|
+
const stack = [o];
|
|
68
|
+
const bytes = [0];
|
|
69
|
+
while (stack.length) {
|
|
70
|
+
const value = stack.pop();
|
|
71
|
+
if (value == null) bytes[0] += 4;
|
|
72
|
+
else if (typeof value === "boolean") bytes[0] += 4;
|
|
73
|
+
else if (typeof value === "string") bytes[0] += value.length * 2;
|
|
74
|
+
else if (typeof value === "number") bytes[0] += 8;
|
|
75
|
+
else if (typeof value === "object" && objectList.indexOf(value) === -1) {
|
|
76
|
+
objectList.push(value);
|
|
77
|
+
if (typeof value.byteLength === "number") bytes[0] += value.byteLength;
|
|
78
|
+
else if (value[Symbol.iterator]) {
|
|
79
|
+
for (const v of value) stack.push(v);
|
|
80
|
+
} else {
|
|
81
|
+
Object.keys(value).forEach((k) => {
|
|
82
|
+
bytes[0] += k.length * 2;
|
|
83
|
+
stack.push(value[k]);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return bytes[0];
|
|
89
|
+
}
|
|
90
|
+
var filter = (r, predicate) => Object.entries(r).reduce(
|
|
91
|
+
(store, [key, value]) => predicate(value) ? { ...store, [key]: value } : store,
|
|
92
|
+
{}
|
|
93
|
+
);
|
|
94
|
+
var transform = (r, transformFn) => Object.entries(r).reduce(
|
|
95
|
+
(store, [key, value]) => ({
|
|
96
|
+
...store,
|
|
97
|
+
...transformFn(key, value)
|
|
98
|
+
}),
|
|
99
|
+
{}
|
|
100
|
+
);
|
|
101
|
+
var partition2 = (r, predicate) => {
|
|
102
|
+
const passed = {};
|
|
103
|
+
const failed = {};
|
|
104
|
+
for (const key in r) {
|
|
105
|
+
if (predicate(key)) passed[key] = r[key];
|
|
106
|
+
else failed[key] = r[key];
|
|
107
|
+
}
|
|
108
|
+
return [passed, failed];
|
|
109
|
+
};
|
|
110
|
+
var exists = (obj) => {
|
|
111
|
+
return obj && typeof obj === "object" && Object.keys(obj).length > 0;
|
|
112
|
+
};
|
|
113
|
+
var isEmpty = (obj) => {
|
|
114
|
+
return !obj || Object.keys(obj).length === 0 && obj.constructor === Object;
|
|
115
|
+
};
|
|
116
|
+
var pick = (r, paths) => Object.entries(r).reduce(
|
|
117
|
+
(store, [key, value]) => paths.includes(key) ? { ...store, [key]: value } : store,
|
|
118
|
+
{}
|
|
119
|
+
);
|
|
120
|
+
var omit = (r, paths) => {
|
|
121
|
+
if (!r) {
|
|
122
|
+
throw new Error("[omit] item was not an object");
|
|
123
|
+
}
|
|
124
|
+
return Object.entries(r).reduce((store, [key, value]) => {
|
|
125
|
+
if (paths.includes(key)) {
|
|
126
|
+
return store;
|
|
127
|
+
} else {
|
|
128
|
+
store[key] = value;
|
|
129
|
+
return store;
|
|
130
|
+
}
|
|
131
|
+
}, {});
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// src/shared/str.ts
|
|
135
|
+
var str_exports = {};
|
|
136
|
+
__export(str_exports, {
|
|
137
|
+
concat: () => concat,
|
|
138
|
+
countChar: () => countChar,
|
|
139
|
+
countWords: () => countWords,
|
|
140
|
+
createSentences: () => createSentences,
|
|
141
|
+
toCase: () => toCase
|
|
142
|
+
});
|
|
143
|
+
var createSentences = (text) => {
|
|
144
|
+
if (!text) return [];
|
|
145
|
+
return text?.replace(/([.?!])\s*(?=[A-Z])/g, "$1|").split("|");
|
|
146
|
+
};
|
|
147
|
+
var countWords = (text) => {
|
|
148
|
+
text = text.trim();
|
|
149
|
+
if (text.length === 0) {
|
|
150
|
+
return 0;
|
|
151
|
+
}
|
|
152
|
+
const wordPattern = /\w+/g;
|
|
153
|
+
const matches = text.match(wordPattern);
|
|
154
|
+
return matches ? matches.length : 0;
|
|
155
|
+
};
|
|
156
|
+
var concat = (xs, delimiter) => {
|
|
157
|
+
return xs.filter((x) => !!x).join(delimiter);
|
|
158
|
+
};
|
|
159
|
+
var countChar = (str, ch) => {
|
|
160
|
+
return str.split("").reduce((x, y) => y === ch ? x + 1 : x, 0);
|
|
161
|
+
};
|
|
162
|
+
var toCase = (text, opts) => {
|
|
163
|
+
switch (opts.to) {
|
|
164
|
+
case "title":
|
|
165
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
166
|
+
case "snake":
|
|
167
|
+
return text.replace(
|
|
168
|
+
/[A-Z]/g,
|
|
169
|
+
(l, idx) => idx === 0 ? l.toLowerCase() : "_" + l.toLowerCase()
|
|
170
|
+
);
|
|
171
|
+
case "kebab": {
|
|
172
|
+
const lowered = text.toLowerCase().trim();
|
|
173
|
+
const cleaned = opts.clean ? lowered.replaceAll(/[:,]/g, "") : lowered;
|
|
174
|
+
return cleaned.replaceAll(/\s+/g, "-");
|
|
175
|
+
}
|
|
176
|
+
default:
|
|
177
|
+
return text;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// src/shared/int.ts
|
|
182
|
+
var int_exports = {};
|
|
183
|
+
__export(int_exports, {
|
|
184
|
+
clamp: () => clamp,
|
|
185
|
+
commaSeparateThousandths: () => commaSeparateThousandths,
|
|
186
|
+
formatBytes: () => formatBytes
|
|
187
|
+
});
|
|
188
|
+
var clamp = (num2, range) => Math.min(Math.max(num2, range.min), range.max);
|
|
189
|
+
var isNumeric = (x) => {
|
|
190
|
+
return /^[0-9]+$/.test(x);
|
|
191
|
+
};
|
|
192
|
+
var commaSeparateThousandths = (n) => {
|
|
193
|
+
if (typeof n === "string" && !isNumeric(n)) {
|
|
194
|
+
throw new Error(`[comma separate thousandths] Value ${n} must be a number`);
|
|
195
|
+
}
|
|
196
|
+
return Number(n).toLocaleString("en-US");
|
|
197
|
+
};
|
|
198
|
+
var formatBytes = (bytes, decimals = 1, binaryUnits = false) => {
|
|
199
|
+
if (!bytes) return {};
|
|
200
|
+
if (bytes === 0) return { value: 0, unit: "Bytes" };
|
|
201
|
+
const unitMultiple = binaryUnits ? 1024 : 1e3;
|
|
202
|
+
const unitNames = unitMultiple === 1024 ? ["Bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] : ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
203
|
+
const unitChanges = Math.floor(Math.log(bytes) / Math.log(unitMultiple));
|
|
204
|
+
const value = parseFloat(
|
|
205
|
+
(bytes / Math.pow(unitMultiple, unitChanges)).toFixed(decimals || 0)
|
|
206
|
+
);
|
|
207
|
+
const unit = unitNames[unitChanges];
|
|
208
|
+
return { value, unit, display: `${value}${unit}` };
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// src/shared/money.ts
|
|
212
|
+
var money_exports = {};
|
|
213
|
+
__export(money_exports, {
|
|
214
|
+
convertToCents: () => convertToCents,
|
|
215
|
+
convertToUsd: () => convertToUsd
|
|
216
|
+
});
|
|
217
|
+
var convertToUsd = (cents, opts = {}) => {
|
|
218
|
+
if (!cents) return;
|
|
219
|
+
const dollars = (Number(cents) / 100).toLocaleString("en-US", {
|
|
220
|
+
style: "currency",
|
|
221
|
+
currency: "USD"
|
|
222
|
+
});
|
|
223
|
+
const showSymbol = opts.symbol ?? true;
|
|
224
|
+
return showSymbol ? dollars : dollars.slice(1);
|
|
225
|
+
};
|
|
226
|
+
var convertToCents = (dollars) => {
|
|
227
|
+
const str = dollars.toString().replaceAll(/[\$,]+/g, "");
|
|
228
|
+
return Number(str) * 100;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// src/shared/time.ts
|
|
232
|
+
var time_exports = {};
|
|
233
|
+
__export(time_exports, {
|
|
234
|
+
adjustDate: () => adjustDate,
|
|
235
|
+
formatDate: () => formatDate,
|
|
236
|
+
formatDateRange: () => formatDateRange,
|
|
237
|
+
formatDuration: () => formatDuration,
|
|
238
|
+
formatThreadDateRange: () => formatThreadDateRange,
|
|
239
|
+
now: () => now,
|
|
240
|
+
sleep: () => sleep,
|
|
241
|
+
toMs: () => toMs
|
|
242
|
+
});
|
|
243
|
+
var formatDuration = (ms, options = {}) => {
|
|
244
|
+
if (ms === null || ms === void 0) return "--:--";
|
|
245
|
+
const { format: fmt = "clock", showZero = false } = options;
|
|
246
|
+
const totalSeconds = Math.floor(Math.abs(ms) / 1e3);
|
|
247
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
248
|
+
const minutes = Math.floor(totalSeconds % 3600 / 60);
|
|
249
|
+
const seconds = totalSeconds % 60;
|
|
250
|
+
if (fmt === "clock") {
|
|
251
|
+
if (hours > 0) {
|
|
252
|
+
return `${hours}:${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`;
|
|
253
|
+
}
|
|
254
|
+
return `${minutes}:${seconds.toString().padStart(2, "0")}`;
|
|
255
|
+
}
|
|
256
|
+
if (fmt === "full") {
|
|
257
|
+
const parts2 = [];
|
|
258
|
+
if (showZero) {
|
|
259
|
+
const hasHours = hours > 0;
|
|
260
|
+
const hasMinutes = minutes > 0;
|
|
261
|
+
const hasSeconds = seconds > 0;
|
|
262
|
+
if (hasHours || hasMinutes || hasSeconds) {
|
|
263
|
+
if (hasHours) parts2.push(`${hours} ${hours === 1 ? "hour" : "hours"}`);
|
|
264
|
+
if (hasHours || hasMinutes)
|
|
265
|
+
parts2.push(`${minutes} ${minutes === 1 ? "minute" : "minutes"}`);
|
|
266
|
+
parts2.push(`${seconds} ${seconds === 1 ? "second" : "seconds"}`);
|
|
267
|
+
} else {
|
|
268
|
+
parts2.push("0 seconds");
|
|
269
|
+
}
|
|
270
|
+
} else {
|
|
271
|
+
if (hours > 0) parts2.push(`${hours} ${hours === 1 ? "hour" : "hours"}`);
|
|
272
|
+
if (minutes > 0)
|
|
273
|
+
parts2.push(`${minutes} ${minutes === 1 ? "minute" : "minutes"}`);
|
|
274
|
+
if (seconds > 0)
|
|
275
|
+
parts2.push(`${seconds} ${seconds === 1 ? "second" : "seconds"}`);
|
|
276
|
+
}
|
|
277
|
+
return parts2.join(" ") || "0 seconds";
|
|
278
|
+
}
|
|
279
|
+
if (fmt === "fractional") {
|
|
280
|
+
const totalSecondsWithFraction = Math.abs(ms) / 1e3;
|
|
281
|
+
const totalMinutes = Math.floor(totalSecondsWithFraction / 60);
|
|
282
|
+
if (totalMinutes === 0) {
|
|
283
|
+
const fractionalSeconds = totalSecondsWithFraction.toFixed(1);
|
|
284
|
+
return `${fractionalSeconds}s`;
|
|
285
|
+
} else {
|
|
286
|
+
const remainingSeconds = totalSecondsWithFraction % 60;
|
|
287
|
+
const fractionalSeconds = remainingSeconds.toFixed(1);
|
|
288
|
+
return `${totalMinutes}m ${fractionalSeconds}s`;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
const parts = [];
|
|
292
|
+
if (showZero) {
|
|
293
|
+
const hasHours = hours > 0;
|
|
294
|
+
const hasMinutes = minutes > 0;
|
|
295
|
+
const hasSeconds = seconds > 0;
|
|
296
|
+
if (hasHours || hasMinutes || hasSeconds) {
|
|
297
|
+
if (hasHours) parts.push(`${hours}h`);
|
|
298
|
+
if (hasHours || hasMinutes) parts.push(`${minutes}m`);
|
|
299
|
+
parts.push(`${seconds}s`);
|
|
300
|
+
} else {
|
|
301
|
+
parts.push("0s");
|
|
302
|
+
}
|
|
303
|
+
} else {
|
|
304
|
+
if (hours > 0) parts.push(`${hours}h`);
|
|
305
|
+
if (minutes > 0) parts.push(`${minutes}m`);
|
|
306
|
+
if (seconds > 0) parts.push(`${seconds}s`);
|
|
307
|
+
}
|
|
308
|
+
return parts.join(" ") || "0s";
|
|
309
|
+
};
|
|
310
|
+
var formatDate = (input, options = {}) => {
|
|
311
|
+
const { style = "medium", pattern, includeTime = false } = options;
|
|
312
|
+
let date2;
|
|
313
|
+
if (typeof input === "string") {
|
|
314
|
+
date2 = new Date(input);
|
|
315
|
+
} else if (typeof input === "number") {
|
|
316
|
+
date2 = new Date(input);
|
|
317
|
+
} else {
|
|
318
|
+
date2 = input;
|
|
319
|
+
}
|
|
320
|
+
if (isNaN(date2.getTime())) {
|
|
321
|
+
return "Invalid Date";
|
|
322
|
+
}
|
|
323
|
+
if (pattern) {
|
|
324
|
+
return dateFns.format(date2, pattern);
|
|
325
|
+
}
|
|
326
|
+
switch (style) {
|
|
327
|
+
case "iso":
|
|
328
|
+
return dateFns.formatISO(date2);
|
|
329
|
+
case "short":
|
|
330
|
+
return includeTime ? dateFns.format(date2, "M/d/yy h:mm a") : dateFns.format(date2, "M/d/yy");
|
|
331
|
+
case "medium":
|
|
332
|
+
return includeTime ? dateFns.format(date2, "MMM d, yyyy h:mm a") : dateFns.format(date2, "MMM d, yyyy");
|
|
333
|
+
case "long":
|
|
334
|
+
return includeTime ? dateFns.format(date2, "MMMM d, yyyy 'at' h:mm a") : dateFns.format(date2, "MMMM d, yyyy");
|
|
335
|
+
case "relative":
|
|
336
|
+
return dateFns.formatDistanceToNow(date2, { addSuffix: true });
|
|
337
|
+
case "year":
|
|
338
|
+
return dateFns.format(date2, "yyyy");
|
|
339
|
+
default:
|
|
340
|
+
return includeTime ? dateFns.format(date2, "MMM d, yyyy h:mm a") : dateFns.format(date2, "MMM d, yyyy");
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
var toDate = (input) => typeof input === "string" || typeof input === "number" ? new Date(input) : input;
|
|
344
|
+
var formatDateRange = (startInput, endInput, options = {}) => {
|
|
345
|
+
const now2 = options.now ?? /* @__PURE__ */ new Date();
|
|
346
|
+
const showTimeWhenSameDay = options.showTimeWhenSameDay ?? true;
|
|
347
|
+
const markToday = options.markToday ?? true;
|
|
348
|
+
const todayLabel = options.todayLabel ?? "today";
|
|
349
|
+
const separator = options.separator ?? " - ";
|
|
350
|
+
const monthPattern = options.monthFormat === "long" ? "MMMM" : "MMM";
|
|
351
|
+
const lowercaseAmPm = options.lowercaseAmPm ?? true;
|
|
352
|
+
const { locale } = options;
|
|
353
|
+
let start = toDate(startInput);
|
|
354
|
+
let end = toDate(endInput);
|
|
355
|
+
if (start.getTime() > end.getTime()) {
|
|
356
|
+
const tmp = start;
|
|
357
|
+
start = end;
|
|
358
|
+
end = tmp;
|
|
359
|
+
}
|
|
360
|
+
if (isNaN(start.getTime()) || isNaN(end.getTime())) return "";
|
|
361
|
+
const sameYear = dateFns.isSameYear(start, end);
|
|
362
|
+
const sameMonth = sameYear && dateFns.isSameMonth(start, end);
|
|
363
|
+
const sameDay = sameMonth && dateFns.isSameDay(start, end);
|
|
364
|
+
const isStartToday = dateFns.isSameDay(start, now2);
|
|
365
|
+
const isEndToday = dateFns.isSameDay(end, now2);
|
|
366
|
+
const appendToday = (base, isTodayFlag) => markToday && isTodayFlag ? `${base} (${todayLabel})` : base;
|
|
367
|
+
const fmt = (d, pattern) => locale ? dateFns.format(d, pattern, { locale }) : dateFns.format(d, pattern);
|
|
368
|
+
if (sameDay) {
|
|
369
|
+
const dayPart = appendToday(
|
|
370
|
+
fmt(start, `${monthPattern} d`),
|
|
371
|
+
isStartToday || isEndToday
|
|
372
|
+
);
|
|
373
|
+
if (!showTimeWhenSameDay) return dayPart;
|
|
374
|
+
const timePattern = "h:mma";
|
|
375
|
+
const formatTime = (d) => lowercaseAmPm ? fmt(d, timePattern).toLowerCase() : fmt(d, timePattern);
|
|
376
|
+
const startTime = formatTime(start);
|
|
377
|
+
const endTime = formatTime(end);
|
|
378
|
+
return `${dayPart}, ${startTime}${separator}${endTime}`;
|
|
379
|
+
}
|
|
380
|
+
if (sameMonth) {
|
|
381
|
+
const monthPart = fmt(start, monthPattern);
|
|
382
|
+
const startDay = fmt(start, "d");
|
|
383
|
+
const endDay = fmt(end, "d");
|
|
384
|
+
const startSegment = appendToday(startDay, isStartToday);
|
|
385
|
+
const endSegment = appendToday(endDay, isEndToday);
|
|
386
|
+
const yearPart = fmt(start, "yyyy");
|
|
387
|
+
return `${monthPart} ${startSegment}${separator}${endSegment}, ${yearPart}`;
|
|
388
|
+
}
|
|
389
|
+
if (sameYear) {
|
|
390
|
+
const startPart2 = appendToday(
|
|
391
|
+
fmt(start, `${monthPattern} d`),
|
|
392
|
+
isStartToday
|
|
393
|
+
);
|
|
394
|
+
const endPart2 = appendToday(fmt(end, `${monthPattern} d`), isEndToday);
|
|
395
|
+
const yearPart = fmt(start, "yyyy");
|
|
396
|
+
return `${startPart2}${separator}${endPart2}, ${yearPart}`;
|
|
397
|
+
}
|
|
398
|
+
const startPart = appendToday(
|
|
399
|
+
fmt(start, `${monthPattern} d, yyyy`),
|
|
400
|
+
isStartToday
|
|
401
|
+
);
|
|
402
|
+
const endPart = appendToday(fmt(end, `${monthPattern} d, yyyy`), isEndToday);
|
|
403
|
+
return `${startPart}${separator}${endPart}`;
|
|
404
|
+
};
|
|
405
|
+
var formatThreadDateRange = (startInput, endInput, options = {}) => formatDateRange(startInput, endInput, options);
|
|
406
|
+
var adjustDate = (adjustment, baseDate = /* @__PURE__ */ new Date()) => {
|
|
407
|
+
let result = new Date(baseDate);
|
|
408
|
+
if (adjustment.seconds) result = dateFns.addSeconds(result, adjustment.seconds);
|
|
409
|
+
if (adjustment.minutes) result = dateFns.addMinutes(result, adjustment.minutes);
|
|
410
|
+
if (adjustment.hours) result = dateFns.addHours(result, adjustment.hours);
|
|
411
|
+
if (adjustment.days) result = dateFns.addDays(result, adjustment.days);
|
|
412
|
+
if (adjustment.weeks) result = dateFns.addWeeks(result, adjustment.weeks);
|
|
413
|
+
if (adjustment.businessDays)
|
|
414
|
+
result = dateFns.addBusinessDays(result, adjustment.businessDays);
|
|
415
|
+
if (adjustment.months) result = dateFns.addMonths(result, adjustment.months);
|
|
416
|
+
if (adjustment.years) result = dateFns.addYears(result, adjustment.years);
|
|
417
|
+
return result;
|
|
418
|
+
};
|
|
419
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
420
|
+
var now = () => Date.now();
|
|
421
|
+
var toMs = (value, unit = "seconds") => {
|
|
422
|
+
const multipliers = {
|
|
423
|
+
seconds: 1e3,
|
|
424
|
+
minutes: 60 * 1e3,
|
|
425
|
+
hours: 60 * 60 * 1e3,
|
|
426
|
+
days: 24 * 60 * 60 * 1e3,
|
|
427
|
+
weeks: 7 * 24 * 60 * 60 * 1e3,
|
|
428
|
+
months: 30 * 24 * 60 * 60 * 1e3,
|
|
429
|
+
// approximate
|
|
430
|
+
years: 365 * 24 * 60 * 60 * 1e3
|
|
431
|
+
// approximate
|
|
432
|
+
};
|
|
433
|
+
return value * multipliers[unit];
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
// src/shared/flow.ts
|
|
437
|
+
var flow_exports = {};
|
|
438
|
+
__export(flow_exports, {
|
|
439
|
+
asyncPool: () => asyncPool,
|
|
440
|
+
debounce: () => debounce,
|
|
441
|
+
sleep: () => sleep2,
|
|
442
|
+
throttle: () => throttle
|
|
443
|
+
});
|
|
444
|
+
var throttle = (fn, ms) => {
|
|
445
|
+
let time = Date.now();
|
|
446
|
+
return (...args) => {
|
|
447
|
+
if (time + ms - Date.now() < 0) {
|
|
448
|
+
fn(...args);
|
|
449
|
+
time = Date.now();
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
};
|
|
453
|
+
var debounce = (fn, timeout) => {
|
|
454
|
+
let timer;
|
|
455
|
+
return (...args) => {
|
|
456
|
+
clearTimeout(timer);
|
|
457
|
+
timer = setTimeout(() => {
|
|
458
|
+
fn(...args);
|
|
459
|
+
}, timeout);
|
|
460
|
+
};
|
|
461
|
+
};
|
|
462
|
+
var sleep2 = (ms) => new Promise((res) => setTimeout(res, ms));
|
|
463
|
+
async function* asyncPool(concurrency, iterable, iterator_fn) {
|
|
464
|
+
const executing = /* @__PURE__ */ new Set();
|
|
465
|
+
const consume = async () => {
|
|
466
|
+
const [promise, value] = await Promise.race(executing);
|
|
467
|
+
executing.delete(promise);
|
|
468
|
+
return value;
|
|
469
|
+
};
|
|
470
|
+
for (const item2 of iterable) {
|
|
471
|
+
const promise = (async () => await iterator_fn(item2, iterable))().then(
|
|
472
|
+
(value) => [promise, value]
|
|
473
|
+
);
|
|
474
|
+
executing.add(promise);
|
|
475
|
+
if (executing.size >= concurrency) {
|
|
476
|
+
yield await consume();
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
while (executing.size) {
|
|
480
|
+
yield await consume();
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// src/shared/random.ts
|
|
485
|
+
var random_exports = {};
|
|
486
|
+
__export(random_exports, {
|
|
487
|
+
coinFlip: () => coinFlip,
|
|
488
|
+
date: () => date,
|
|
489
|
+
hexColor: () => hexColor,
|
|
490
|
+
item: () => item,
|
|
491
|
+
num: () => num,
|
|
492
|
+
shuffle: () => shuffle
|
|
493
|
+
});
|
|
494
|
+
var item = (xs) => {
|
|
495
|
+
const rand = Math.random() * xs.length;
|
|
496
|
+
const flooredRand = Math.floor(rand);
|
|
497
|
+
return xs[flooredRand];
|
|
498
|
+
};
|
|
499
|
+
var num = (props = {}) => {
|
|
500
|
+
const { min = 0, max = Number.MAX_SAFE_INTEGER } = props;
|
|
501
|
+
return Math.floor(Math.pow(10, 14) * Math.random() * Math.random()) % (max - min + 1) + min;
|
|
502
|
+
};
|
|
503
|
+
var shuffle = (xs) => {
|
|
504
|
+
return xs.reduceRight((r, _, __, s) => {
|
|
505
|
+
const randomItem = s.splice(0 | Math.random() * s.length, 1)[0];
|
|
506
|
+
return r.push(randomItem), r;
|
|
507
|
+
}, []);
|
|
508
|
+
};
|
|
509
|
+
var coinFlip = () => {
|
|
510
|
+
return Math.random() < 0.5;
|
|
511
|
+
};
|
|
512
|
+
var date = () => {
|
|
513
|
+
return new Date(+/* @__PURE__ */ new Date() - Math.floor(Math.random() * 1e13));
|
|
514
|
+
};
|
|
515
|
+
var hexColor = () => {
|
|
516
|
+
const hex = Math.floor(Math.random() * 16777215).toString(16);
|
|
517
|
+
if (hex.length !== 6) {
|
|
518
|
+
console.warn(`${hex} was not 6 characters. Regenerating.`);
|
|
519
|
+
return hexColor();
|
|
520
|
+
}
|
|
521
|
+
return hex;
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
// src/server/file.ts
|
|
525
|
+
var file_exports = {};
|
|
526
|
+
__export(file_exports, {
|
|
527
|
+
readFile: () => readFile
|
|
528
|
+
});
|
|
529
|
+
var readFile = (filePath, encoding = "utf-8") => {
|
|
530
|
+
return fs__default.default.readFileSync(filePath, encoding);
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
exports.Dict = dict_exports;
|
|
534
|
+
exports.File = file_exports;
|
|
535
|
+
exports.Flow = flow_exports;
|
|
536
|
+
exports.Int = int_exports;
|
|
537
|
+
exports.List = list_exports;
|
|
538
|
+
exports.Money = money_exports;
|
|
539
|
+
exports.Random = random_exports;
|
|
540
|
+
exports.Str = str_exports;
|
|
541
|
+
exports.Time = time_exports;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { d as Dict, f as Flow, i as Int, l as List, m as Money, r as Random, s as Str, t as Time } from '../random-DMErOOdk.cjs';
|
|
2
|
+
import 'date-fns';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Read file contents as string
|
|
6
|
+
* @param filePath
|
|
7
|
+
* @param encoding
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
declare const readFile: (filePath: string, encoding?: BufferEncoding) => string;
|
|
11
|
+
|
|
12
|
+
declare const file_readFile: typeof readFile;
|
|
13
|
+
declare namespace file {
|
|
14
|
+
export { file_readFile as readFile };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { file as File };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { d as Dict, f as Flow, i as Int, l as List, m as Money, r as Random, s as Str, t as Time } from '../random-DMErOOdk.js';
|
|
2
|
+
import 'date-fns';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Read file contents as string
|
|
6
|
+
* @param filePath
|
|
7
|
+
* @param encoding
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
declare const readFile: (filePath: string, encoding?: BufferEncoding) => string;
|
|
11
|
+
|
|
12
|
+
declare const file_readFile: typeof readFile;
|
|
13
|
+
declare namespace file {
|
|
14
|
+
export { file_readFile as readFile };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { file as File };
|