@alextheman/utility 5.10.1 → 5.11.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.
@@ -171,213 +171,6 @@ var DataError = class DataError extends Error {
171
171
  }
172
172
  };
173
173
  //#endregion
174
- //#region src/root/constants/FILE_PATH_REGEX.ts
175
- const FILE_PATH_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]+)`;
176
- RegExp(`^${FILE_PATH_PATTERN}$`);
177
- new RegExp(`^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$`);
178
- //#endregion
179
- //#region src/root/constants/VERSION_NUMBER_REGEX.ts
180
- const VERSION_NUMBER_PATTERN = String.raw`^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$`;
181
- const VERSION_NUMBER_REGEX = RegExp(`^${VERSION_NUMBER_PATTERN}$`);
182
- //#endregion
183
- //#region src/root/types/VersionNumber.ts
184
- /**
185
- * Represents a software version number, considered to be made up of a major, minor, and patch part.
186
- *
187
- * @category Types
188
- */
189
- var VersionNumber = class VersionNumber {
190
- static NON_NEGATIVE_TUPLE_ERROR = "Input array must be a tuple of three non-negative integers.";
191
- /** The major number. Increments when a feature is removed or changed in a way that is not backwards-compatible with the previous release. */
192
- major = 0;
193
- /** The minor number. Increments when a new feature is added/deprecated and is expected to be backwards-compatible with the previous release. */
194
- minor = 0;
195
- /** The patch number. Increments when the next release is fixing a bug or doing a small refactor that should not be noticeable in practice. */
196
- patch = 0;
197
- /**
198
- * @param input - The input to create a new instance of `VersionNumber` from.
199
- */
200
- constructor(input) {
201
- if (input instanceof VersionNumber) {
202
- this.major = input.major;
203
- this.minor = input.minor;
204
- this.patch = input.patch;
205
- } else if (typeof input === "string") {
206
- if (!VERSION_NUMBER_REGEX.test(input)) throw new DataError({ input }, "INVALID_VERSION", `"${input}" is not a valid version number. Version numbers must be of the format "X.Y.Z" or "vX.Y.Z", where X, Y, and Z are non-negative integers.`);
207
- const [major, minor, patch] = VersionNumber.formatString(input, { omitPrefix: true }).split(".").map((number) => {
208
- return parseIntStrict(number);
209
- });
210
- this.major = major;
211
- this.minor = minor;
212
- this.patch = patch;
213
- } else if (Array.isArray(input)) {
214
- if (input.length !== 3) throw new DataError({ input }, "INVALID_LENGTH", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
215
- const [major, minor, patch] = input.map((number) => {
216
- const parsedInteger = parseIntStrict(number?.toString());
217
- if (parsedInteger < 0) throw new DataError({ input }, "NEGATIVE_INPUTS", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
218
- return parsedInteger;
219
- });
220
- this.major = major;
221
- this.minor = minor;
222
- this.patch = patch;
223
- } else throw new DataError({ input }, "INVALID_INPUT", normaliseIndents`
224
- The provided input can not be parsed into a valid version number.
225
- Expected either a string of format X.Y.Z or vX.Y.Z, a tuple of three numbers, or another \`VersionNumber\` instance.
226
- `);
227
- }
228
- /**
229
- * Gets the current version type of the current instance of `VersionNumber`.
230
- *
231
- * @returns Either `"major"`, `"minor"`, or `"patch"`, depending on the version type.
232
- */
233
- get type() {
234
- if (this.minor === 0 && this.patch === 0) return VersionType.MAJOR;
235
- if (this.patch === 0) return VersionType.MINOR;
236
- return VersionType.PATCH;
237
- }
238
- static formatString(input, options) {
239
- if (options?.omitPrefix) return input.startsWith("v") ? input.slice(1) : input;
240
- return input.startsWith("v") ? input : `v${input}`;
241
- }
242
- /**
243
- * Checks if the provided version numbers have the exact same major, minor, and patch numbers.
244
- *
245
- * @param firstVersion - The first version number to compare.
246
- * @param secondVersion - The second version number to compare.
247
- *
248
- * @returns `true` if the provided version numbers have exactly the same major, minor, and patch numbers, and returns `false` otherwise.
249
- */
250
- static isEqual(firstVersion, secondVersion) {
251
- return firstVersion.major === secondVersion.major && firstVersion.minor === secondVersion.minor && firstVersion.patch === secondVersion.patch;
252
- }
253
- /**
254
- * Get a formatted string representation of the current version number
255
- *
256
- * @param options - Options to apply to the string formatting.
257
- *
258
- * @returns A formatted string representation of the current version number with the options applied.
259
- */
260
- format(options) {
261
- let baseOutput = `${this.major}`;
262
- if (!options?.omitMinor) {
263
- baseOutput += `.${this.minor}`;
264
- if (!options?.omitPatch) baseOutput += `.${this.patch}`;
265
- }
266
- return VersionNumber.formatString(baseOutput, { omitPrefix: options?.omitPrefix });
267
- }
268
- /**
269
- * Increments the current version number by the given increment type, returning the result as a new reference in memory.
270
- *
271
- * @param incrementType - The type of increment. Can be one of the following:
272
- * - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
273
- * - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
274
- * - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
275
- * @param incrementAmount - The amount to increment by (defaults to 1).
276
- *
277
- * @returns A new instance of `VersionNumber` with the increment applied.
278
- */
279
- increment(incrementType, incrementAmount = 1) {
280
- const incrementBy = parseIntStrict(String(incrementAmount));
281
- const calculatedRawVersion = {
282
- major: [
283
- this.major + incrementBy,
284
- 0,
285
- 0
286
- ],
287
- minor: [
288
- this.major,
289
- this.minor + incrementBy,
290
- 0
291
- ],
292
- patch: [
293
- this.major,
294
- this.minor,
295
- this.patch + incrementBy
296
- ]
297
- }[incrementType];
298
- try {
299
- return new VersionNumber(calculatedRawVersion);
300
- } catch (error) {
301
- if (DataError.check(error) && error.code === "NEGATIVE_INPUTS") throw new DataError({
302
- currentVersion: this.toString(),
303
- calculatedRawVersion: `v${calculatedRawVersion.join(".")}`,
304
- incrementAmount
305
- }, "NEGATIVE_VERSION", "Cannot apply this increment amount as it would lead to a negative version number.");
306
- else throw error;
307
- }
308
- }
309
- /**
310
- * Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
311
- *
312
- * @param hint - Not used as of now, but generally used to help with numeric coercion, I think (which we most likely do not need for version numbers).
313
- *
314
- * @returns A stringified representation of the current version number, prefixed with `v`.
315
- */
316
- [Symbol.toPrimitive](hint) {
317
- if (hint === "number") throw new DataError({ thisVersion: this.toString() }, "INVALID_COERCION", "VersionNumber cannot be coerced to a number type.");
318
- return this.toString();
319
- }
320
- /**
321
- * Ensures that the VersionNumber behaves correctly when attempted to be converted to JSON.
322
- *
323
- * @returns A stringified representation of the current version number, prefixed with `v`.
324
- */
325
- toJSON() {
326
- return this.toString();
327
- }
328
- /**
329
- * Get a string representation of the current version number.
330
- *
331
- * @returns A stringified representation of the current version number with the prefix.
332
- */
333
- toString() {
334
- const rawString = `${this.major}.${this.minor}.${this.patch}`;
335
- return VersionNumber.formatString(rawString, { omitPrefix: false });
336
- }
337
- };
338
- zod.default.union([
339
- zod.default.string(),
340
- zod.default.tuple([
341
- zod.default.number(),
342
- zod.default.number(),
343
- zod.default.number()
344
- ]),
345
- zod.default.instanceof(VersionNumber)
346
- ]).transform((rawVersionNumber) => {
347
- return new VersionNumber(rawVersionNumber);
348
- });
349
- //#endregion
350
- //#region src/root/functions/parsers/parseIntStrict.ts
351
- /**
352
- * Converts a string to an integer and throws an error if it cannot be converted.
353
- *
354
- * @category Parsers
355
- *
356
- * @param string - A string to convert into a number.
357
- * @param radix - A value between 2 and 36 that specifies the base of the number in string. If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. All other strings are considered decimal.
358
- *
359
- * @throws {DataError} If the provided string cannot safely be converted to an integer.
360
- *
361
- * @returns The integer parsed from the input string.
362
- */
363
- function parseIntStrict(string, radix) {
364
- const trimmedString = string.trim();
365
- const maxAllowedAlphabeticalCharacter = radix && radix > 10 && radix <= 36 ? String.fromCharCode(87 + radix - 1) : void 0;
366
- if (!(radix && radix > 10 && radix <= 36 ? new RegExp(`^[+-]?[0-9a-${maxAllowedAlphabeticalCharacter}]+$`, "i") : /^[+-]?\d+$/).test(trimmedString)) throw new DataError(radix ? {
367
- string,
368
- radix
369
- } : { string }, "INTEGER_PARSING_ERROR", `Only numeric values${radix && radix > 10 && radix <= 36 ? ` or character${radix !== 11 ? "s" : ""} A${radix !== 11 ? `-${maxAllowedAlphabeticalCharacter?.toUpperCase()} ` : " "}` : " "}are allowed.`);
370
- if (radix && radix < 10 && [...trimmedString.replace(/^[+-]/, "")].some((character) => {
371
- return parseInt(character) >= radix;
372
- })) throw new DataError({
373
- string,
374
- radix
375
- }, "INTEGER_PARSING_ERROR", "Value contains one or more digits outside of the range of the given radix.");
376
- const parseIntResult = parseInt(trimmedString, radix);
377
- if (isNaN(parseIntResult)) throw new DataError({ string }, "INTEGER_PARSING_ERROR", "Value is not a valid integer.");
378
- return parseIntResult;
379
- }
380
- //#endregion
381
174
  //#region src/root/functions/taggedTemplate/interpolate.ts
382
175
  /**
383
176
  * Returns the result of interpolating a template string when given the strings and interpolations separately.
@@ -628,18 +421,6 @@ function parseZodSchema(schema, input, onError) {
628
421
  return _parseZodSchema(schema.safeParse(input), input, onError);
629
422
  }
630
423
  //#endregion
631
- //#region src/root/functions/parsers/parseVersionType.ts
632
- /**
633
- * Represents the three common software version types.
634
- *
635
- * @category Types
636
- */
637
- const VersionType = {
638
- MAJOR: "major",
639
- MINOR: "minor",
640
- PATCH: "patch"
641
- };
642
- //#endregion
643
424
  //#region src/internal/getDependenciesFromGroup.ts
644
425
  /**
645
426
  * Get the dependencies from a given dependency group in `package.json`.
@@ -146,213 +146,6 @@ var DataError = class DataError extends Error {
146
146
  }
147
147
  };
148
148
  //#endregion
149
- //#region src/root/constants/FILE_PATH_REGEX.ts
150
- const FILE_PATH_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]+)`;
151
- RegExp(`^${FILE_PATH_PATTERN}$`);
152
- new RegExp(`^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$`);
153
- //#endregion
154
- //#region src/root/constants/VERSION_NUMBER_REGEX.ts
155
- const VERSION_NUMBER_PATTERN = String.raw`^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$`;
156
- const VERSION_NUMBER_REGEX = RegExp(`^${VERSION_NUMBER_PATTERN}$`);
157
- //#endregion
158
- //#region src/root/types/VersionNumber.ts
159
- /**
160
- * Represents a software version number, considered to be made up of a major, minor, and patch part.
161
- *
162
- * @category Types
163
- */
164
- var VersionNumber = class VersionNumber {
165
- static NON_NEGATIVE_TUPLE_ERROR = "Input array must be a tuple of three non-negative integers.";
166
- /** The major number. Increments when a feature is removed or changed in a way that is not backwards-compatible with the previous release. */
167
- major = 0;
168
- /** The minor number. Increments when a new feature is added/deprecated and is expected to be backwards-compatible with the previous release. */
169
- minor = 0;
170
- /** The patch number. Increments when the next release is fixing a bug or doing a small refactor that should not be noticeable in practice. */
171
- patch = 0;
172
- /**
173
- * @param input - The input to create a new instance of `VersionNumber` from.
174
- */
175
- constructor(input) {
176
- if (input instanceof VersionNumber) {
177
- this.major = input.major;
178
- this.minor = input.minor;
179
- this.patch = input.patch;
180
- } else if (typeof input === "string") {
181
- if (!VERSION_NUMBER_REGEX.test(input)) throw new DataError({ input }, "INVALID_VERSION", `"${input}" is not a valid version number. Version numbers must be of the format "X.Y.Z" or "vX.Y.Z", where X, Y, and Z are non-negative integers.`);
182
- const [major, minor, patch] = VersionNumber.formatString(input, { omitPrefix: true }).split(".").map((number) => {
183
- return parseIntStrict(number);
184
- });
185
- this.major = major;
186
- this.minor = minor;
187
- this.patch = patch;
188
- } else if (Array.isArray(input)) {
189
- if (input.length !== 3) throw new DataError({ input }, "INVALID_LENGTH", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
190
- const [major, minor, patch] = input.map((number) => {
191
- const parsedInteger = parseIntStrict(number?.toString());
192
- if (parsedInteger < 0) throw new DataError({ input }, "NEGATIVE_INPUTS", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
193
- return parsedInteger;
194
- });
195
- this.major = major;
196
- this.minor = minor;
197
- this.patch = patch;
198
- } else throw new DataError({ input }, "INVALID_INPUT", normaliseIndents`
199
- The provided input can not be parsed into a valid version number.
200
- Expected either a string of format X.Y.Z or vX.Y.Z, a tuple of three numbers, or another \`VersionNumber\` instance.
201
- `);
202
- }
203
- /**
204
- * Gets the current version type of the current instance of `VersionNumber`.
205
- *
206
- * @returns Either `"major"`, `"minor"`, or `"patch"`, depending on the version type.
207
- */
208
- get type() {
209
- if (this.minor === 0 && this.patch === 0) return VersionType.MAJOR;
210
- if (this.patch === 0) return VersionType.MINOR;
211
- return VersionType.PATCH;
212
- }
213
- static formatString(input, options) {
214
- if (options?.omitPrefix) return input.startsWith("v") ? input.slice(1) : input;
215
- return input.startsWith("v") ? input : `v${input}`;
216
- }
217
- /**
218
- * Checks if the provided version numbers have the exact same major, minor, and patch numbers.
219
- *
220
- * @param firstVersion - The first version number to compare.
221
- * @param secondVersion - The second version number to compare.
222
- *
223
- * @returns `true` if the provided version numbers have exactly the same major, minor, and patch numbers, and returns `false` otherwise.
224
- */
225
- static isEqual(firstVersion, secondVersion) {
226
- return firstVersion.major === secondVersion.major && firstVersion.minor === secondVersion.minor && firstVersion.patch === secondVersion.patch;
227
- }
228
- /**
229
- * Get a formatted string representation of the current version number
230
- *
231
- * @param options - Options to apply to the string formatting.
232
- *
233
- * @returns A formatted string representation of the current version number with the options applied.
234
- */
235
- format(options) {
236
- let baseOutput = `${this.major}`;
237
- if (!options?.omitMinor) {
238
- baseOutput += `.${this.minor}`;
239
- if (!options?.omitPatch) baseOutput += `.${this.patch}`;
240
- }
241
- return VersionNumber.formatString(baseOutput, { omitPrefix: options?.omitPrefix });
242
- }
243
- /**
244
- * Increments the current version number by the given increment type, returning the result as a new reference in memory.
245
- *
246
- * @param incrementType - The type of increment. Can be one of the following:
247
- * - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
248
- * - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
249
- * - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
250
- * @param incrementAmount - The amount to increment by (defaults to 1).
251
- *
252
- * @returns A new instance of `VersionNumber` with the increment applied.
253
- */
254
- increment(incrementType, incrementAmount = 1) {
255
- const incrementBy = parseIntStrict(String(incrementAmount));
256
- const calculatedRawVersion = {
257
- major: [
258
- this.major + incrementBy,
259
- 0,
260
- 0
261
- ],
262
- minor: [
263
- this.major,
264
- this.minor + incrementBy,
265
- 0
266
- ],
267
- patch: [
268
- this.major,
269
- this.minor,
270
- this.patch + incrementBy
271
- ]
272
- }[incrementType];
273
- try {
274
- return new VersionNumber(calculatedRawVersion);
275
- } catch (error) {
276
- if (DataError.check(error) && error.code === "NEGATIVE_INPUTS") throw new DataError({
277
- currentVersion: this.toString(),
278
- calculatedRawVersion: `v${calculatedRawVersion.join(".")}`,
279
- incrementAmount
280
- }, "NEGATIVE_VERSION", "Cannot apply this increment amount as it would lead to a negative version number.");
281
- else throw error;
282
- }
283
- }
284
- /**
285
- * Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
286
- *
287
- * @param hint - Not used as of now, but generally used to help with numeric coercion, I think (which we most likely do not need for version numbers).
288
- *
289
- * @returns A stringified representation of the current version number, prefixed with `v`.
290
- */
291
- [Symbol.toPrimitive](hint) {
292
- if (hint === "number") throw new DataError({ thisVersion: this.toString() }, "INVALID_COERCION", "VersionNumber cannot be coerced to a number type.");
293
- return this.toString();
294
- }
295
- /**
296
- * Ensures that the VersionNumber behaves correctly when attempted to be converted to JSON.
297
- *
298
- * @returns A stringified representation of the current version number, prefixed with `v`.
299
- */
300
- toJSON() {
301
- return this.toString();
302
- }
303
- /**
304
- * Get a string representation of the current version number.
305
- *
306
- * @returns A stringified representation of the current version number with the prefix.
307
- */
308
- toString() {
309
- const rawString = `${this.major}.${this.minor}.${this.patch}`;
310
- return VersionNumber.formatString(rawString, { omitPrefix: false });
311
- }
312
- };
313
- z.union([
314
- z.string(),
315
- z.tuple([
316
- z.number(),
317
- z.number(),
318
- z.number()
319
- ]),
320
- z.instanceof(VersionNumber)
321
- ]).transform((rawVersionNumber) => {
322
- return new VersionNumber(rawVersionNumber);
323
- });
324
- //#endregion
325
- //#region src/root/functions/parsers/parseIntStrict.ts
326
- /**
327
- * Converts a string to an integer and throws an error if it cannot be converted.
328
- *
329
- * @category Parsers
330
- *
331
- * @param string - A string to convert into a number.
332
- * @param radix - A value between 2 and 36 that specifies the base of the number in string. If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. All other strings are considered decimal.
333
- *
334
- * @throws {DataError} If the provided string cannot safely be converted to an integer.
335
- *
336
- * @returns The integer parsed from the input string.
337
- */
338
- function parseIntStrict(string, radix) {
339
- const trimmedString = string.trim();
340
- const maxAllowedAlphabeticalCharacter = radix && radix > 10 && radix <= 36 ? String.fromCharCode(87 + radix - 1) : void 0;
341
- if (!(radix && radix > 10 && radix <= 36 ? new RegExp(`^[+-]?[0-9a-${maxAllowedAlphabeticalCharacter}]+$`, "i") : /^[+-]?\d+$/).test(trimmedString)) throw new DataError(radix ? {
342
- string,
343
- radix
344
- } : { string }, "INTEGER_PARSING_ERROR", `Only numeric values${radix && radix > 10 && radix <= 36 ? ` or character${radix !== 11 ? "s" : ""} A${radix !== 11 ? `-${maxAllowedAlphabeticalCharacter?.toUpperCase()} ` : " "}` : " "}are allowed.`);
345
- if (radix && radix < 10 && [...trimmedString.replace(/^[+-]/, "")].some((character) => {
346
- return parseInt(character) >= radix;
347
- })) throw new DataError({
348
- string,
349
- radix
350
- }, "INTEGER_PARSING_ERROR", "Value contains one or more digits outside of the range of the given radix.");
351
- const parseIntResult = parseInt(trimmedString, radix);
352
- if (isNaN(parseIntResult)) throw new DataError({ string }, "INTEGER_PARSING_ERROR", "Value is not a valid integer.");
353
- return parseIntResult;
354
- }
355
- //#endregion
356
149
  //#region src/root/functions/taggedTemplate/interpolate.ts
357
150
  /**
358
151
  * Returns the result of interpolating a template string when given the strings and interpolations separately.
@@ -603,18 +396,6 @@ function parseZodSchema(schema, input, onError) {
603
396
  return _parseZodSchema(schema.safeParse(input), input, onError);
604
397
  }
605
398
  //#endregion
606
- //#region src/root/functions/parsers/parseVersionType.ts
607
- /**
608
- * Represents the three common software version types.
609
- *
610
- * @category Types
611
- */
612
- const VersionType = {
613
- MAJOR: "major",
614
- MINOR: "minor",
615
- PATCH: "patch"
616
- };
617
- //#endregion
618
399
  //#region src/internal/getDependenciesFromGroup.ts
619
400
  /**
620
401
  * Get the dependencies from a given dependency group in `package.json`.
@@ -23,10 +23,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  //#endregion
24
24
  let node_path = require("node:path");
25
25
  node_path = __toESM(node_path);
26
- let zod = require("zod");
27
- zod = __toESM(zod);
28
- let libsodium_wrappers = require("libsodium-wrappers");
29
- libsodium_wrappers = __toESM(libsodium_wrappers);
30
26
  //#region src/node/functions/normalizeImportPath.ts
31
27
  /**
32
28
  * Normalizes an import path meant for use in an import statement in JavaScript.
@@ -66,11 +62,6 @@ const normaliseImportPath = normalizeImportPath;
66
62
  //#region src/root/constants/FILE_PATH_REGEX.ts
67
63
  const FILE_PATH_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]+)`;
68
64
  const FILE_PATH_REGEX = RegExp(`^${FILE_PATH_PATTERN}$`);
69
- new RegExp(`^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$`);
70
- //#endregion
71
- //#region src/root/constants/VERSION_NUMBER_REGEX.ts
72
- const VERSION_NUMBER_PATTERN = String.raw`^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$`;
73
- const VERSION_NUMBER_REGEX = RegExp(`^${VERSION_NUMBER_PATTERN}$`);
74
65
  //#endregion
75
66
  //#region src/root/functions/arrayHelpers/fillArray.ts
76
67
  /**
@@ -121,37 +112,6 @@ function paralleliseArrays(firstArray, secondArray) {
121
112
  return outputArray;
122
113
  }
123
114
  //#endregion
124
- //#region src/root/functions/parsers/parseIntStrict.ts
125
- /**
126
- * Converts a string to an integer and throws an error if it cannot be converted.
127
- *
128
- * @category Parsers
129
- *
130
- * @param string - A string to convert into a number.
131
- * @param radix - A value between 2 and 36 that specifies the base of the number in string. If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. All other strings are considered decimal.
132
- *
133
- * @throws {DataError} If the provided string cannot safely be converted to an integer.
134
- *
135
- * @returns The integer parsed from the input string.
136
- */
137
- function parseIntStrict(string, radix) {
138
- const trimmedString = string.trim();
139
- const maxAllowedAlphabeticalCharacter = radix && radix > 10 && radix <= 36 ? String.fromCharCode(87 + radix - 1) : void 0;
140
- if (!(radix && radix > 10 && radix <= 36 ? new RegExp(`^[+-]?[0-9a-${maxAllowedAlphabeticalCharacter}]+$`, "i") : /^[+-]?\d+$/).test(trimmedString)) throw new DataError(radix ? {
141
- string,
142
- radix
143
- } : { string }, "INTEGER_PARSING_ERROR", `Only numeric values${radix && radix > 10 && radix <= 36 ? ` or character${radix !== 11 ? "s" : ""} A${radix !== 11 ? `-${maxAllowedAlphabeticalCharacter?.toUpperCase()} ` : " "}` : " "}are allowed.`);
144
- if (radix && radix < 10 && [...trimmedString.replace(/^[+-]/, "")].some((character) => {
145
- return parseInt(character) >= radix;
146
- })) throw new DataError({
147
- string,
148
- radix
149
- }, "INTEGER_PARSING_ERROR", "Value contains one or more digits outside of the range of the given radix.");
150
- const parseIntResult = parseInt(trimmedString, radix);
151
- if (isNaN(parseIntResult)) throw new DataError({ string }, "INTEGER_PARSING_ERROR", "Value is not a valid integer.");
152
- return parseIntResult;
153
- }
154
- //#endregion
155
115
  //#region src/root/functions/taggedTemplate/interpolate.ts
156
116
  /**
157
117
  * Returns the result of interpolating a template string when given the strings and interpolations separately.
@@ -355,18 +315,6 @@ function sayHello() {
355
315
  `;
356
316
  }
357
317
  //#endregion
358
- //#region src/root/functions/parsers/parseVersionType.ts
359
- /**
360
- * Represents the three common software version types.
361
- *
362
- * @category Types
363
- */
364
- const VersionType = {
365
- MAJOR: "major",
366
- MINOR: "minor",
367
- PATCH: "patch"
368
- };
369
- //#endregion
370
318
  //#region src/root/types/DataError.ts
371
319
  /**
372
320
  * Represents errors you may get that may've been caused by a specific piece of data.
@@ -456,173 +404,6 @@ var DataError = class DataError extends Error {
456
404
  }
457
405
  };
458
406
  //#endregion
459
- //#region src/root/types/VersionNumber.ts
460
- /**
461
- * Represents a software version number, considered to be made up of a major, minor, and patch part.
462
- *
463
- * @category Types
464
- */
465
- var VersionNumber = class VersionNumber {
466
- static NON_NEGATIVE_TUPLE_ERROR = "Input array must be a tuple of three non-negative integers.";
467
- /** The major number. Increments when a feature is removed or changed in a way that is not backwards-compatible with the previous release. */
468
- major = 0;
469
- /** The minor number. Increments when a new feature is added/deprecated and is expected to be backwards-compatible with the previous release. */
470
- minor = 0;
471
- /** The patch number. Increments when the next release is fixing a bug or doing a small refactor that should not be noticeable in practice. */
472
- patch = 0;
473
- /**
474
- * @param input - The input to create a new instance of `VersionNumber` from.
475
- */
476
- constructor(input) {
477
- if (input instanceof VersionNumber) {
478
- this.major = input.major;
479
- this.minor = input.minor;
480
- this.patch = input.patch;
481
- } else if (typeof input === "string") {
482
- if (!VERSION_NUMBER_REGEX.test(input)) throw new DataError({ input }, "INVALID_VERSION", `"${input}" is not a valid version number. Version numbers must be of the format "X.Y.Z" or "vX.Y.Z", where X, Y, and Z are non-negative integers.`);
483
- const [major, minor, patch] = VersionNumber.formatString(input, { omitPrefix: true }).split(".").map((number) => {
484
- return parseIntStrict(number);
485
- });
486
- this.major = major;
487
- this.minor = minor;
488
- this.patch = patch;
489
- } else if (Array.isArray(input)) {
490
- if (input.length !== 3) throw new DataError({ input }, "INVALID_LENGTH", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
491
- const [major, minor, patch] = input.map((number) => {
492
- const parsedInteger = parseIntStrict(number?.toString());
493
- if (parsedInteger < 0) throw new DataError({ input }, "NEGATIVE_INPUTS", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
494
- return parsedInteger;
495
- });
496
- this.major = major;
497
- this.minor = minor;
498
- this.patch = patch;
499
- } else throw new DataError({ input }, "INVALID_INPUT", normaliseIndents`
500
- The provided input can not be parsed into a valid version number.
501
- Expected either a string of format X.Y.Z or vX.Y.Z, a tuple of three numbers, or another \`VersionNumber\` instance.
502
- `);
503
- }
504
- /**
505
- * Gets the current version type of the current instance of `VersionNumber`.
506
- *
507
- * @returns Either `"major"`, `"minor"`, or `"patch"`, depending on the version type.
508
- */
509
- get type() {
510
- if (this.minor === 0 && this.patch === 0) return VersionType.MAJOR;
511
- if (this.patch === 0) return VersionType.MINOR;
512
- return VersionType.PATCH;
513
- }
514
- static formatString(input, options) {
515
- if (options?.omitPrefix) return input.startsWith("v") ? input.slice(1) : input;
516
- return input.startsWith("v") ? input : `v${input}`;
517
- }
518
- /**
519
- * Checks if the provided version numbers have the exact same major, minor, and patch numbers.
520
- *
521
- * @param firstVersion - The first version number to compare.
522
- * @param secondVersion - The second version number to compare.
523
- *
524
- * @returns `true` if the provided version numbers have exactly the same major, minor, and patch numbers, and returns `false` otherwise.
525
- */
526
- static isEqual(firstVersion, secondVersion) {
527
- return firstVersion.major === secondVersion.major && firstVersion.minor === secondVersion.minor && firstVersion.patch === secondVersion.patch;
528
- }
529
- /**
530
- * Get a formatted string representation of the current version number
531
- *
532
- * @param options - Options to apply to the string formatting.
533
- *
534
- * @returns A formatted string representation of the current version number with the options applied.
535
- */
536
- format(options) {
537
- let baseOutput = `${this.major}`;
538
- if (!options?.omitMinor) {
539
- baseOutput += `.${this.minor}`;
540
- if (!options?.omitPatch) baseOutput += `.${this.patch}`;
541
- }
542
- return VersionNumber.formatString(baseOutput, { omitPrefix: options?.omitPrefix });
543
- }
544
- /**
545
- * Increments the current version number by the given increment type, returning the result as a new reference in memory.
546
- *
547
- * @param incrementType - The type of increment. Can be one of the following:
548
- * - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
549
- * - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
550
- * - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
551
- * @param incrementAmount - The amount to increment by (defaults to 1).
552
- *
553
- * @returns A new instance of `VersionNumber` with the increment applied.
554
- */
555
- increment(incrementType, incrementAmount = 1) {
556
- const incrementBy = parseIntStrict(String(incrementAmount));
557
- const calculatedRawVersion = {
558
- major: [
559
- this.major + incrementBy,
560
- 0,
561
- 0
562
- ],
563
- minor: [
564
- this.major,
565
- this.minor + incrementBy,
566
- 0
567
- ],
568
- patch: [
569
- this.major,
570
- this.minor,
571
- this.patch + incrementBy
572
- ]
573
- }[incrementType];
574
- try {
575
- return new VersionNumber(calculatedRawVersion);
576
- } catch (error) {
577
- if (DataError.check(error) && error.code === "NEGATIVE_INPUTS") throw new DataError({
578
- currentVersion: this.toString(),
579
- calculatedRawVersion: `v${calculatedRawVersion.join(".")}`,
580
- incrementAmount
581
- }, "NEGATIVE_VERSION", "Cannot apply this increment amount as it would lead to a negative version number.");
582
- else throw error;
583
- }
584
- }
585
- /**
586
- * Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
587
- *
588
- * @param hint - Not used as of now, but generally used to help with numeric coercion, I think (which we most likely do not need for version numbers).
589
- *
590
- * @returns A stringified representation of the current version number, prefixed with `v`.
591
- */
592
- [Symbol.toPrimitive](hint) {
593
- if (hint === "number") throw new DataError({ thisVersion: this.toString() }, "INVALID_COERCION", "VersionNumber cannot be coerced to a number type.");
594
- return this.toString();
595
- }
596
- /**
597
- * Ensures that the VersionNumber behaves correctly when attempted to be converted to JSON.
598
- *
599
- * @returns A stringified representation of the current version number, prefixed with `v`.
600
- */
601
- toJSON() {
602
- return this.toString();
603
- }
604
- /**
605
- * Get a string representation of the current version number.
606
- *
607
- * @returns A stringified representation of the current version number with the prefix.
608
- */
609
- toString() {
610
- const rawString = `${this.major}.${this.minor}.${this.patch}`;
611
- return VersionNumber.formatString(rawString, { omitPrefix: false });
612
- }
613
- };
614
- zod.default.union([
615
- zod.default.string(),
616
- zod.default.tuple([
617
- zod.default.number(),
618
- zod.default.number(),
619
- zod.default.number()
620
- ]),
621
- zod.default.instanceof(VersionNumber)
622
- ]).transform((rawVersionNumber) => {
623
- return new VersionNumber(rawVersionNumber);
624
- });
625
- //#endregion
626
407
  //#region src/node/functions/parseFilePath.ts
627
408
  /**
628
409
  * Takes a file path string and parses it into the directory part, the base part, and the full path.
@@ -656,27 +437,6 @@ function parseFilePath(filePath) {
656
437
  //#region src/node/functions/sayHello.ts
657
438
  var sayHello_default = sayHello;
658
439
  //#endregion
659
- //#region src/node/functions/security/encryptWithKey.ts
660
- /**
661
- * Encrypt a secret given the public base64 key and the thing you want to encrypt.
662
- *
663
- * @param publicKey - The public base64 key to encrypt with.
664
- * @param plaintextValue - The value to encrypt in plaintext.
665
- *
666
- * @returns The encrypted string. This value will be different on repeat calls, but the result should always decrypt to the initial `plaintextValue` argument.
667
- */
668
- async function encryptWithKey(publicKey, plaintextValue) {
669
- try {
670
- await libsodium_wrappers.default.ready;
671
- const base64Key = libsodium_wrappers.default.from_base64(publicKey, libsodium_wrappers.default.base64_variants.ORIGINAL);
672
- const encryptedValue = libsodium_wrappers.default.crypto_box_seal(plaintextValue, base64Key);
673
- return libsodium_wrappers.default.to_base64(encryptedValue, libsodium_wrappers.default.base64_variants.ORIGINAL);
674
- } catch {
675
- throw new DataError({ publicKey }, "ENCRYPTION_FAILED", "Encryption failed. Please double-check that the given key is a valid base 64 string.");
676
- }
677
- }
678
- //#endregion
679
- exports.encryptWithKey = encryptWithKey;
680
440
  exports.normaliseImportPath = normaliseImportPath;
681
441
  exports.normalizeImportPath = normalizeImportPath;
682
442
  exports.parseFilePath = parseFilePath;
@@ -65,15 +65,4 @@ declare function sayHello(): string;
65
65
  //#region src/root/types/IsTypeArgumentString.d.ts
66
66
  type IsTypeArgumentString<Argument extends string> = Argument;
67
67
  //#endregion
68
- //#region src/node/functions/security/encryptWithKey.d.ts
69
- /**
70
- * Encrypt a secret given the public base64 key and the thing you want to encrypt.
71
- *
72
- * @param publicKey - The public base64 key to encrypt with.
73
- * @param plaintextValue - The value to encrypt in plaintext.
74
- *
75
- * @returns The encrypted string. This value will be different on repeat calls, but the result should always decrypt to the initial `plaintextValue` argument.
76
- */
77
- declare function encryptWithKey(publicKey: string, plaintextValue: string): Promise<string>;
78
- //#endregion
79
- export { type IsTypeArgumentString, encryptWithKey, normaliseImportPath, normalizeImportPath, parseFilePath, sayHello };
68
+ export { type IsTypeArgumentString, normaliseImportPath, normalizeImportPath, parseFilePath, sayHello };
@@ -1,4 +1,3 @@
1
- import z from "zod";
2
1
  //#region src/node/functions/normalizeImportPath.d.ts
3
2
  /**
4
3
  * Normalizes an import path meant for use in an import statement in JavaScript.
@@ -66,15 +65,4 @@ declare function sayHello(): string;
66
65
  //#region src/root/types/IsTypeArgumentString.d.ts
67
66
  type IsTypeArgumentString<Argument extends string> = Argument;
68
67
  //#endregion
69
- //#region src/node/functions/security/encryptWithKey.d.ts
70
- /**
71
- * Encrypt a secret given the public base64 key and the thing you want to encrypt.
72
- *
73
- * @param publicKey - The public base64 key to encrypt with.
74
- * @param plaintextValue - The value to encrypt in plaintext.
75
- *
76
- * @returns The encrypted string. This value will be different on repeat calls, but the result should always decrypt to the initial `plaintextValue` argument.
77
- */
78
- declare function encryptWithKey(publicKey: string, plaintextValue: string): Promise<string>;
79
- //#endregion
80
- export { type IsTypeArgumentString, encryptWithKey, normaliseImportPath, normalizeImportPath, parseFilePath, sayHello };
68
+ export { type IsTypeArgumentString, normaliseImportPath, normalizeImportPath, parseFilePath, sayHello };
@@ -1,6 +1,4 @@
1
1
  import path from "node:path";
2
- import z from "zod";
3
- import sodium from "libsodium-wrappers";
4
2
  //#region src/node/functions/normalizeImportPath.ts
5
3
  /**
6
4
  * Normalizes an import path meant for use in an import statement in JavaScript.
@@ -40,11 +38,6 @@ const normaliseImportPath = normalizeImportPath;
40
38
  //#region src/root/constants/FILE_PATH_REGEX.ts
41
39
  const FILE_PATH_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]+)`;
42
40
  const FILE_PATH_REGEX = RegExp(`^${FILE_PATH_PATTERN}$`);
43
- new RegExp(`^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$`);
44
- //#endregion
45
- //#region src/root/constants/VERSION_NUMBER_REGEX.ts
46
- const VERSION_NUMBER_PATTERN = String.raw`^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$`;
47
- const VERSION_NUMBER_REGEX = RegExp(`^${VERSION_NUMBER_PATTERN}$`);
48
41
  //#endregion
49
42
  //#region src/root/functions/arrayHelpers/fillArray.ts
50
43
  /**
@@ -95,37 +88,6 @@ function paralleliseArrays(firstArray, secondArray) {
95
88
  return outputArray;
96
89
  }
97
90
  //#endregion
98
- //#region src/root/functions/parsers/parseIntStrict.ts
99
- /**
100
- * Converts a string to an integer and throws an error if it cannot be converted.
101
- *
102
- * @category Parsers
103
- *
104
- * @param string - A string to convert into a number.
105
- * @param radix - A value between 2 and 36 that specifies the base of the number in string. If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. All other strings are considered decimal.
106
- *
107
- * @throws {DataError} If the provided string cannot safely be converted to an integer.
108
- *
109
- * @returns The integer parsed from the input string.
110
- */
111
- function parseIntStrict(string, radix) {
112
- const trimmedString = string.trim();
113
- const maxAllowedAlphabeticalCharacter = radix && radix > 10 && radix <= 36 ? String.fromCharCode(87 + radix - 1) : void 0;
114
- if (!(radix && radix > 10 && radix <= 36 ? new RegExp(`^[+-]?[0-9a-${maxAllowedAlphabeticalCharacter}]+$`, "i") : /^[+-]?\d+$/).test(trimmedString)) throw new DataError(radix ? {
115
- string,
116
- radix
117
- } : { string }, "INTEGER_PARSING_ERROR", `Only numeric values${radix && radix > 10 && radix <= 36 ? ` or character${radix !== 11 ? "s" : ""} A${radix !== 11 ? `-${maxAllowedAlphabeticalCharacter?.toUpperCase()} ` : " "}` : " "}are allowed.`);
118
- if (radix && radix < 10 && [...trimmedString.replace(/^[+-]/, "")].some((character) => {
119
- return parseInt(character) >= radix;
120
- })) throw new DataError({
121
- string,
122
- radix
123
- }, "INTEGER_PARSING_ERROR", "Value contains one or more digits outside of the range of the given radix.");
124
- const parseIntResult = parseInt(trimmedString, radix);
125
- if (isNaN(parseIntResult)) throw new DataError({ string }, "INTEGER_PARSING_ERROR", "Value is not a valid integer.");
126
- return parseIntResult;
127
- }
128
- //#endregion
129
91
  //#region src/root/functions/taggedTemplate/interpolate.ts
130
92
  /**
131
93
  * Returns the result of interpolating a template string when given the strings and interpolations separately.
@@ -329,18 +291,6 @@ function sayHello() {
329
291
  `;
330
292
  }
331
293
  //#endregion
332
- //#region src/root/functions/parsers/parseVersionType.ts
333
- /**
334
- * Represents the three common software version types.
335
- *
336
- * @category Types
337
- */
338
- const VersionType = {
339
- MAJOR: "major",
340
- MINOR: "minor",
341
- PATCH: "patch"
342
- };
343
- //#endregion
344
294
  //#region src/root/types/DataError.ts
345
295
  /**
346
296
  * Represents errors you may get that may've been caused by a specific piece of data.
@@ -430,173 +380,6 @@ var DataError = class DataError extends Error {
430
380
  }
431
381
  };
432
382
  //#endregion
433
- //#region src/root/types/VersionNumber.ts
434
- /**
435
- * Represents a software version number, considered to be made up of a major, minor, and patch part.
436
- *
437
- * @category Types
438
- */
439
- var VersionNumber = class VersionNumber {
440
- static NON_NEGATIVE_TUPLE_ERROR = "Input array must be a tuple of three non-negative integers.";
441
- /** The major number. Increments when a feature is removed or changed in a way that is not backwards-compatible with the previous release. */
442
- major = 0;
443
- /** The minor number. Increments when a new feature is added/deprecated and is expected to be backwards-compatible with the previous release. */
444
- minor = 0;
445
- /** The patch number. Increments when the next release is fixing a bug or doing a small refactor that should not be noticeable in practice. */
446
- patch = 0;
447
- /**
448
- * @param input - The input to create a new instance of `VersionNumber` from.
449
- */
450
- constructor(input) {
451
- if (input instanceof VersionNumber) {
452
- this.major = input.major;
453
- this.minor = input.minor;
454
- this.patch = input.patch;
455
- } else if (typeof input === "string") {
456
- if (!VERSION_NUMBER_REGEX.test(input)) throw new DataError({ input }, "INVALID_VERSION", `"${input}" is not a valid version number. Version numbers must be of the format "X.Y.Z" or "vX.Y.Z", where X, Y, and Z are non-negative integers.`);
457
- const [major, minor, patch] = VersionNumber.formatString(input, { omitPrefix: true }).split(".").map((number) => {
458
- return parseIntStrict(number);
459
- });
460
- this.major = major;
461
- this.minor = minor;
462
- this.patch = patch;
463
- } else if (Array.isArray(input)) {
464
- if (input.length !== 3) throw new DataError({ input }, "INVALID_LENGTH", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
465
- const [major, minor, patch] = input.map((number) => {
466
- const parsedInteger = parseIntStrict(number?.toString());
467
- if (parsedInteger < 0) throw new DataError({ input }, "NEGATIVE_INPUTS", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
468
- return parsedInteger;
469
- });
470
- this.major = major;
471
- this.minor = minor;
472
- this.patch = patch;
473
- } else throw new DataError({ input }, "INVALID_INPUT", normaliseIndents`
474
- The provided input can not be parsed into a valid version number.
475
- Expected either a string of format X.Y.Z or vX.Y.Z, a tuple of three numbers, or another \`VersionNumber\` instance.
476
- `);
477
- }
478
- /**
479
- * Gets the current version type of the current instance of `VersionNumber`.
480
- *
481
- * @returns Either `"major"`, `"minor"`, or `"patch"`, depending on the version type.
482
- */
483
- get type() {
484
- if (this.minor === 0 && this.patch === 0) return VersionType.MAJOR;
485
- if (this.patch === 0) return VersionType.MINOR;
486
- return VersionType.PATCH;
487
- }
488
- static formatString(input, options) {
489
- if (options?.omitPrefix) return input.startsWith("v") ? input.slice(1) : input;
490
- return input.startsWith("v") ? input : `v${input}`;
491
- }
492
- /**
493
- * Checks if the provided version numbers have the exact same major, minor, and patch numbers.
494
- *
495
- * @param firstVersion - The first version number to compare.
496
- * @param secondVersion - The second version number to compare.
497
- *
498
- * @returns `true` if the provided version numbers have exactly the same major, minor, and patch numbers, and returns `false` otherwise.
499
- */
500
- static isEqual(firstVersion, secondVersion) {
501
- return firstVersion.major === secondVersion.major && firstVersion.minor === secondVersion.minor && firstVersion.patch === secondVersion.patch;
502
- }
503
- /**
504
- * Get a formatted string representation of the current version number
505
- *
506
- * @param options - Options to apply to the string formatting.
507
- *
508
- * @returns A formatted string representation of the current version number with the options applied.
509
- */
510
- format(options) {
511
- let baseOutput = `${this.major}`;
512
- if (!options?.omitMinor) {
513
- baseOutput += `.${this.minor}`;
514
- if (!options?.omitPatch) baseOutput += `.${this.patch}`;
515
- }
516
- return VersionNumber.formatString(baseOutput, { omitPrefix: options?.omitPrefix });
517
- }
518
- /**
519
- * Increments the current version number by the given increment type, returning the result as a new reference in memory.
520
- *
521
- * @param incrementType - The type of increment. Can be one of the following:
522
- * - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
523
- * - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
524
- * - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
525
- * @param incrementAmount - The amount to increment by (defaults to 1).
526
- *
527
- * @returns A new instance of `VersionNumber` with the increment applied.
528
- */
529
- increment(incrementType, incrementAmount = 1) {
530
- const incrementBy = parseIntStrict(String(incrementAmount));
531
- const calculatedRawVersion = {
532
- major: [
533
- this.major + incrementBy,
534
- 0,
535
- 0
536
- ],
537
- minor: [
538
- this.major,
539
- this.minor + incrementBy,
540
- 0
541
- ],
542
- patch: [
543
- this.major,
544
- this.minor,
545
- this.patch + incrementBy
546
- ]
547
- }[incrementType];
548
- try {
549
- return new VersionNumber(calculatedRawVersion);
550
- } catch (error) {
551
- if (DataError.check(error) && error.code === "NEGATIVE_INPUTS") throw new DataError({
552
- currentVersion: this.toString(),
553
- calculatedRawVersion: `v${calculatedRawVersion.join(".")}`,
554
- incrementAmount
555
- }, "NEGATIVE_VERSION", "Cannot apply this increment amount as it would lead to a negative version number.");
556
- else throw error;
557
- }
558
- }
559
- /**
560
- * Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
561
- *
562
- * @param hint - Not used as of now, but generally used to help with numeric coercion, I think (which we most likely do not need for version numbers).
563
- *
564
- * @returns A stringified representation of the current version number, prefixed with `v`.
565
- */
566
- [Symbol.toPrimitive](hint) {
567
- if (hint === "number") throw new DataError({ thisVersion: this.toString() }, "INVALID_COERCION", "VersionNumber cannot be coerced to a number type.");
568
- return this.toString();
569
- }
570
- /**
571
- * Ensures that the VersionNumber behaves correctly when attempted to be converted to JSON.
572
- *
573
- * @returns A stringified representation of the current version number, prefixed with `v`.
574
- */
575
- toJSON() {
576
- return this.toString();
577
- }
578
- /**
579
- * Get a string representation of the current version number.
580
- *
581
- * @returns A stringified representation of the current version number with the prefix.
582
- */
583
- toString() {
584
- const rawString = `${this.major}.${this.minor}.${this.patch}`;
585
- return VersionNumber.formatString(rawString, { omitPrefix: false });
586
- }
587
- };
588
- z.union([
589
- z.string(),
590
- z.tuple([
591
- z.number(),
592
- z.number(),
593
- z.number()
594
- ]),
595
- z.instanceof(VersionNumber)
596
- ]).transform((rawVersionNumber) => {
597
- return new VersionNumber(rawVersionNumber);
598
- });
599
- //#endregion
600
383
  //#region src/node/functions/parseFilePath.ts
601
384
  /**
602
385
  * Takes a file path string and parses it into the directory part, the base part, and the full path.
@@ -630,24 +413,4 @@ function parseFilePath(filePath) {
630
413
  //#region src/node/functions/sayHello.ts
631
414
  var sayHello_default = sayHello;
632
415
  //#endregion
633
- //#region src/node/functions/security/encryptWithKey.ts
634
- /**
635
- * Encrypt a secret given the public base64 key and the thing you want to encrypt.
636
- *
637
- * @param publicKey - The public base64 key to encrypt with.
638
- * @param plaintextValue - The value to encrypt in plaintext.
639
- *
640
- * @returns The encrypted string. This value will be different on repeat calls, but the result should always decrypt to the initial `plaintextValue` argument.
641
- */
642
- async function encryptWithKey(publicKey, plaintextValue) {
643
- try {
644
- await sodium.ready;
645
- const base64Key = sodium.from_base64(publicKey, sodium.base64_variants.ORIGINAL);
646
- const encryptedValue = sodium.crypto_box_seal(plaintextValue, base64Key);
647
- return sodium.to_base64(encryptedValue, sodium.base64_variants.ORIGINAL);
648
- } catch {
649
- throw new DataError({ publicKey }, "ENCRYPTION_FAILED", "Encryption failed. Please double-check that the given key is a valid base 64 string.");
650
- }
651
- }
652
- //#endregion
653
- export { encryptWithKey, normaliseImportPath, normalizeImportPath, parseFilePath, sayHello_default as sayHello };
416
+ export { normaliseImportPath, normalizeImportPath, parseFilePath, sayHello_default as sayHello };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/utility",
3
- "version": "5.10.1",
3
+ "version": "5.11.1",
4
4
  "description": "Helpful utility functions.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,6 +9,7 @@
9
9
  "license": "MIT",
10
10
  "author": "alextheman",
11
11
  "type": "module",
12
+ "sideEffects": false,
12
13
  "exports": {
13
14
  ".": {
14
15
  "types": "./dist/index.d.ts",
@@ -30,30 +31,31 @@
30
31
  "dist"
31
32
  ],
32
33
  "dependencies": {
33
- "dotenv": "17.4.0",
34
+ "dotenv": "17.4.1",
34
35
  "execa": "9.6.1",
35
- "libsodium-wrappers": "0.8.2",
36
36
  "zod": "4.3.6"
37
37
  },
38
38
  "devDependencies": {
39
- "@alextheman/eslint-plugin": "5.12.0",
40
- "@types/node": "25.5.2",
41
- "alex-c-line": "2.5.0",
39
+ "@alextheman/eslint-plugin": "5.13.0",
40
+ "@types/node": "25.6.0",
41
+ "alex-c-line": "2.6.1",
42
42
  "cross-env": "10.1.0",
43
43
  "dotenv-cli": "11.0.0",
44
44
  "eslint": "10.2.0",
45
45
  "globals": "17.4.0",
46
46
  "husky": "9.1.7",
47
- "jsdom": "29.0.1",
48
- "prettier": "3.8.1",
47
+ "jsdom": "29.0.2",
48
+ "prettier": "3.8.2",
49
49
  "tempy": "3.2.0",
50
50
  "tsdown": "0.21.7",
51
51
  "tsx": "4.21.0",
52
52
  "typedoc": "0.28.18",
53
+ "typedoc-plugin-markdown": "4.11.0",
54
+ "typedoc-rhineai-theme": "1.2.0",
53
55
  "typescript": "6.0.2",
54
- "typescript-eslint": "8.58.0",
55
- "vite-tsconfig-paths": "6.1.1",
56
- "vitest": "4.1.2"
56
+ "typescript-eslint": "8.58.1",
57
+ "vite": "8.0.8",
58
+ "vitest": "4.1.4"
57
59
  },
58
60
  "engines": {
59
61
  "node": ">=22.3.0"