@akanjs/common 0.0.46 → 0.0.47

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/index.js CHANGED
@@ -1,13 +1,7 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
5
  var __copyProps = (to, from, except, desc) => {
12
6
  if (from && typeof from === "object" || typeof from === "function") {
13
7
  for (let key of __getOwnPropNames(from))
@@ -16,348 +10,8 @@ var __copyProps = (to, from, except, desc) => {
16
10
  }
17
11
  return to;
18
12
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
27
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // pkgs/@akanjs/common/index.ts
30
15
  var common_exports = {};
31
- __export(common_exports, {
32
- Logger: () => Logger,
33
- applyMixins: () => applyMixins,
34
- capitalize: () => capitalize,
35
- deepObjectify: () => deepObjectify,
36
- isDayjs: () => import_dayjs.isDayjs,
37
- isQueryEqual: () => isQueryEqual,
38
- isValidDate: () => isValidDate,
39
- lowerlize: () => lowerlize,
40
- mergeVersion: () => mergeVersion,
41
- objectify: () => objectify,
42
- pathGet: () => pathGet,
43
- pathSet: () => pathSet,
44
- pluralize: () => import_pluralize.default,
45
- randomPick: () => randomPick,
46
- randomPicks: () => randomPicks,
47
- sleep: () => sleep,
48
- splitVersion: () => splitVersion
49
- });
50
16
  module.exports = __toCommonJS(common_exports);
51
-
52
- // pkgs/@akanjs/common/src/splitVersion.ts
53
- var splitVersion = (version) => {
54
- const [major, minor, patch] = version.split(".");
55
- return { major, minor, patch };
56
- };
57
-
58
- // pkgs/@akanjs/common/src/isDayjs.ts
59
- var import_dayjs = require("dayjs");
60
-
61
- // pkgs/@akanjs/common/src/deepObjectify.ts
62
- var deepObjectify = (obj, option = {}) => {
63
- if ((0, import_dayjs.isDayjs)(obj) || obj?.constructor === Date) {
64
- if (!option.serializable && !option.convertDate)
65
- return obj;
66
- if (option.convertDate === "string")
67
- return obj.toISOString();
68
- else if (option.convertDate === "number")
69
- return (0, import_dayjs.isDayjs)(obj) ? obj.toDate().getTime() : obj.getTime();
70
- else
71
- return (0, import_dayjs.isDayjs)(obj) ? obj.toDate() : obj;
72
- } else if (Array.isArray(obj)) {
73
- return obj.map((o) => deepObjectify(o, option));
74
- } else if (obj && typeof obj === "object") {
75
- const val = {};
76
- Object.keys(obj).forEach((key) => {
77
- const fieldValue = obj[key];
78
- if (fieldValue?.__ModelType__ && !option.serializable)
79
- val[key] = fieldValue;
80
- else if (typeof obj[key] !== "function")
81
- val[key] = deepObjectify(fieldValue, option);
82
- });
83
- return val;
84
- } else {
85
- return obj;
86
- }
87
- };
88
-
89
- // pkgs/@akanjs/common/src/pathGet.ts
90
- var pathGet = (path, obj, separator = ".") => {
91
- const properties = Array.isArray(path) ? path : path.split(separator);
92
- return properties.reduce((prev, curr) => prev[curr], obj);
93
- };
94
-
95
- // pkgs/@akanjs/common/src/isQueryEqual.ts
96
- var import_dayjs2 = __toESM(require("dayjs"));
97
- var isQueryEqual = (value1, value2) => {
98
- if (value1 === value2)
99
- return true;
100
- if (Array.isArray(value1) && Array.isArray(value2)) {
101
- if (value1.length !== value2.length)
102
- return false;
103
- for (let i = 0; i < value1.length; i++)
104
- if (!isQueryEqual(value1[i], value2[i]))
105
- return false;
106
- return true;
107
- }
108
- if ([value1, value2].some((val) => val instanceof Date || (0, import_dayjs.isDayjs)(val)))
109
- return (0, import_dayjs2.default)(value1).isSame((0, import_dayjs2.default)(value2));
110
- if (typeof value1 === "object" && typeof value2 === "object") {
111
- if (value1 === null || value2 === null)
112
- return value1 === value2;
113
- if (Object.keys(value1).length !== Object.keys(value2).length)
114
- return false;
115
- for (const key of Object.keys(value1))
116
- if (!isQueryEqual(value1[key], value2[key]))
117
- return false;
118
- return true;
119
- }
120
- return false;
121
- };
122
-
123
- // pkgs/@akanjs/common/src/isValidDate.ts
124
- var import_dayjs3 = __toESM(require("dayjs"));
125
- var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
126
- import_dayjs3.default.extend(import_customParseFormat.default);
127
- var isValidDate = (d) => {
128
- const format = "YYYY-MM-DD";
129
- if (typeof d === "string") {
130
- return (0, import_dayjs3.default)(d, format).isValid();
131
- } else if ((0, import_dayjs.isDayjs)(d))
132
- return d.isValid();
133
- else
134
- return d instanceof Date && !isNaN(d.getTime());
135
- };
136
-
137
- // pkgs/@akanjs/common/src/objectify.ts
138
- var objectify = (obj, keys = Object.keys(obj)) => {
139
- const val = {};
140
- keys.forEach((key) => {
141
- if (typeof obj[key] !== "function")
142
- val[key] = obj[key];
143
- });
144
- return val;
145
- };
146
-
147
- // pkgs/@akanjs/common/src/randomPick.ts
148
- var randomPick = (arr) => arr[Math.floor(Math.random() * arr.length)];
149
-
150
- // pkgs/@akanjs/common/src/randomPicks.ts
151
- var randomPicks = (arr, count = 1, allowDuplicate = false) => {
152
- if (!allowDuplicate && arr.length <= count)
153
- return arr;
154
- const idxs = [];
155
- let pickIdx;
156
- for (let i = 0; i < count; i++) {
157
- do {
158
- pickIdx = Math.floor(Math.random() * arr.length);
159
- } while (!allowDuplicate && idxs.includes(pickIdx));
160
- idxs.push(pickIdx);
161
- }
162
- return idxs.map((idx) => arr[idx]);
163
- };
164
-
165
- // pkgs/@akanjs/common/src/pathSet.ts
166
- var pathSet = (obj, path, value) => {
167
- if (Object(obj) !== obj)
168
- return obj;
169
- if (!Array.isArray(path))
170
- path = path.toString().match(/[^.[\]]+/g) || [];
171
- path.slice(0, -1).reduce(
172
- (a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {},
173
- obj
174
- )[path[path.length - 1]] = value;
175
- return obj;
176
- };
177
-
178
- // pkgs/@akanjs/common/src/mergeVersion.ts
179
- var mergeVersion = (major, minor, patch) => `${major}.${minor}.${patch}`;
180
-
181
- // pkgs/@akanjs/common/src/pluralize.ts
182
- var import_pluralize = __toESM(require("pluralize"));
183
-
184
- // pkgs/@akanjs/common/src/applyMixins.ts
185
- var getAllPropertyDescriptors = (objRef) => {
186
- const descriptors = {};
187
- let current = objRef.prototype;
188
- while (current) {
189
- Object.getOwnPropertyNames(current).forEach((name) => {
190
- descriptors[name] ??= Object.getOwnPropertyDescriptor(current, name);
191
- });
192
- current = Object.getPrototypeOf(current);
193
- }
194
- return descriptors;
195
- };
196
- var applyMixins = (derivedCtor, constructors, avoidKeys) => {
197
- constructors.forEach((baseCtor) => {
198
- Object.entries(getAllPropertyDescriptors(baseCtor)).forEach(([name, descriptor]) => {
199
- if (name === "constructor" || avoidKeys?.has(name))
200
- return;
201
- Object.defineProperty(derivedCtor.prototype, name, { ...descriptor, configurable: true });
202
- });
203
- });
204
- };
205
-
206
- // pkgs/@akanjs/common/src/capitalize.ts
207
- var capitalize = (str) => {
208
- return str.charAt(0).toUpperCase() + str.slice(1);
209
- };
210
-
211
- // pkgs/@akanjs/common/src/Logger.ts
212
- var import_dayjs4 = __toESM(require("dayjs"));
213
- var logLevels = ["trace", "verbose", "debug", "log", "info", "warn", "error"];
214
- var clc = {
215
- bold: (text) => `\x1B[1m${text}\x1B[0m`,
216
- green: (text) => `\x1B[32m${text}\x1B[39m`,
217
- yellow: (text) => `\x1B[33m${text}\x1B[39m`,
218
- red: (text) => `\x1B[31m${text}\x1B[39m`,
219
- magentaBright: (text) => `\x1B[95m${text}\x1B[39m`,
220
- cyanBright: (text) => `\x1B[96m${text}\x1B[39m`
221
- };
222
- var colorizeMap = {
223
- trace: clc.bold,
224
- verbose: clc.cyanBright,
225
- debug: clc.magentaBright,
226
- log: clc.green,
227
- info: clc.green,
228
- warn: clc.yellow,
229
- error: clc.red
230
- };
231
- var Logger = class _Logger {
232
- static #ignoreCtxSet = /* @__PURE__ */ new Set([
233
- "InstanceLoader",
234
- "RoutesResolver",
235
- "RouterExplorer",
236
- "NestFactory",
237
- "WebSocketsController",
238
- "GraphQLModule",
239
- "NestApplication"
240
- ]);
241
- static level = process.env.NEXT_PUBLIC_LOG_LEVEL ?? "log";
242
- static #levelIdx = logLevels.findIndex((l) => l === process.env.NEXT_PUBLIC_LOG_LEVEL);
243
- static #startAt = (0, import_dayjs4.default)();
244
- static setLevel(level) {
245
- this.level = level;
246
- this.#levelIdx = logLevels.findIndex((l) => l === level);
247
- }
248
- name;
249
- constructor(name) {
250
- this.name = name;
251
- }
252
- trace(msg, context = "") {
253
- if (_Logger.#levelIdx <= 0)
254
- _Logger.#printMessages(this.name ?? "App", msg, context, "trace");
255
- }
256
- verbose(msg, context = "") {
257
- if (_Logger.#levelIdx <= 1)
258
- _Logger.#printMessages(this.name ?? "App", msg, context, "verbose");
259
- }
260
- debug(msg, context = "") {
261
- if (_Logger.#levelIdx <= 2)
262
- _Logger.#printMessages(this.name ?? "App", msg, context, "debug");
263
- }
264
- log(msg, context = "") {
265
- if (_Logger.#levelIdx <= 3)
266
- _Logger.#printMessages(this.name ?? "App", msg, context, "log");
267
- }
268
- info(msg, context = "") {
269
- if (_Logger.#levelIdx <= 4)
270
- _Logger.#printMessages(this.name ?? "App", msg, context, "info");
271
- }
272
- warn(msg, context = "") {
273
- if (_Logger.#levelIdx <= 5)
274
- _Logger.#printMessages(this.name ?? "App", msg, context, "warn");
275
- }
276
- error(msg, context = "") {
277
- if (_Logger.#levelIdx <= 6)
278
- _Logger.#printMessages(this.name ?? "App", msg, context, "error");
279
- }
280
- raw(msg, method) {
281
- _Logger.rawLog(msg, method);
282
- }
283
- rawLog(msg, method) {
284
- _Logger.rawLog(msg, method);
285
- }
286
- static trace(msg, context = "") {
287
- if (_Logger.#levelIdx <= 0)
288
- _Logger.#printMessages("App", msg, context, "trace");
289
- }
290
- static verbose(msg, context = "") {
291
- if (_Logger.#levelIdx <= 1)
292
- _Logger.#printMessages("App", msg, context, "verbose");
293
- }
294
- static debug(msg, context = "") {
295
- if (_Logger.#levelIdx <= 2)
296
- _Logger.#printMessages("App", msg, context, "debug");
297
- }
298
- static log(msg, context = "") {
299
- if (_Logger.#levelIdx <= 3)
300
- _Logger.#printMessages("App", msg, context, "log");
301
- }
302
- static info(msg, context = "") {
303
- if (_Logger.#levelIdx <= 4)
304
- _Logger.#printMessages("App", msg, context, "info");
305
- }
306
- static warn(msg, context = "") {
307
- if (_Logger.#levelIdx <= 5)
308
- _Logger.#printMessages("App", msg, context, "warn");
309
- }
310
- static error(msg, context = "") {
311
- if (_Logger.#levelIdx <= 6)
312
- _Logger.#printMessages("App", msg, context, "error");
313
- }
314
- static #colorize(msg, logLevel) {
315
- return colorizeMap[logLevel](msg);
316
- }
317
- static #printMessages(name, content, context, logLevel, writeStreamType = logLevel === "error" ? "stderr" : "stdout") {
318
- if (this.#ignoreCtxSet.has(context))
319
- return;
320
- const now = (0, import_dayjs4.default)();
321
- const processMsg = this.#colorize(
322
- `[${name ?? "App"}] ${global.process?.pid ?? "window"} -`,
323
- logLevel
324
- );
325
- const timestampMsg = now.format("MM/DD/YYYY, HH:mm:ss A");
326
- const logLevelMsg = this.#colorize(logLevel.toUpperCase().padStart(7, " "), logLevel);
327
- const contextMsg = context ? clc.yellow(`[${context}] `) : "";
328
- const contentMsg = this.#colorize(content, logLevel);
329
- const timeDiffMsg = clc.yellow(`+${now.diff(_Logger.#startAt, "ms")}ms`);
330
- if (typeof window === "undefined")
331
- process[writeStreamType].write(
332
- `${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
333
- `
334
- );
335
- else
336
- console.log(`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
337
- `);
338
- }
339
- static rawLog(msg, method) {
340
- this.raw(`${msg}
341
- `, method);
342
- }
343
- static raw(msg, method) {
344
- if (typeof window === "undefined" && method !== "console" && global.process)
345
- global.process.stdout.write(msg);
346
- else
347
- console.log(msg);
348
- }
349
- };
350
-
351
- // pkgs/@akanjs/common/src/lowerlize.ts
352
- var lowerlize = (str) => {
353
- return str.charAt(0).toLowerCase() + str.slice(1);
354
- };
355
-
356
- // pkgs/@akanjs/common/src/sleep.ts
357
- var sleep = async (ms) => {
358
- return new Promise((resolve) => {
359
- setTimeout(() => {
360
- resolve(true);
361
- }, ms);
362
- });
363
- };
17
+ __reExport(common_exports, require("./src"), module.exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/common",
3
- "version": "0.0.46",
3
+ "version": "0.0.47",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/Logger.js ADDED
@@ -0,0 +1,170 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var Logger_exports = {};
29
+ __export(Logger_exports, {
30
+ Logger: () => Logger
31
+ });
32
+ module.exports = __toCommonJS(Logger_exports);
33
+ var import_dayjs = __toESM(require("dayjs"));
34
+ const logLevels = ["trace", "verbose", "debug", "log", "info", "warn", "error"];
35
+ const clc = {
36
+ bold: (text) => `\x1B[1m${text}\x1B[0m`,
37
+ green: (text) => `\x1B[32m${text}\x1B[39m`,
38
+ yellow: (text) => `\x1B[33m${text}\x1B[39m`,
39
+ red: (text) => `\x1B[31m${text}\x1B[39m`,
40
+ magentaBright: (text) => `\x1B[95m${text}\x1B[39m`,
41
+ cyanBright: (text) => `\x1B[96m${text}\x1B[39m`
42
+ };
43
+ const colorizeMap = {
44
+ trace: clc.bold,
45
+ verbose: clc.cyanBright,
46
+ debug: clc.magentaBright,
47
+ log: clc.green,
48
+ info: clc.green,
49
+ warn: clc.yellow,
50
+ error: clc.red
51
+ };
52
+ class Logger {
53
+ static #ignoreCtxSet = /* @__PURE__ */ new Set([
54
+ "InstanceLoader",
55
+ "RoutesResolver",
56
+ "RouterExplorer",
57
+ "NestFactory",
58
+ "WebSocketsController",
59
+ "GraphQLModule",
60
+ "NestApplication"
61
+ ]);
62
+ static level = process.env.NEXT_PUBLIC_LOG_LEVEL ?? "log";
63
+ static #levelIdx = logLevels.findIndex((l) => l === process.env.NEXT_PUBLIC_LOG_LEVEL);
64
+ static #startAt = (0, import_dayjs.default)();
65
+ static setLevel(level) {
66
+ this.level = level;
67
+ this.#levelIdx = logLevels.findIndex((l) => l === level);
68
+ }
69
+ name;
70
+ constructor(name) {
71
+ this.name = name;
72
+ }
73
+ trace(msg, context = "") {
74
+ if (Logger.#levelIdx <= 0)
75
+ Logger.#printMessages(this.name ?? "App", msg, context, "trace");
76
+ }
77
+ verbose(msg, context = "") {
78
+ if (Logger.#levelIdx <= 1)
79
+ Logger.#printMessages(this.name ?? "App", msg, context, "verbose");
80
+ }
81
+ debug(msg, context = "") {
82
+ if (Logger.#levelIdx <= 2)
83
+ Logger.#printMessages(this.name ?? "App", msg, context, "debug");
84
+ }
85
+ log(msg, context = "") {
86
+ if (Logger.#levelIdx <= 3)
87
+ Logger.#printMessages(this.name ?? "App", msg, context, "log");
88
+ }
89
+ info(msg, context = "") {
90
+ if (Logger.#levelIdx <= 4)
91
+ Logger.#printMessages(this.name ?? "App", msg, context, "info");
92
+ }
93
+ warn(msg, context = "") {
94
+ if (Logger.#levelIdx <= 5)
95
+ Logger.#printMessages(this.name ?? "App", msg, context, "warn");
96
+ }
97
+ error(msg, context = "") {
98
+ if (Logger.#levelIdx <= 6)
99
+ Logger.#printMessages(this.name ?? "App", msg, context, "error");
100
+ }
101
+ raw(msg, method) {
102
+ Logger.rawLog(msg, method);
103
+ }
104
+ rawLog(msg, method) {
105
+ Logger.rawLog(msg, method);
106
+ }
107
+ static trace(msg, context = "") {
108
+ if (Logger.#levelIdx <= 0)
109
+ Logger.#printMessages("App", msg, context, "trace");
110
+ }
111
+ static verbose(msg, context = "") {
112
+ if (Logger.#levelIdx <= 1)
113
+ Logger.#printMessages("App", msg, context, "verbose");
114
+ }
115
+ static debug(msg, context = "") {
116
+ if (Logger.#levelIdx <= 2)
117
+ Logger.#printMessages("App", msg, context, "debug");
118
+ }
119
+ static log(msg, context = "") {
120
+ if (Logger.#levelIdx <= 3)
121
+ Logger.#printMessages("App", msg, context, "log");
122
+ }
123
+ static info(msg, context = "") {
124
+ if (Logger.#levelIdx <= 4)
125
+ Logger.#printMessages("App", msg, context, "info");
126
+ }
127
+ static warn(msg, context = "") {
128
+ if (Logger.#levelIdx <= 5)
129
+ Logger.#printMessages("App", msg, context, "warn");
130
+ }
131
+ static error(msg, context = "") {
132
+ if (Logger.#levelIdx <= 6)
133
+ Logger.#printMessages("App", msg, context, "error");
134
+ }
135
+ static #colorize(msg, logLevel) {
136
+ return colorizeMap[logLevel](msg);
137
+ }
138
+ static #printMessages(name, content, context, logLevel, writeStreamType = logLevel === "error" ? "stderr" : "stdout") {
139
+ if (this.#ignoreCtxSet.has(context))
140
+ return;
141
+ const now = (0, import_dayjs.default)();
142
+ const processMsg = this.#colorize(
143
+ `[${name ?? "App"}] ${global.process?.pid ?? "window"} -`,
144
+ logLevel
145
+ );
146
+ const timestampMsg = now.format("MM/DD/YYYY, HH:mm:ss A");
147
+ const logLevelMsg = this.#colorize(logLevel.toUpperCase().padStart(7, " "), logLevel);
148
+ const contextMsg = context ? clc.yellow(`[${context}] `) : "";
149
+ const contentMsg = this.#colorize(content, logLevel);
150
+ const timeDiffMsg = clc.yellow(`+${now.diff(Logger.#startAt, "ms")}ms`);
151
+ if (typeof window === "undefined")
152
+ process[writeStreamType].write(
153
+ `${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
154
+ `
155
+ );
156
+ else
157
+ console.log(`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
158
+ `);
159
+ }
160
+ static rawLog(msg, method) {
161
+ this.raw(`${msg}
162
+ `, method);
163
+ }
164
+ static raw(msg, method) {
165
+ if (typeof window === "undefined" && method !== "console" && global.process)
166
+ global.process.stdout.write(msg);
167
+ else
168
+ console.log(msg);
169
+ }
170
+ }
@@ -0,0 +1,42 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var applyMixins_exports = {};
19
+ __export(applyMixins_exports, {
20
+ applyMixins: () => applyMixins
21
+ });
22
+ module.exports = __toCommonJS(applyMixins_exports);
23
+ const getAllPropertyDescriptors = (objRef) => {
24
+ const descriptors = {};
25
+ let current = objRef.prototype;
26
+ while (current) {
27
+ Object.getOwnPropertyNames(current).forEach((name) => {
28
+ descriptors[name] ??= Object.getOwnPropertyDescriptor(current, name);
29
+ });
30
+ current = Object.getPrototypeOf(current);
31
+ }
32
+ return descriptors;
33
+ };
34
+ const applyMixins = (derivedCtor, constructors, avoidKeys) => {
35
+ constructors.forEach((baseCtor) => {
36
+ Object.entries(getAllPropertyDescriptors(baseCtor)).forEach(([name, descriptor]) => {
37
+ if (name === "constructor" || avoidKeys?.has(name))
38
+ return;
39
+ Object.defineProperty(derivedCtor.prototype, name, { ...descriptor, configurable: true });
40
+ });
41
+ });
42
+ };
@@ -0,0 +1,25 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var capitalize_exports = {};
19
+ __export(capitalize_exports, {
20
+ capitalize: () => capitalize
21
+ });
22
+ module.exports = __toCommonJS(capitalize_exports);
23
+ const capitalize = (str) => {
24
+ return str.charAt(0).toUpperCase() + str.slice(1);
25
+ };
@@ -0,0 +1,49 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var deepObjectify_exports = {};
19
+ __export(deepObjectify_exports, {
20
+ deepObjectify: () => deepObjectify
21
+ });
22
+ module.exports = __toCommonJS(deepObjectify_exports);
23
+ var import_isDayjs = require("./isDayjs");
24
+ const deepObjectify = (obj, option = {}) => {
25
+ if ((0, import_isDayjs.isDayjs)(obj) || obj?.constructor === Date) {
26
+ if (!option.serializable && !option.convertDate)
27
+ return obj;
28
+ if (option.convertDate === "string")
29
+ return obj.toISOString();
30
+ else if (option.convertDate === "number")
31
+ return (0, import_isDayjs.isDayjs)(obj) ? obj.toDate().getTime() : obj.getTime();
32
+ else
33
+ return (0, import_isDayjs.isDayjs)(obj) ? obj.toDate() : obj;
34
+ } else if (Array.isArray(obj)) {
35
+ return obj.map((o) => deepObjectify(o, option));
36
+ } else if (obj && typeof obj === "object") {
37
+ const val = {};
38
+ Object.keys(obj).forEach((key) => {
39
+ const fieldValue = obj[key];
40
+ if (fieldValue?.__ModelType__ && !option.serializable)
41
+ val[key] = fieldValue;
42
+ else if (typeof obj[key] !== "function")
43
+ val[key] = deepObjectify(fieldValue, option);
44
+ });
45
+ return val;
46
+ } else {
47
+ return obj;
48
+ }
49
+ };
package/src/index.js ADDED
@@ -0,0 +1,55 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var src_exports = {};
19
+ __export(src_exports, {
20
+ Logger: () => import_Logger.Logger,
21
+ applyMixins: () => import_applyMixins.applyMixins,
22
+ capitalize: () => import_capitalize.capitalize,
23
+ deepObjectify: () => import_deepObjectify.deepObjectify,
24
+ isDayjs: () => import_isDayjs.isDayjs,
25
+ isQueryEqual: () => import_isQueryEqual.isQueryEqual,
26
+ isValidDate: () => import_isValidDate.isValidDate,
27
+ lowerlize: () => import_lowerlize.lowerlize,
28
+ mergeVersion: () => import_mergeVersion.mergeVersion,
29
+ objectify: () => import_objectify.objectify,
30
+ pathGet: () => import_pathGet.pathGet,
31
+ pathSet: () => import_pathSet.pathSet,
32
+ pluralize: () => import_pluralize.pluralize,
33
+ randomPick: () => import_randomPick.randomPick,
34
+ randomPicks: () => import_randomPicks.randomPicks,
35
+ sleep: () => import_sleep.sleep,
36
+ splitVersion: () => import_splitVersion.splitVersion
37
+ });
38
+ module.exports = __toCommonJS(src_exports);
39
+ var import_splitVersion = require("./splitVersion");
40
+ var import_deepObjectify = require("./deepObjectify");
41
+ var import_pathGet = require("./pathGet");
42
+ var import_isQueryEqual = require("./isQueryEqual");
43
+ var import_isValidDate = require("./isValidDate");
44
+ var import_objectify = require("./objectify");
45
+ var import_randomPick = require("./randomPick");
46
+ var import_randomPicks = require("./randomPicks");
47
+ var import_pathSet = require("./pathSet");
48
+ var import_isDayjs = require("./isDayjs");
49
+ var import_mergeVersion = require("./mergeVersion");
50
+ var import_pluralize = require("./pluralize");
51
+ var import_applyMixins = require("./applyMixins");
52
+ var import_capitalize = require("./capitalize");
53
+ var import_Logger = require("./Logger");
54
+ var import_lowerlize = require("./lowerlize");
55
+ var import_sleep = require("./sleep");
package/src/isDayjs.js ADDED
@@ -0,0 +1,23 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var isDayjs_exports = {};
19
+ __export(isDayjs_exports, {
20
+ isDayjs: () => import_dayjs.isDayjs
21
+ });
22
+ module.exports = __toCommonJS(isDayjs_exports);
23
+ var import_dayjs = require("dayjs");
@@ -0,0 +1,59 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var isQueryEqual_exports = {};
29
+ __export(isQueryEqual_exports, {
30
+ isQueryEqual: () => isQueryEqual
31
+ });
32
+ module.exports = __toCommonJS(isQueryEqual_exports);
33
+ var import_dayjs = __toESM(require("dayjs"));
34
+ var import_isDayjs = require("./isDayjs");
35
+ const isQueryEqual = (value1, value2) => {
36
+ if (value1 === value2)
37
+ return true;
38
+ if (Array.isArray(value1) && Array.isArray(value2)) {
39
+ if (value1.length !== value2.length)
40
+ return false;
41
+ for (let i = 0; i < value1.length; i++)
42
+ if (!isQueryEqual(value1[i], value2[i]))
43
+ return false;
44
+ return true;
45
+ }
46
+ if ([value1, value2].some((val) => val instanceof Date || (0, import_isDayjs.isDayjs)(val)))
47
+ return (0, import_dayjs.default)(value1).isSame((0, import_dayjs.default)(value2));
48
+ if (typeof value1 === "object" && typeof value2 === "object") {
49
+ if (value1 === null || value2 === null)
50
+ return value1 === value2;
51
+ if (Object.keys(value1).length !== Object.keys(value2).length)
52
+ return false;
53
+ for (const key of Object.keys(value1))
54
+ if (!isQueryEqual(value1[key], value2[key]))
55
+ return false;
56
+ return true;
57
+ }
58
+ return false;
59
+ };
@@ -0,0 +1,45 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var isValidDate_exports = {};
29
+ __export(isValidDate_exports, {
30
+ isValidDate: () => isValidDate
31
+ });
32
+ module.exports = __toCommonJS(isValidDate_exports);
33
+ var import_dayjs = __toESM(require("dayjs"));
34
+ var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
35
+ var import_isDayjs = require("./isDayjs");
36
+ import_dayjs.default.extend(import_customParseFormat.default);
37
+ const isValidDate = (d) => {
38
+ const format = "YYYY-MM-DD";
39
+ if (typeof d === "string") {
40
+ return (0, import_dayjs.default)(d, format).isValid();
41
+ } else if ((0, import_isDayjs.isDayjs)(d))
42
+ return d.isValid();
43
+ else
44
+ return d instanceof Date && !isNaN(d.getTime());
45
+ };
@@ -0,0 +1,25 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var lowerlize_exports = {};
19
+ __export(lowerlize_exports, {
20
+ lowerlize: () => lowerlize
21
+ });
22
+ module.exports = __toCommonJS(lowerlize_exports);
23
+ const lowerlize = (str) => {
24
+ return str.charAt(0).toLowerCase() + str.slice(1);
25
+ };
@@ -0,0 +1,23 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var mergeVersion_exports = {};
19
+ __export(mergeVersion_exports, {
20
+ mergeVersion: () => mergeVersion
21
+ });
22
+ module.exports = __toCommonJS(mergeVersion_exports);
23
+ const mergeVersion = (major, minor, patch) => `${major}.${minor}.${patch}`;
@@ -0,0 +1,30 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var objectify_exports = {};
19
+ __export(objectify_exports, {
20
+ objectify: () => objectify
21
+ });
22
+ module.exports = __toCommonJS(objectify_exports);
23
+ const objectify = (obj, keys = Object.keys(obj)) => {
24
+ const val = {};
25
+ keys.forEach((key) => {
26
+ if (typeof obj[key] !== "function")
27
+ val[key] = obj[key];
28
+ });
29
+ return val;
30
+ };
package/src/pathGet.js ADDED
@@ -0,0 +1,26 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var pathGet_exports = {};
19
+ __export(pathGet_exports, {
20
+ pathGet: () => pathGet
21
+ });
22
+ module.exports = __toCommonJS(pathGet_exports);
23
+ const pathGet = (path, obj, separator = ".") => {
24
+ const properties = Array.isArray(path) ? path : path.split(separator);
25
+ return properties.reduce((prev, curr) => prev[curr], obj);
26
+ };
package/src/pathSet.js ADDED
@@ -0,0 +1,33 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var pathSet_exports = {};
19
+ __export(pathSet_exports, {
20
+ pathSet: () => pathSet
21
+ });
22
+ module.exports = __toCommonJS(pathSet_exports);
23
+ const pathSet = (obj, path, value) => {
24
+ if (Object(obj) !== obj)
25
+ return obj;
26
+ if (!Array.isArray(path))
27
+ path = path.toString().match(/[^.[\]]+/g) || [];
28
+ path.slice(0, -1).reduce(
29
+ (a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {},
30
+ obj
31
+ )[path[path.length - 1]] = value;
32
+ return obj;
33
+ };
@@ -0,0 +1,33 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var pluralize_exports = {};
29
+ __export(pluralize_exports, {
30
+ pluralize: () => import_pluralize.default
31
+ });
32
+ module.exports = __toCommonJS(pluralize_exports);
33
+ var import_pluralize = __toESM(require("pluralize"));
@@ -0,0 +1,23 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var randomPick_exports = {};
19
+ __export(randomPick_exports, {
20
+ randomPick: () => randomPick
21
+ });
22
+ module.exports = __toCommonJS(randomPick_exports);
23
+ const randomPick = (arr) => arr[Math.floor(Math.random() * arr.length)];
@@ -0,0 +1,35 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var randomPicks_exports = {};
19
+ __export(randomPicks_exports, {
20
+ randomPicks: () => randomPicks
21
+ });
22
+ module.exports = __toCommonJS(randomPicks_exports);
23
+ const randomPicks = (arr, count = 1, allowDuplicate = false) => {
24
+ if (!allowDuplicate && arr.length <= count)
25
+ return arr;
26
+ const idxs = [];
27
+ let pickIdx;
28
+ for (let i = 0; i < count; i++) {
29
+ do {
30
+ pickIdx = Math.floor(Math.random() * arr.length);
31
+ } while (!allowDuplicate && idxs.includes(pickIdx));
32
+ idxs.push(pickIdx);
33
+ }
34
+ return idxs.map((idx) => arr[idx]);
35
+ };
package/src/sleep.js ADDED
@@ -0,0 +1,29 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var sleep_exports = {};
19
+ __export(sleep_exports, {
20
+ sleep: () => sleep
21
+ });
22
+ module.exports = __toCommonJS(sleep_exports);
23
+ const sleep = async (ms) => {
24
+ return new Promise((resolve) => {
25
+ setTimeout(() => {
26
+ resolve(true);
27
+ }, ms);
28
+ });
29
+ };
@@ -0,0 +1,26 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var splitVersion_exports = {};
19
+ __export(splitVersion_exports, {
20
+ splitVersion: () => splitVersion
21
+ });
22
+ module.exports = __toCommonJS(splitVersion_exports);
23
+ const splitVersion = (version) => {
24
+ const [major, minor, patch] = version.split(".");
25
+ return { major, minor, patch };
26
+ };
package/src/types.js ADDED
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var types_exports = {};
15
+ module.exports = __toCommonJS(types_exports);