@akanjs/common 0.0.54 → 0.0.56

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/Logger.js CHANGED
@@ -1,4 +1,36 @@
1
- import dayjs from "dayjs";
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"));
2
34
  const logLevels = ["trace", "verbose", "debug", "log", "info", "warn", "error"];
3
35
  const clc = {
4
36
  bold: (text) => `\x1B[1m${text}\x1B[0m`,
@@ -29,7 +61,7 @@ class Logger {
29
61
  ]);
30
62
  static level = process.env.NEXT_PUBLIC_LOG_LEVEL ?? "log";
31
63
  static #levelIdx = logLevels.findIndex((l) => l === process.env.NEXT_PUBLIC_LOG_LEVEL);
32
- static #startAt = dayjs();
64
+ static #startAt = (0, import_dayjs.default)();
33
65
  static setLevel(level) {
34
66
  this.level = level;
35
67
  this.#levelIdx = logLevels.findIndex((l) => l === level);
@@ -106,7 +138,7 @@ class Logger {
106
138
  static #printMessages(name, content, context, logLevel, writeStreamType = logLevel === "error" ? "stderr" : "stdout") {
107
139
  if (this.#ignoreCtxSet.has(context))
108
140
  return;
109
- const now = dayjs();
141
+ const now = (0, import_dayjs.default)();
110
142
  const processMsg = this.#colorize(
111
143
  `[${name ?? "App"}] ${global.process?.pid ?? "window"} -`,
112
144
  logLevel
@@ -136,6 +168,3 @@ class Logger {
136
168
  console.log(msg);
137
169
  }
138
170
  }
139
- export {
140
- Logger
141
- };
package/Logger.mjs ADDED
@@ -0,0 +1,141 @@
1
+ import dayjs from "dayjs";
2
+ const logLevels = ["trace", "verbose", "debug", "log", "info", "warn", "error"];
3
+ const clc = {
4
+ bold: (text) => `\x1B[1m${text}\x1B[0m`,
5
+ green: (text) => `\x1B[32m${text}\x1B[39m`,
6
+ yellow: (text) => `\x1B[33m${text}\x1B[39m`,
7
+ red: (text) => `\x1B[31m${text}\x1B[39m`,
8
+ magentaBright: (text) => `\x1B[95m${text}\x1B[39m`,
9
+ cyanBright: (text) => `\x1B[96m${text}\x1B[39m`
10
+ };
11
+ const colorizeMap = {
12
+ trace: clc.bold,
13
+ verbose: clc.cyanBright,
14
+ debug: clc.magentaBright,
15
+ log: clc.green,
16
+ info: clc.green,
17
+ warn: clc.yellow,
18
+ error: clc.red
19
+ };
20
+ class Logger {
21
+ static #ignoreCtxSet = /* @__PURE__ */ new Set([
22
+ "InstanceLoader",
23
+ "RoutesResolver",
24
+ "RouterExplorer",
25
+ "NestFactory",
26
+ "WebSocketsController",
27
+ "GraphQLModule",
28
+ "NestApplication"
29
+ ]);
30
+ static level = process.env.NEXT_PUBLIC_LOG_LEVEL ?? "log";
31
+ static #levelIdx = logLevels.findIndex((l) => l === process.env.NEXT_PUBLIC_LOG_LEVEL);
32
+ static #startAt = dayjs();
33
+ static setLevel(level) {
34
+ this.level = level;
35
+ this.#levelIdx = logLevels.findIndex((l) => l === level);
36
+ }
37
+ name;
38
+ constructor(name) {
39
+ this.name = name;
40
+ }
41
+ trace(msg, context = "") {
42
+ if (Logger.#levelIdx <= 0)
43
+ Logger.#printMessages(this.name ?? "App", msg, context, "trace");
44
+ }
45
+ verbose(msg, context = "") {
46
+ if (Logger.#levelIdx <= 1)
47
+ Logger.#printMessages(this.name ?? "App", msg, context, "verbose");
48
+ }
49
+ debug(msg, context = "") {
50
+ if (Logger.#levelIdx <= 2)
51
+ Logger.#printMessages(this.name ?? "App", msg, context, "debug");
52
+ }
53
+ log(msg, context = "") {
54
+ if (Logger.#levelIdx <= 3)
55
+ Logger.#printMessages(this.name ?? "App", msg, context, "log");
56
+ }
57
+ info(msg, context = "") {
58
+ if (Logger.#levelIdx <= 4)
59
+ Logger.#printMessages(this.name ?? "App", msg, context, "info");
60
+ }
61
+ warn(msg, context = "") {
62
+ if (Logger.#levelIdx <= 5)
63
+ Logger.#printMessages(this.name ?? "App", msg, context, "warn");
64
+ }
65
+ error(msg, context = "") {
66
+ if (Logger.#levelIdx <= 6)
67
+ Logger.#printMessages(this.name ?? "App", msg, context, "error");
68
+ }
69
+ raw(msg, method) {
70
+ Logger.rawLog(msg, method);
71
+ }
72
+ rawLog(msg, method) {
73
+ Logger.rawLog(msg, method);
74
+ }
75
+ static trace(msg, context = "") {
76
+ if (Logger.#levelIdx <= 0)
77
+ Logger.#printMessages("App", msg, context, "trace");
78
+ }
79
+ static verbose(msg, context = "") {
80
+ if (Logger.#levelIdx <= 1)
81
+ Logger.#printMessages("App", msg, context, "verbose");
82
+ }
83
+ static debug(msg, context = "") {
84
+ if (Logger.#levelIdx <= 2)
85
+ Logger.#printMessages("App", msg, context, "debug");
86
+ }
87
+ static log(msg, context = "") {
88
+ if (Logger.#levelIdx <= 3)
89
+ Logger.#printMessages("App", msg, context, "log");
90
+ }
91
+ static info(msg, context = "") {
92
+ if (Logger.#levelIdx <= 4)
93
+ Logger.#printMessages("App", msg, context, "info");
94
+ }
95
+ static warn(msg, context = "") {
96
+ if (Logger.#levelIdx <= 5)
97
+ Logger.#printMessages("App", msg, context, "warn");
98
+ }
99
+ static error(msg, context = "") {
100
+ if (Logger.#levelIdx <= 6)
101
+ Logger.#printMessages("App", msg, context, "error");
102
+ }
103
+ static #colorize(msg, logLevel) {
104
+ return colorizeMap[logLevel](msg);
105
+ }
106
+ static #printMessages(name, content, context, logLevel, writeStreamType = logLevel === "error" ? "stderr" : "stdout") {
107
+ if (this.#ignoreCtxSet.has(context))
108
+ return;
109
+ const now = dayjs();
110
+ const processMsg = this.#colorize(
111
+ `[${name ?? "App"}] ${global.process?.pid ?? "window"} -`,
112
+ logLevel
113
+ );
114
+ const timestampMsg = now.format("MM/DD/YYYY, HH:mm:ss A");
115
+ const logLevelMsg = this.#colorize(logLevel.toUpperCase().padStart(7, " "), logLevel);
116
+ const contextMsg = context ? clc.yellow(`[${context}] `) : "";
117
+ const contentMsg = this.#colorize(content, logLevel);
118
+ const timeDiffMsg = clc.yellow(`+${now.diff(Logger.#startAt, "ms")}ms`);
119
+ if (typeof window === "undefined")
120
+ process[writeStreamType].write(
121
+ `${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
122
+ `
123
+ );
124
+ else
125
+ console.log(`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
126
+ `);
127
+ }
128
+ static rawLog(msg, method) {
129
+ this.raw(`${msg}
130
+ `, method);
131
+ }
132
+ static raw(msg, method) {
133
+ if (typeof window === "undefined" && method !== "console" && global.process)
134
+ global.process.stdout.write(msg);
135
+ else
136
+ console.log(msg);
137
+ }
138
+ }
139
+ export {
140
+ Logger
141
+ };
package/applyMixins.js CHANGED
@@ -1,3 +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 applyMixins_exports = {};
19
+ __export(applyMixins_exports, {
20
+ applyMixins: () => applyMixins
21
+ });
22
+ module.exports = __toCommonJS(applyMixins_exports);
1
23
  const getAllPropertyDescriptors = (objRef) => {
2
24
  const descriptors = {};
3
25
  let current = objRef.prototype;
@@ -18,6 +40,3 @@ const applyMixins = (derivedCtor, constructors, avoidKeys) => {
18
40
  });
19
41
  });
20
42
  };
21
- export {
22
- applyMixins
23
- };
@@ -0,0 +1,23 @@
1
+ const getAllPropertyDescriptors = (objRef) => {
2
+ const descriptors = {};
3
+ let current = objRef.prototype;
4
+ while (current) {
5
+ Object.getOwnPropertyNames(current).forEach((name) => {
6
+ descriptors[name] ??= Object.getOwnPropertyDescriptor(current, name);
7
+ });
8
+ current = Object.getPrototypeOf(current);
9
+ }
10
+ return descriptors;
11
+ };
12
+ const applyMixins = (derivedCtor, constructors, avoidKeys) => {
13
+ constructors.forEach((baseCtor) => {
14
+ Object.entries(getAllPropertyDescriptors(baseCtor)).forEach(([name, descriptor]) => {
15
+ if (name === "constructor" || avoidKeys?.has(name))
16
+ return;
17
+ Object.defineProperty(derivedCtor.prototype, name, { ...descriptor, configurable: true });
18
+ });
19
+ });
20
+ };
21
+ export {
22
+ applyMixins
23
+ };
package/capitalize.js CHANGED
@@ -1,6 +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);
1
23
  const capitalize = (str) => {
2
24
  return str.charAt(0).toUpperCase() + str.slice(1);
3
25
  };
4
- export {
5
- capitalize
6
- };
package/capitalize.mjs ADDED
@@ -0,0 +1,6 @@
1
+ const capitalize = (str) => {
2
+ return str.charAt(0).toUpperCase() + str.slice(1);
3
+ };
4
+ export {
5
+ capitalize
6
+ };
package/deepObjectify.js CHANGED
@@ -1,14 +1,36 @@
1
- import { isDayjs } from "./isDayjs";
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");
2
24
  const deepObjectify = (obj, option = {}) => {
3
- if (isDayjs(obj) || obj?.constructor === Date) {
25
+ if ((0, import_isDayjs.isDayjs)(obj) || obj?.constructor === Date) {
4
26
  if (!option.serializable && !option.convertDate)
5
27
  return obj;
6
28
  if (option.convertDate === "string")
7
29
  return obj.toISOString();
8
30
  else if (option.convertDate === "number")
9
- return isDayjs(obj) ? obj.toDate().getTime() : obj.getTime();
31
+ return (0, import_isDayjs.isDayjs)(obj) ? obj.toDate().getTime() : obj.getTime();
10
32
  else
11
- return isDayjs(obj) ? obj.toDate() : obj;
33
+ return (0, import_isDayjs.isDayjs)(obj) ? obj.toDate() : obj;
12
34
  } else if (Array.isArray(obj)) {
13
35
  return obj.map((o) => deepObjectify(o, option));
14
36
  } else if (obj && typeof obj === "object") {
@@ -25,6 +47,3 @@ const deepObjectify = (obj, option = {}) => {
25
47
  return obj;
26
48
  }
27
49
  };
28
- export {
29
- deepObjectify
30
- };
@@ -0,0 +1,30 @@
1
+ import { isDayjs } from "./isDayjs";
2
+ const deepObjectify = (obj, option = {}) => {
3
+ if (isDayjs(obj) || obj?.constructor === Date) {
4
+ if (!option.serializable && !option.convertDate)
5
+ return obj;
6
+ if (option.convertDate === "string")
7
+ return obj.toISOString();
8
+ else if (option.convertDate === "number")
9
+ return isDayjs(obj) ? obj.toDate().getTime() : obj.getTime();
10
+ else
11
+ return isDayjs(obj) ? obj.toDate() : obj;
12
+ } else if (Array.isArray(obj)) {
13
+ return obj.map((o) => deepObjectify(o, option));
14
+ } else if (obj && typeof obj === "object") {
15
+ const val = {};
16
+ Object.keys(obj).forEach((key) => {
17
+ const fieldValue = obj[key];
18
+ if (fieldValue?.__ModelType__ && !option.serializable)
19
+ val[key] = fieldValue;
20
+ else if (typeof obj[key] !== "function")
21
+ val[key] = deepObjectify(fieldValue, option);
22
+ });
23
+ return val;
24
+ } else {
25
+ return obj;
26
+ }
27
+ };
28
+ export {
29
+ deepObjectify
30
+ };
package/index.js CHANGED
@@ -1,36 +1,55 @@
1
- import { splitVersion } from "./splitVersion";
2
- import { deepObjectify } from "./deepObjectify";
3
- import { pathGet } from "./pathGet";
4
- import { isQueryEqual } from "./isQueryEqual";
5
- import { isValidDate } from "./isValidDate";
6
- import { objectify } from "./objectify";
7
- import { randomPick } from "./randomPick";
8
- import { randomPicks } from "./randomPicks";
9
- import { pathSet } from "./pathSet";
10
- import { isDayjs } from "./isDayjs";
11
- import { mergeVersion } from "./mergeVersion";
12
- import { pluralize } from "./pluralize";
13
- import { applyMixins } from "./applyMixins";
14
- import { capitalize } from "./capitalize";
15
- import { Logger } from "./Logger";
16
- import { lowerlize } from "./lowerlize";
17
- import { sleep } from "./sleep";
18
- export {
19
- Logger,
20
- applyMixins,
21
- capitalize,
22
- deepObjectify,
23
- isDayjs,
24
- isQueryEqual,
25
- isValidDate,
26
- lowerlize,
27
- mergeVersion,
28
- objectify,
29
- pathGet,
30
- pathSet,
31
- pluralize,
32
- randomPick,
33
- randomPicks,
34
- sleep,
35
- splitVersion
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 });
36
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 common_exports = {};
19
+ __export(common_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(common_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/index.mjs ADDED
@@ -0,0 +1,36 @@
1
+ import { splitVersion } from "./splitVersion";
2
+ import { deepObjectify } from "./deepObjectify";
3
+ import { pathGet } from "./pathGet";
4
+ import { isQueryEqual } from "./isQueryEqual";
5
+ import { isValidDate } from "./isValidDate";
6
+ import { objectify } from "./objectify";
7
+ import { randomPick } from "./randomPick";
8
+ import { randomPicks } from "./randomPicks";
9
+ import { pathSet } from "./pathSet";
10
+ import { isDayjs } from "./isDayjs";
11
+ import { mergeVersion } from "./mergeVersion";
12
+ import { pluralize } from "./pluralize";
13
+ import { applyMixins } from "./applyMixins";
14
+ import { capitalize } from "./capitalize";
15
+ import { Logger } from "./Logger";
16
+ import { lowerlize } from "./lowerlize";
17
+ import { sleep } from "./sleep";
18
+ export {
19
+ Logger,
20
+ applyMixins,
21
+ capitalize,
22
+ deepObjectify,
23
+ isDayjs,
24
+ isQueryEqual,
25
+ isValidDate,
26
+ lowerlize,
27
+ mergeVersion,
28
+ objectify,
29
+ pathGet,
30
+ pathSet,
31
+ pluralize,
32
+ randomPick,
33
+ randomPicks,
34
+ sleep,
35
+ splitVersion
36
+ };
package/isDayjs.js CHANGED
@@ -1,4 +1,23 @@
1
- import { isDayjs } from "dayjs";
2
- export {
3
- isDayjs
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 });
4
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");
package/isDayjs.mjs ADDED
@@ -0,0 +1,4 @@
1
+ import { isDayjs } from "dayjs";
2
+ export {
3
+ isDayjs
4
+ };
package/isQueryEqual.js CHANGED
@@ -1,5 +1,37 @@
1
- import dayjs from "dayjs";
2
- import { isDayjs } from "./isDayjs";
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");
3
35
  const isQueryEqual = (value1, value2) => {
4
36
  if (value1 === value2)
5
37
  return true;
@@ -11,8 +43,8 @@ const isQueryEqual = (value1, value2) => {
11
43
  return false;
12
44
  return true;
13
45
  }
14
- if ([value1, value2].some((val) => val instanceof Date || isDayjs(val)))
15
- return dayjs(value1).isSame(dayjs(value2));
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));
16
48
  if (typeof value1 === "object" && typeof value2 === "object") {
17
49
  if (value1 === null || value2 === null)
18
50
  return value1 === value2;
@@ -25,6 +57,3 @@ const isQueryEqual = (value1, value2) => {
25
57
  }
26
58
  return false;
27
59
  };
28
- export {
29
- isQueryEqual
30
- };
@@ -0,0 +1,30 @@
1
+ import dayjs from "dayjs";
2
+ import { isDayjs } from "./isDayjs";
3
+ const isQueryEqual = (value1, value2) => {
4
+ if (value1 === value2)
5
+ return true;
6
+ if (Array.isArray(value1) && Array.isArray(value2)) {
7
+ if (value1.length !== value2.length)
8
+ return false;
9
+ for (let i = 0; i < value1.length; i++)
10
+ if (!isQueryEqual(value1[i], value2[i]))
11
+ return false;
12
+ return true;
13
+ }
14
+ if ([value1, value2].some((val) => val instanceof Date || isDayjs(val)))
15
+ return dayjs(value1).isSame(dayjs(value2));
16
+ if (typeof value1 === "object" && typeof value2 === "object") {
17
+ if (value1 === null || value2 === null)
18
+ return value1 === value2;
19
+ if (Object.keys(value1).length !== Object.keys(value2).length)
20
+ return false;
21
+ for (const key of Object.keys(value1))
22
+ if (!isQueryEqual(value1[key], value2[key]))
23
+ return false;
24
+ return true;
25
+ }
26
+ return false;
27
+ };
28
+ export {
29
+ isQueryEqual
30
+ };
package/isValidDate.js CHANGED
@@ -1,16 +1,45 @@
1
- import dayjs from "dayjs";
2
- import customParseFormat from "dayjs/plugin/customParseFormat";
3
- import { isDayjs } from "./isDayjs";
4
- dayjs.extend(customParseFormat);
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);
5
37
  const isValidDate = (d) => {
6
38
  const format = "YYYY-MM-DD";
7
39
  if (typeof d === "string") {
8
- return dayjs(d, format).isValid();
9
- } else if (isDayjs(d))
40
+ return (0, import_dayjs.default)(d, format).isValid();
41
+ } else if ((0, import_isDayjs.isDayjs)(d))
10
42
  return d.isValid();
11
43
  else
12
44
  return d instanceof Date && !isNaN(d.getTime());
13
45
  };
14
- export {
15
- isValidDate
16
- };
@@ -0,0 +1,16 @@
1
+ import dayjs from "dayjs";
2
+ import customParseFormat from "dayjs/plugin/customParseFormat";
3
+ import { isDayjs } from "./isDayjs";
4
+ dayjs.extend(customParseFormat);
5
+ const isValidDate = (d) => {
6
+ const format = "YYYY-MM-DD";
7
+ if (typeof d === "string") {
8
+ return dayjs(d, format).isValid();
9
+ } else if (isDayjs(d))
10
+ return d.isValid();
11
+ else
12
+ return d instanceof Date && !isNaN(d.getTime());
13
+ };
14
+ export {
15
+ isValidDate
16
+ };
package/lowerlize.js CHANGED
@@ -1,6 +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);
1
23
  const lowerlize = (str) => {
2
24
  return str.charAt(0).toLowerCase() + str.slice(1);
3
25
  };
4
- export {
5
- lowerlize
6
- };
package/lowerlize.mjs ADDED
@@ -0,0 +1,6 @@
1
+ const lowerlize = (str) => {
2
+ return str.charAt(0).toLowerCase() + str.slice(1);
3
+ };
4
+ export {
5
+ lowerlize
6
+ };
package/mergeVersion.js CHANGED
@@ -1,4 +1,23 @@
1
- const mergeVersion = (major, minor, patch) => `${major}.${minor}.${patch}`;
2
- export {
3
- mergeVersion
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;
4
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,4 @@
1
+ const mergeVersion = (major, minor, patch) => `${major}.${minor}.${patch}`;
2
+ export {
3
+ mergeVersion
4
+ };
package/objectify.js CHANGED
@@ -1,3 +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 objectify_exports = {};
19
+ __export(objectify_exports, {
20
+ objectify: () => objectify
21
+ });
22
+ module.exports = __toCommonJS(objectify_exports);
1
23
  const objectify = (obj, keys = Object.keys(obj)) => {
2
24
  const val = {};
3
25
  keys.forEach((key) => {
@@ -6,6 +28,3 @@ const objectify = (obj, keys = Object.keys(obj)) => {
6
28
  });
7
29
  return val;
8
30
  };
9
- export {
10
- objectify
11
- };
package/objectify.mjs ADDED
@@ -0,0 +1,11 @@
1
+ const objectify = (obj, keys = Object.keys(obj)) => {
2
+ const val = {};
3
+ keys.forEach((key) => {
4
+ if (typeof obj[key] !== "function")
5
+ val[key] = obj[key];
6
+ });
7
+ return val;
8
+ };
9
+ export {
10
+ objectify
11
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@akanjs/common",
3
- "version": "0.0.54",
4
- "type": "module",
3
+ "version": "0.0.56",
4
+ "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -14,5 +14,14 @@
14
14
  "engines": {
15
15
  "node": ">=22"
16
16
  },
17
- "dependencies": {}
17
+ "dependencies": {
18
+ "dayjs": "^1.11.13",
19
+ "pluralize": "^8.0.0"
20
+ },
21
+ "exports": {
22
+ ".": {
23
+ "require": "./index.js",
24
+ "import": "./index.mjs"
25
+ }
26
+ }
18
27
  }
package/pathGet.js CHANGED
@@ -1,7 +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);
1
23
  const pathGet = (path, obj, separator = ".") => {
2
24
  const properties = Array.isArray(path) ? path : path.split(separator);
3
25
  return properties.reduce((prev, curr) => prev[curr], obj);
4
26
  };
5
- export {
6
- pathGet
7
- };
package/pathGet.mjs ADDED
@@ -0,0 +1,7 @@
1
+ const pathGet = (path, obj, separator = ".") => {
2
+ const properties = Array.isArray(path) ? path : path.split(separator);
3
+ return properties.reduce((prev, curr) => prev[curr], obj);
4
+ };
5
+ export {
6
+ pathGet
7
+ };
package/pathSet.js CHANGED
@@ -1,3 +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 pathSet_exports = {};
19
+ __export(pathSet_exports, {
20
+ pathSet: () => pathSet
21
+ });
22
+ module.exports = __toCommonJS(pathSet_exports);
1
23
  const pathSet = (obj, path, value) => {
2
24
  if (Object(obj) !== obj)
3
25
  return obj;
@@ -9,6 +31,3 @@ const pathSet = (obj, path, value) => {
9
31
  )[path[path.length - 1]] = value;
10
32
  return obj;
11
33
  };
12
- export {
13
- pathSet
14
- };
package/pathSet.mjs ADDED
@@ -0,0 +1,14 @@
1
+ const pathSet = (obj, path, value) => {
2
+ if (Object(obj) !== obj)
3
+ return obj;
4
+ if (!Array.isArray(path))
5
+ path = path.toString().match(/[^.[\]]+/g) || [];
6
+ path.slice(0, -1).reduce(
7
+ (a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {},
8
+ obj
9
+ )[path[path.length - 1]] = value;
10
+ return obj;
11
+ };
12
+ export {
13
+ pathSet
14
+ };
package/pluralize.js CHANGED
@@ -1,4 +1,33 @@
1
- import pluralize from "pluralize";
2
- export {
3
- pluralize
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 });
4
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"));
package/pluralize.mjs ADDED
@@ -0,0 +1,4 @@
1
+ import pluralize from "pluralize";
2
+ export {
3
+ pluralize
4
+ };
package/randomPick.js CHANGED
@@ -1,4 +1,23 @@
1
- const randomPick = (arr) => arr[Math.floor(Math.random() * arr.length)];
2
- export {
3
- randomPick
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;
4
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)];
package/randomPick.mjs ADDED
@@ -0,0 +1,4 @@
1
+ const randomPick = (arr) => arr[Math.floor(Math.random() * arr.length)];
2
+ export {
3
+ randomPick
4
+ };
package/randomPicks.js CHANGED
@@ -1,3 +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 randomPicks_exports = {};
19
+ __export(randomPicks_exports, {
20
+ randomPicks: () => randomPicks
21
+ });
22
+ module.exports = __toCommonJS(randomPicks_exports);
1
23
  const randomPicks = (arr, count = 1, allowDuplicate = false) => {
2
24
  if (!allowDuplicate && arr.length <= count)
3
25
  return arr;
@@ -11,6 +33,3 @@ const randomPicks = (arr, count = 1, allowDuplicate = false) => {
11
33
  }
12
34
  return idxs.map((idx) => arr[idx]);
13
35
  };
14
- export {
15
- randomPicks
16
- };
@@ -0,0 +1,16 @@
1
+ const randomPicks = (arr, count = 1, allowDuplicate = false) => {
2
+ if (!allowDuplicate && arr.length <= count)
3
+ return arr;
4
+ const idxs = [];
5
+ let pickIdx;
6
+ for (let i = 0; i < count; i++) {
7
+ do {
8
+ pickIdx = Math.floor(Math.random() * arr.length);
9
+ } while (!allowDuplicate && idxs.includes(pickIdx));
10
+ idxs.push(pickIdx);
11
+ }
12
+ return idxs.map((idx) => arr[idx]);
13
+ };
14
+ export {
15
+ randomPicks
16
+ };
package/sleep.js CHANGED
@@ -1,3 +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 sleep_exports = {};
19
+ __export(sleep_exports, {
20
+ sleep: () => sleep
21
+ });
22
+ module.exports = __toCommonJS(sleep_exports);
1
23
  const sleep = async (ms) => {
2
24
  return new Promise((resolve) => {
3
25
  setTimeout(() => {
@@ -5,6 +27,3 @@ const sleep = async (ms) => {
5
27
  }, ms);
6
28
  });
7
29
  };
8
- export {
9
- sleep
10
- };
package/sleep.mjs ADDED
@@ -0,0 +1,10 @@
1
+ const sleep = async (ms) => {
2
+ return new Promise((resolve) => {
3
+ setTimeout(() => {
4
+ resolve(true);
5
+ }, ms);
6
+ });
7
+ };
8
+ export {
9
+ sleep
10
+ };
package/splitVersion.js CHANGED
@@ -1,7 +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);
1
23
  const splitVersion = (version) => {
2
24
  const [major, minor, patch] = version.split(".");
3
25
  return { major, minor, patch };
4
26
  };
5
- export {
6
- splitVersion
7
- };
@@ -0,0 +1,7 @@
1
+ const splitVersion = (version) => {
2
+ const [major, minor, patch] = version.split(".");
3
+ return { major, minor, patch };
4
+ };
5
+ export {
6
+ splitVersion
7
+ };
package/types.js CHANGED
@@ -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);
package/types.mjs ADDED
File without changes