@ovendjs/utils 0.21.7 → 0.22.1

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/README.md CHANGED
@@ -1 +1,107 @@
1
- # @ovenjs/utils
1
+ # @ovendjs/utils
2
+
3
+ > Utility package for OvenJS — styled and structured debug output for modern terminal logging.
4
+
5
+ ## Overview
6
+
7
+ `@ovendjs/utils` provides formatting utilities for clean, readable terminal output. It enables consistent debug messaging across OvenJS packages (and beyond), with features like:
8
+
9
+ - Colored debug banners
10
+ - Support for both string and array messages
11
+ - Grouped message formatting utilities
12
+
13
+ It's designed for internal use in the OvenJS ecosystem, but modular enough for general-purpose usage in any Node.js project.
14
+
15
+ ---
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pnpm add @ovendjs/utils
21
+ # or
22
+ npm install @ovendjs/utils
23
+ # or
24
+ yarn add @ovendjs/utils
25
+ ```
26
+
27
+ ---
28
+
29
+ ## Usage
30
+
31
+ ```ts
32
+ import { fmtDebug, fmtGroup } from '@ovendjs/utils';
33
+
34
+ const output = fmtDebug({
35
+ package: { name: 'utils', version: '0.21.7' },
36
+ string: 'Hello from utils!',
37
+ });
38
+
39
+ console.log(output);
40
+ ```
41
+
42
+ ### Array Input
43
+
44
+ ```ts
45
+ const output = fmtDebug({
46
+ package: { name: 'utils', version: '0.21.7' },
47
+ array: {
48
+ input: ['Log message 1', 'Log message 2'],
49
+ formatted: 'exclusive',
50
+ },
51
+ });
52
+
53
+ console.log(output);
54
+ ```
55
+
56
+ ### Group Utility
57
+
58
+ ```ts
59
+ const group = fmtGroup([]);
60
+
61
+ group.add('Task A completed');
62
+ group.add('Task B failed');
63
+
64
+ console.log(group.fmt());
65
+ // or
66
+ console.log(group.fmtArray());
67
+ ```
68
+
69
+ ---
70
+
71
+ ## API
72
+
73
+ ### `fmt(meta: FmtPackage): { debug(input): string }`
74
+
75
+ Utility method for making it easier to repeat fmtDebug.
76
+
77
+ ### `fmtDebug(options: FmtDebugOptions): string | Error`
78
+
79
+ Formats a debug message with color-coded output. Accepts either a `string` or `array` input.
80
+
81
+ #### Options:
82
+
83
+ - `package.name` – name of the calling package
84
+ - `package.version` – version of the calling package
85
+ - `string` – plain string to format
86
+ - `array.input` – list of lines to format
87
+ - `array.formatted` – `"exclusive"` (default) or `"unique"`
88
+
89
+ ---
90
+
91
+ ### `fmtGroup(group: string[])`
92
+
93
+ Creates a utility object to manage and format a collection of messages.
94
+
95
+ #### Returns:
96
+
97
+ - `_.add(string)` – adds an item to the group
98
+ - `_.fmt()` – returns a newline-separated string
99
+ - `_.fmtArray()` – returns the array as-is
100
+
101
+ ---
102
+
103
+ ## License
104
+
105
+ ISC — [OvenJS](https://github.com/ovenjs/Oven)
106
+
107
+ ---
package/dist/index.cjs CHANGED
@@ -21,8 +21,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  // src/index.ts
22
22
  var index_exports = {};
23
23
  __export(index_exports, {
24
+ fmt: () => fmt,
24
25
  fmtDebug: () => fmtDebug,
25
- fmtGroup: () => fmtGroup
26
+ fmtGroup: () => fmtGroup,
27
+ isString: () => isString,
28
+ version: () => version
26
29
  });
27
30
  module.exports = __toCommonJS(index_exports);
28
31
 
@@ -96,9 +99,32 @@ function fmtGroup(group) {
96
99
  };
97
100
  }
98
101
  __name(fmtGroup, "fmtGroup");
102
+
103
+ // src/shared/util.ts
104
+ function fmt(meta) {
105
+ return {
106
+ debug: /* @__PURE__ */ __name((input) => {
107
+ return fmtDebug({
108
+ package: meta,
109
+ [isString(input) ? "string" : "array"]: input
110
+ });
111
+ }, "debug")
112
+ };
113
+ }
114
+ __name(fmt, "fmt");
115
+ function isString(type) {
116
+ return typeof type === "string";
117
+ }
118
+ __name(isString, "isString");
119
+
120
+ // src/index.ts
121
+ var version = "0.22.1";
99
122
  // Annotate the CommonJS export names for ESM import in node:
100
123
  0 && (module.exports = {
124
+ fmt,
101
125
  fmtDebug,
102
- fmtGroup
126
+ fmtGroup,
127
+ isString,
128
+ version
103
129
  });
104
130
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/shared/fmt.ts"],"sourcesContent":["export * from './shared/types';\nexport { fmtDebug, fmtGroup } from './shared/fmt';\n","import { FmtDebugOptions } from './types';\n\nexport const fmtColors = {\n RED: '\\x1b[31m',\n GREEN: '\\x1b[32m',\n YELLOW: '\\x1b[33m',\n BLUE: '\\x1b[34m',\n NC: '\\x1b[0m',\n};\n\nexport function fmtDebug(options: FmtDebugOptions): string | Error {\n if (options.string) {\n const prepre_point = ` _`.repeat(10);\n const pre_point = `\\n|\\n`;\n\n const starting_point = `| ${fmtColors.GREEN}@ovenjs${fmtColors.NC}/${fmtColors.RED}${options.package.name}${fmtColors.NC} ~ v${fmtColors.YELLOW}${options.package.version}${fmtColors.NC} \\n|`;\n\n let middle_point = `[${options.package.name.toUpperCase()}]: ${options.string}\\n|`;\n\n if (options.string.includes('\\n')) {\n const lines = options.string.split('\\n');\n middle_point = ``;\n for (let i = 0; i < lines.length; i++) {\n middle_point += `[${options.package.name.toUpperCase()}]: ${lines[i]}\\n|`;\n }\n }\n\n const ending_point = ` _`.repeat(10).trimStart();\n\n const combined =\n prepre_point + pre_point + starting_point + middle_point + ending_point;\n const combined_lines = combined.split('\\n');\n const combined_nl = combined_lines.map(line => `- ${line}`);\n const combined_clean = combined_nl.join('\\n');\n return combined_clean;\n }\n\n if (options.array) {\n options.array.formatted ??= \"exclusive\";\n \n const top = \" _\".repeat(10);\n const empty_space = \"\\n|\\n\"\n const starting_point = `| ${fmtColors.GREEN}@ovenjs${fmtColors.NC}/${fmtColors.RED}${options.package.name}${fmtColors.NC} ~ v${fmtColors.YELLOW}${options.package.version}${fmtColors.NC}\\n`;\n let lines = \"\";\n if (options.array.formatted === \"exclusive\")\n lines = `| [${options.package.name.toUpperCase()}]:\\n`\n\n for (let i = 0; i < options.array.input.length; i++) {\n if (options.array.formatted === \"exclusive\") {\n lines += `| [${i}]: ${options.array.input[i]}\\n`;\n } else {\n lines += `| [${options.package.name.toUpperCase()}]: ${options.array.input[i]}\\n`\n }\n }\n\n const bottom = \" _\".repeat(10)\n const combined_all = top + empty_space + starting_point + lines + bottom;\n const combined_clean = combined_all\n .split(\"\\n\")\n .map(line => `- ${line}`)\n .join(\"\\n\")\n\n const combined = combined_clean\n return combined;\n }\n\n throw new Error(\"Unknown Input. Must be either a String or an Array\");\n}\n\nexport function fmtGroup(group: Array<string>) {\n return {\n _: group.length,\n add: (text: string) => group.push(text),\n fmt: () => group.join('\\n'),\n fmtArray: () => group\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,YAAY;AAAA,EACvB,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,IAAI;AACN;AAEO,SAAS,SAAS,SAA0C;AACjE,MAAI,QAAQ,QAAQ;AAClB,UAAM,eAAe,KAAK,OAAO,EAAE;AACnC,UAAM,YAAY;AAAA;AAAA;AAElB,UAAM,iBAAiB,KAAK,UAAU,KAAK,UAAU,UAAU,EAAE,IAAI,UAAU,GAAG,GAAG,QAAQ,QAAQ,IAAI,GAAG,UAAU,EAAE,OAAO,UAAU,MAAM,GAAG,QAAQ,QAAQ,OAAO,GAAG,UAAU,EAAE;AAAA;AAExL,QAAI,eAAe,IAAI,QAAQ,QAAQ,KAAK,YAAY,CAAC,MAAM,QAAQ,MAAM;AAAA;AAE7E,QAAI,QAAQ,OAAO,SAAS,IAAI,GAAG;AACjC,YAAM,QAAQ,QAAQ,OAAO,MAAM,IAAI;AACvC,qBAAe;AACf,eAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,wBAAgB,IAAI,QAAQ,QAAQ,KAAK,YAAY,CAAC,MAAM,MAAM,CAAC,CAAC;AAAA;AAAA,MACtE;AAAA,IACF;AAEA,UAAM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S,OAAsB;AAC7C,SAAO;AAAA,IACL,GAAG,MAAM;AAAA,IACT,KAAK,wBAAC,SAAiB,MAAM,KAAK,IAAI,GAAjC;AAAA,IACL,KAAK,6BAAM,MAAM,KAAK,IAAI,GAArB;AAAA,IACL,UAAU,6BAAM,OAAN;AAAA,EACZ;AACF;AAPgB;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/shared/fmt.ts","../src/shared/util.ts"],"sourcesContent":["export * from './shared/types';\nexport { fmtDebug, fmtGroup } from './shared/fmt';\nexport { isString, fmt } from './shared/util';\n\n/**\n * The current version that you are currently using.\n *\n * Note to developers: This needs to explicitly be `string` so it is not typed as a \"const string\" that gets injected by esbuild\n */\nexport const version: string = '0.22.1';\n","import { FmtDebugOptions } from './types';\n\nexport const fmtColors = {\n RED: '\\x1b[31m',\n GREEN: '\\x1b[32m',\n YELLOW: '\\x1b[33m',\n BLUE: '\\x1b[34m',\n NC: '\\x1b[0m',\n};\n\nexport function fmtDebug(options: FmtDebugOptions): string | Error {\n if (options.string) {\n const prepre_point = ` _`.repeat(10);\n const pre_point = `\\n|\\n`;\n\n const starting_point = `| ${fmtColors.GREEN}@ovenjs${fmtColors.NC}/${fmtColors.RED}${options.package.name}${fmtColors.NC} ~ v${fmtColors.YELLOW}${options.package.version}${fmtColors.NC} \\n|`;\n\n let middle_point = `[${options.package.name.toUpperCase()}]: ${options.string}\\n|`;\n\n if (options.string.includes('\\n')) {\n const lines = options.string.split('\\n');\n middle_point = ``;\n for (let i = 0; i < lines.length; i++) {\n middle_point += `[${options.package.name.toUpperCase()}]: ${lines[i]}\\n|`;\n }\n }\n\n const ending_point = ` _`.repeat(10).trimStart();\n\n const combined =\n prepre_point + pre_point + starting_point + middle_point + ending_point;\n const combined_lines = combined.split('\\n');\n const combined_nl = combined_lines.map(line => `- ${line}`);\n const combined_clean = combined_nl.join('\\n');\n return combined_clean;\n }\n\n if (options.array) {\n options.array.formatted ??= 'exclusive';\n\n const top = ' _'.repeat(10);\n const empty_space = '\\n|\\n';\n const starting_point = `| ${fmtColors.GREEN}@ovenjs${fmtColors.NC}/${fmtColors.RED}${options.package.name}${fmtColors.NC} ~ v${fmtColors.YELLOW}${options.package.version}${fmtColors.NC}\\n`;\n let lines = '';\n if (options.array.formatted === 'exclusive')\n lines = `| [${options.package.name.toUpperCase()}]:\\n`;\n\n for (let i = 0; i < options.array.input.length; i++) {\n if (options.array.formatted === 'exclusive') {\n lines += `| [${i}]: ${options.array.input[i]}\\n`;\n } else {\n lines += `| [${options.package.name.toUpperCase()}]: ${options.array.input[i]}\\n`;\n }\n }\n\n const bottom = ' _'.repeat(10);\n const combined_all = top + empty_space + starting_point + lines + bottom;\n const combined_clean = combined_all\n .split('\\n')\n .map(line => `- ${line}`)\n .join('\\n');\n\n const combined = combined_clean;\n return combined;\n }\n\n throw new Error('Unknown Input. Must be either a String or an Array');\n}\n\nexport function fmtGroup(group: Array<string>) {\n return {\n _: group.length,\n add: (text: string) => group.push(text),\n fmt: () => group.join('\\n'),\n fmtArray: () => group,\n };\n}\n","import { fmtDebug } from './fmt';\nimport { FmtDebugArray, FmtPackage } from './types';\n\nexport function fmt(meta: FmtPackage) {\n return {\n debug: (input: FmtDebugArray | string) => {\n return fmtDebug({\n package: meta,\n [isString(input) ? 'string' : 'array']: input,\n });\n },\n };\n}\n\nexport function isString(type: any) {\n return typeof type === 'string';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,YAAY;AAAA,EACvB,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,IAAI;AACN;AAEO,SAAS,SAAS,SAA0C;AACjE,MAAI,QAAQ,QAAQ;AAClB,UAAM,eAAe,KAAK,OAAO,EAAE;AACnC,UAAM,YAAY;AAAA;AAAA;AAElB,UAAM,iBAAiB,KAAK,UAAU,KAAK,UAAU,UAAU,EAAE,IA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iBAAS,YAAY,CAAC,MAAM,QAAQ,MAAM,MAAM,CAAC,CAAC;AAAA;AAAA,MACpD,OAAO;AACL,iBAAS,MAAM,QAAQ,QAAQ,KAAK,YAAY,CAAC,MAAM,QAAQ,MAAM,MAAM,CAAC,CAAC;AAAA;AAAA,MAC/E;AAAA,IACF;AAEA,UAAM,SAAS,KAAK,OAAO,EAAE;AAC7B,UAAM,eAAe,MAAM,cAAc,iBAAiB,QAAQ;AAClE,UAAM,iBAAiB,aACpB,MAAM,IAAI,EACV,IAAI,UAAQ,KAAK,IAAI,EAAE,EACvB,KAAK,IAAI;AAEZ,UAAM,WAAW;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,IAAI,MAAM,oDAAoD;AACtE;AAzDgB;AA2DT,SAAS,SAAS,OAAsB;AAC7C,SAAO;AAAA,IACL,GAAG,MAAM;AAAA,IACT,KAAK,wBAAC,SAAiB,MAAM,KAAK,IAAI,GAAjC;AAAA,IACL,KAAK,6BAAM,MAAM,KAAK,IAAI,GAArB;AAAA,IACL,UAAU,6BAAM,OAAN;AAAA,EACZ;AACF;AAPgB;;;AClET,SAAS,IAAI,MAAkB;AACpC,SAAO;AAAA,IACL,OAAO,wBAAC,UAAkC;AACxC,aAAO,SAAS;AAAA,QACd,SAAS;AAAA,QACT,CAAC,SAAS,KAAK,IAAI,WAAW,OAAO,GAAG;AAAA,MAC1C,CAAC;AAAA,IACH,GALO;AAAA,EAMT;AACF;AATgB;AAWT,SAAS,SAAS,MAAW;AAClC,SAAO,OAAO,SAAS;AACzB;AAFgB;;;AFLT,IAAM,UAAkB;","names":[]}
package/dist/index.d.cts CHANGED
@@ -20,4 +20,16 @@ declare function fmtGroup(group: Array<string>): {
20
20
  fmtArray: () => string[];
21
21
  };
22
22
 
23
- export { type FmtDebugArray, type FmtDebugOptions, type FmtPackage, fmtDebug, fmtGroup };
23
+ declare function fmt(meta: FmtPackage): {
24
+ debug: (input: FmtDebugArray | string) => string | Error;
25
+ };
26
+ declare function isString(type: any): type is string;
27
+
28
+ /**
29
+ * The current version that you are currently using.
30
+ *
31
+ * Note to developers: This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild
32
+ */
33
+ declare const version: string;
34
+
35
+ export { type FmtDebugArray, type FmtDebugOptions, type FmtPackage, fmt, fmtDebug, fmtGroup, isString, version };
package/dist/index.d.ts CHANGED
@@ -20,4 +20,16 @@ declare function fmtGroup(group: Array<string>): {
20
20
  fmtArray: () => string[];
21
21
  };
22
22
 
23
- export { type FmtDebugArray, type FmtDebugOptions, type FmtPackage, fmtDebug, fmtGroup };
23
+ declare function fmt(meta: FmtPackage): {
24
+ debug: (input: FmtDebugArray | string) => string | Error;
25
+ };
26
+ declare function isString(type: any): type is string;
27
+
28
+ /**
29
+ * The current version that you are currently using.
30
+ *
31
+ * Note to developers: This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild
32
+ */
33
+ declare const version: string;
34
+
35
+ export { type FmtDebugArray, type FmtDebugOptions, type FmtPackage, fmt, fmtDebug, fmtGroup, isString, version };
package/dist/index.js CHANGED
@@ -71,8 +71,31 @@ function fmtGroup(group) {
71
71
  };
72
72
  }
73
73
  __name(fmtGroup, "fmtGroup");
74
+
75
+ // src/shared/util.ts
76
+ function fmt(meta) {
77
+ return {
78
+ debug: /* @__PURE__ */ __name((input) => {
79
+ return fmtDebug({
80
+ package: meta,
81
+ [isString(input) ? "string" : "array"]: input
82
+ });
83
+ }, "debug")
84
+ };
85
+ }
86
+ __name(fmt, "fmt");
87
+ function isString(type) {
88
+ return typeof type === "string";
89
+ }
90
+ __name(isString, "isString");
91
+
92
+ // src/index.ts
93
+ var version = "0.22.1";
74
94
  export {
95
+ fmt,
75
96
  fmtDebug,
76
- fmtGroup
97
+ fmtGroup,
98
+ isString,
99
+ version
77
100
  };
78
101
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/shared/fmt.ts"],"sourcesContent":["import { FmtDebugOptions } from './types';\n\nexport const fmtColors = {\n RED: '\\x1b[31m',\n GREEN: '\\x1b[32m',\n YELLOW: '\\x1b[33m',\n BLUE: '\\x1b[34m',\n NC: '\\x1b[0m',\n};\n\nexport function fmtDebug(options: FmtDebugOptions): string | Error {\n if (options.string) {\n const prepre_point = ` _`.repeat(10);\n const pre_point = `\\n|\\n`;\n\n const starting_point = `| ${fmtColors.GREEN}@ovenjs${fmtColors.NC}/${fmtColors.RED}${options.package.name}${fmtColors.NC} ~ v${fmtColors.YELLOW}${options.package.version}${fmtColors.NC} \\n|`;\n\n let middle_point = `[${options.package.name.toUpperCase()}]: ${options.string}\\n|`;\n\n if (options.string.includes('\\n')) {\n const lines = options.string.split('\\n');\n middle_point = ``;\n for (let i = 0; i < lines.length; i++) {\n middle_point += `[${options.package.name.toUpperCase()}]: ${lines[i]}\\n|`;\n }\n }\n\n const ending_point = ` _`.repeat(10).trimStart();\n\n const combined =\n prepre_point + pre_point + starting_point + middle_point + ending_point;\n const combined_lines = combined.split('\\n');\n const combined_nl = combined_lines.map(line => `- ${line}`);\n const combined_clean = combined_nl.join('\\n');\n return combined_clean;\n }\n\n if (options.array) {\n options.array.formatted ??= \"exclusive\";\n \n const top = \" _\".repeat(10);\n const empty_space = \"\\n|\\n\"\n const starting_point = `| ${fmtColors.GREEN}@ovenjs${fmtColors.NC}/${fmtColors.RED}${options.package.name}${fmtColors.NC} ~ v${fmtColors.YELLOW}${options.package.version}${fmtColors.NC}\\n`;\n let lines = \"\";\n if (options.array.formatted === \"exclusive\")\n lines = `| [${options.package.name.toUpperCase()}]:\\n`\n\n for (let i = 0; i < options.array.input.length; i++) {\n if (options.array.formatted === \"exclusive\") {\n lines += `| [${i}]: ${options.array.input[i]}\\n`;\n } else {\n lines += `| [${options.package.name.toUpperCase()}]: ${options.array.input[i]}\\n`\n }\n }\n\n const bottom = \" _\".repeat(10)\n const combined_all = top + empty_space + starting_point + lines + bottom;\n const combined_clean = combined_all\n .split(\"\\n\")\n .map(line => `- ${line}`)\n .join(\"\\n\")\n\n const combined = combined_clean\n return combined;\n }\n\n throw new Error(\"Unknown Input. Must be either a String or an Array\");\n}\n\nexport function fmtGroup(group: Array<string>) {\n return {\n _: group.length,\n add: (text: string) => group.push(text),\n fmt: () => group.join('\\n'),\n fmtArray: () => group\n };\n}\n"],"mappings":";;;;AAEO,IAAM,YAAY;AAAA,EACvB,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,IAAI;AACN;AAEO,SAAS,SAAS,SAA0C;AACjE,MAAI,QAAQ,QAAQ;AAClB,UAAM,eAAe,KAAK,OAAO,EAAE;AACnC,UAAM,YAAY;AAAA;AAAA;AAElB,UAAM,iBAAiB,KAAK,UAAU,KAAK,UAAU,UAAU,EAAE,IAAI,UAAU,GAAG,GAAG,QAAQ,QAAQ,IAAI,GAAG,UAAU,EAAE,OAAO,UAAU,MAAM,GAAG,QAAQ,QAAQ,OAAO,GAAG,UAAU,EAAE;AAAA;AAExL,QAAI,eAAe,IAAI,QAAQ,QAAQ,KAAK,YAAY,CAAC,MAAM,QAAQ,MAAM;AAAA;AAE7E,QAAI,QAAQ,OAAO,SAAS,IAAI,GAAG;AACjC,YAAM,QAAQ,QAAQ,OAAO,MAAM,IAAI;AACvC,qBAAe;AACf,eAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,wBAAgB,IAAI,QAAQ,QAAQ,KAAK,YAAY,CAAC,MAAM,MAAM,CAAC,CAAC;AAAA;AAAA,MACtE;AAAA,IACF;AAEA,UAAM,eAAe,KAAK,OAAO,EAAE,EAAE,UAAU;AAE/C,UAAM,WACJ,eAAe,YAAY,iBAAiB,eAAe;AAC7D,UAAM,iBAAiB,SAAS,MAAM,IAAI;AAC1C,UAAM,cAAc,eAAe,IAAI,UAAQ,KAAK,IAAI,EAAE;AAC1D,UAAM,iBAAiB,YAAY,KAAK,IAAI;AAC5C,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ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src/index.ts"],"sourcesContent":["import { FmtDebugOptions } from './types';\n\nexport const fmtColors = {\n RED: '\\x1b[31m',\n GREEN: '\\x1b[32m',\n YELLOW: '\\x1b[33m',\n BLUE: '\\x1b[34m',\n NC: '\\x1b[0m',\n};\n\nexport function fmtDebug(options: FmtDebugOptions): string | Error {\n if (options.string) {\n const prepre_point = ` _`.repeat(10);\n const pre_point = `\\n|\\n`;\n\n const starting_point = `| ${fmtColors.GREEN}@ovenjs${fmtColors.NC}/${fmtColors.RED}${options.package.name}${fmtColors.NC} ~ v${fmtColors.YELLOW}${options.package.version}${fmtColors.NC} \\n|`;\n\n let middle_point = `[${options.package.name.toUpperCase()}]: ${options.string}\\n|`;\n\n if (options.string.includes('\\n')) {\n const lines = options.string.split('\\n');\n middle_point = ``;\n for (let i = 0; i < lines.length; i++) {\n middle_point += `[${options.package.name.toUpperCase()}]: ${lines[i]}\\n|`;\n }\n }\n\n const ending_point = ` _`.repeat(10).trimStart();\n\n const combined =\n prepre_point + pre_point + starting_point + middle_point + ending_point;\n const combined_lines = combined.split('\\n');\n const combined_nl = combined_lines.map(line => `- ${line}`);\n const combined_clean = combined_nl.join('\\n');\n return combined_clean;\n }\n\n if (options.array) {\n options.array.formatted ??= 'exclusive';\n\n const top = ' _'.repeat(10);\n const empty_space = '\\n|\\n';\n const starting_point = `| ${fmtColors.GREEN}@ovenjs${fmtColors.NC}/${fmtColors.RED}${options.package.name}${fmtColors.NC} ~ v${fmtColors.YELLOW}${options.package.version}${fmtColors.NC}\\n`;\n let lines = '';\n if (options.array.formatted === 'exclusive')\n lines = `| [${options.package.name.toUpperCase()}]:\\n`;\n\n for (let i = 0; i < options.array.input.length; i++) {\n if (options.array.formatted === 'exclusive') {\n lines += `| [${i}]: ${options.array.input[i]}\\n`;\n } else {\n lines += `| [${options.package.name.toUpperCase()}]: ${options.array.input[i]}\\n`;\n }\n }\n\n const bottom = ' _'.repeat(10);\n const combined_all = top + empty_space + starting_point + lines + bottom;\n const combined_clean = combined_all\n .split('\\n')\n .map(line => `- ${line}`)\n .join('\\n');\n\n const combined = combined_clean;\n return combined;\n }\n\n throw new Error('Unknown Input. Must be either a String or an Array');\n}\n\nexport function fmtGroup(group: Array<string>) {\n return {\n _: group.length,\n add: (text: string) => group.push(text),\n fmt: () => group.join('\\n'),\n fmtArray: () => group,\n };\n}\n","import { fmtDebug } from './fmt';\nimport { FmtDebugArray, FmtPackage } from './types';\n\nexport function fmt(meta: FmtPackage) {\n return {\n debug: (input: FmtDebugArray | string) => {\n return fmtDebug({\n package: meta,\n [isString(input) ? 'string' : 'array']: input,\n });\n },\n };\n}\n\nexport function isString(type: any) {\n return typeof type === 'string';\n}\n","export * from './shared/types';\nexport { fmtDebug, fmtGroup } from './shared/fmt';\nexport { isString, fmt } from './shared/util';\n\n/**\n * The current version that you are currently using.\n *\n * Note to developers: This needs to explicitly be `string` so it is not typed as a \"const string\" that gets injected by esbuild\n */\nexport const version: string = '0.22.1';\n"],"mappings":";;;;AAEO,IAAM,YAAY;AAAA,EACvB,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,IAAI;AACN;AAEO,SAAS,SAAS,SAA0C;AACjE,MAAI,QAAQ,QAAQ;AAClB,UAAM,eAAe,KAAK,OAAO,EAAE;AACnC,UAAM,YAAY;AAAA;AAAA;AAElB,UAAM,iBAAiB,KAAK,UAAU,KAAK,UAAU,UAAU,EAAE,IAAI,UAAU,GAAG,GAAG,QAAQ,QAAQ,IAAI,GAAG,UAAU,EAAE,OAAO,UAAU,MAAM,GAAG,QAAQ,QAAQ,OAAO,GAAG,UAAU,EAAE;AAAA;AAExL,QAAI,eAAe,IAAI,QAAQ,QAAQ,KAAK,YAAY,CAAC,MAAM,QAAQ,MAAM;AAAA;AAE7E,QAAI,QAAQ,OAAO,SAAS,IAAI,GAAG;AACjC,YAAM,QAAQ,QAAQ,OAAO,MAAM,IAAI;AACvC,qBAAe;AACf,eAAS,IAAI,GAAG,IA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KAAK,IAAI,EAAE,EACvB,KAAK,IAAI;AAEZ,UAAM,WAAW;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,IAAI,MAAM,oDAAoD;AACtE;AAzDgB;AA2DT,SAAS,SAAS,OAAsB;AAC7C,SAAO;AAAA,IACL,GAAG,MAAM;AAAA,IACT,KAAK,wBAAC,SAAiB,MAAM,KAAK,IAAI,GAAjC;AAAA,IACL,KAAK,6BAAM,MAAM,KAAK,IAAI,GAArB;AAAA,IACL,UAAU,6BAAM,OAAN;AAAA,EACZ;AACF;AAPgB;;;AClET,SAAS,IAAI,MAAkB;AACpC,SAAO;AAAA,IACL,OAAO,wBAAC,UAAkC;AACxC,aAAO,SAAS;AAAA,QACd,SAAS;AAAA,QACT,CAAC,SAAS,KAAK,IAAI,WAAW,OAAO,GAAG;AAAA,MAC1C,CAAC;AAAA,IACH,GALO;AAAA,EAMT;AACF;AATgB;AAWT,SAAS,SAAS,MAAW;AAClC,SAAO,OAAO,SAAS;AACzB;AAFgB;;;ACLT,IAAM,UAAkB;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovendjs/utils",
3
- "version": "0.21.7",
3
+ "version": "0.22.1",
4
4
  "description": "Utiliy package for ovenjs",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -30,6 +30,9 @@
30
30
  ],
31
31
  "author": "OvenJS",
32
32
  "license": "ISC",
33
+ "devDependencies": {
34
+ "esbuild-plugin-version-injector": "^1.2.1"
35
+ },
33
36
  "scripts": {
34
37
  "build": "tsc --noEmit && tsup",
35
38
  "dev": "tsup --watch",