@alextheman/utility 3.1.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +48 -0
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +46 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,11 @@ path = __toESM(path);
|
|
|
30
30
|
let zod = require("zod");
|
|
31
31
|
zod = __toESM(zod);
|
|
32
32
|
|
|
33
|
+
//#region src/constants/NAMESPACE_EXPORT_REGEX.ts
|
|
34
|
+
const NAMESPACE_EXPORT_REGEX = "export\\s+\\*\\s+from";
|
|
35
|
+
var NAMESPACE_EXPORT_REGEX_default = NAMESPACE_EXPORT_REGEX;
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
33
38
|
//#region src/functions/appendSemicolon.ts
|
|
34
39
|
function appendSemicolon(stringToAppendTo) {
|
|
35
40
|
if (stringToAppendTo.includes("\n")) throw new Error("MULTIPLE_LINE_ERROR");
|
|
@@ -515,6 +520,46 @@ function interpolateObjects(strings, ...values) {
|
|
|
515
520
|
}
|
|
516
521
|
var interpolateObjects_default = interpolateObjects;
|
|
517
522
|
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region src/functions/taggedTemplate/normaliseIndents.ts
|
|
525
|
+
function calculateTabSize$1(line, whitespaceLength) {
|
|
526
|
+
const potentialWhitespacePart = line.slice(0, whitespaceLength);
|
|
527
|
+
const trimmedString = line.trimStart();
|
|
528
|
+
if (potentialWhitespacePart.trim() !== "") return 0;
|
|
529
|
+
const tabSize = line.length - (trimmedString.length + whitespaceLength);
|
|
530
|
+
return tabSize < 0 ? 0 : tabSize;
|
|
531
|
+
}
|
|
532
|
+
function getWhitespaceLength$1(lines) {
|
|
533
|
+
const [firstNonEmptyLine] = lines.filter((line) => {
|
|
534
|
+
return line.trim() !== "";
|
|
535
|
+
});
|
|
536
|
+
return firstNonEmptyLine.length - firstNonEmptyLine.trimStart().length;
|
|
537
|
+
}
|
|
538
|
+
function reduceLines$1(lines, { preserveTabs = true }) {
|
|
539
|
+
const slicedLines = lines.slice(1);
|
|
540
|
+
const isFirstLineEmpty = lines[0].trim() === "";
|
|
541
|
+
const whitespaceLength = getWhitespaceLength$1(isFirstLineEmpty ? lines : slicedLines);
|
|
542
|
+
return (isFirstLineEmpty ? slicedLines : lines).map((line) => {
|
|
543
|
+
const tabSize = calculateTabSize$1(line, whitespaceLength);
|
|
544
|
+
return (preserveTabs ? fillArray_default(() => {
|
|
545
|
+
return " ";
|
|
546
|
+
}, tabSize).join("") : "") + line.trimStart();
|
|
547
|
+
}).join("\n");
|
|
548
|
+
}
|
|
549
|
+
function normaliseIndents(first, ...args) {
|
|
550
|
+
if (typeof first === "object" && first !== null && !Array.isArray(first)) {
|
|
551
|
+
const options$1 = first;
|
|
552
|
+
return (strings$1, ...interpolations) => {
|
|
553
|
+
return normaliseIndents(strings$1, ...interpolations, options$1);
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
const strings = first;
|
|
557
|
+
const options = typeof args[args.length - 1] === "object" && !Array.isArray(args[args.length - 1]) ? args.pop() : {};
|
|
558
|
+
return reduceLines$1(interpolate_default(strings, ...[...args]).split("\n"), options);
|
|
559
|
+
}
|
|
560
|
+
const normalizeIndents = normaliseIndents;
|
|
561
|
+
var normaliseIndents_default = normaliseIndents;
|
|
562
|
+
|
|
518
563
|
//#endregion
|
|
519
564
|
//#region src/functions/taggedTemplate/removeIndents.ts
|
|
520
565
|
function calculateTabSize(line, whitespaceLength) {
|
|
@@ -575,6 +620,7 @@ var wait_default = wait;
|
|
|
575
620
|
//#endregion
|
|
576
621
|
exports.APIError = APIError_default;
|
|
577
622
|
exports.DataError = DataError_default;
|
|
623
|
+
exports.NAMESPACE_EXPORT_REGEX = NAMESPACE_EXPORT_REGEX_default;
|
|
578
624
|
exports.addDaysToDate = addDaysToDate_default;
|
|
579
625
|
exports.appendSemicolon = appendSemicolon_default;
|
|
580
626
|
exports.camelToKebab = camelToKebab_default;
|
|
@@ -595,7 +641,9 @@ exports.isOrdered = isOrdered_default;
|
|
|
595
641
|
exports.isSameDate = isSameDate_default;
|
|
596
642
|
exports.kebabToCamel = kebabToCamel_default;
|
|
597
643
|
exports.normaliseImportPath = normaliseImportPath;
|
|
644
|
+
exports.normaliseIndents = normaliseIndents_default;
|
|
598
645
|
exports.normalizeImportPath = normalizeImportPath_default;
|
|
646
|
+
exports.normalizeIndents = normalizeIndents;
|
|
599
647
|
exports.omitProperties = omitProperties_default;
|
|
600
648
|
exports.paralleliseArrays = paralleliseArrays_default;
|
|
601
649
|
exports.parseBoolean = parseBoolean_default;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import z, { ZodType, core, z as z$1 } from "zod";
|
|
2
2
|
|
|
3
|
+
//#region src/constants/NAMESPACE_EXPORT_REGEX.d.ts
|
|
4
|
+
declare const NAMESPACE_EXPORT_REGEX = "export\\s+\\*\\s+from";
|
|
5
|
+
//#endregion
|
|
3
6
|
//#region src/functions/appendSemicolon.d.ts
|
|
4
7
|
declare function appendSemicolon(stringToAppendTo: string): string;
|
|
5
8
|
//#endregion
|
|
@@ -174,12 +177,25 @@ declare function interpolate(strings: TemplateStringsArray, ...interpolations: u
|
|
|
174
177
|
//#region src/functions/taggedTemplate/interpolateObjects.d.ts
|
|
175
178
|
declare function interpolateObjects(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
176
179
|
//#endregion
|
|
180
|
+
//#region src/functions/taggedTemplate/normaliseIndents.d.ts
|
|
181
|
+
interface NormaliseIndentsOptions {
|
|
182
|
+
preserveTabs?: boolean;
|
|
183
|
+
}
|
|
184
|
+
type NormalizeIndentsOptions = NormaliseIndentsOptions;
|
|
185
|
+
type NormaliseIndentsFunction = (strings: TemplateStringsArray, ...interpolations: unknown[]) => string;
|
|
186
|
+
type NormalizeIndentsFunction = NormaliseIndentsFunction;
|
|
187
|
+
declare function normaliseIndents(options: NormaliseIndentsOptions): NormaliseIndentsFunction;
|
|
188
|
+
declare function normaliseIndents(strings: TemplateStringsArray, ...interpolations: unknown[]): string;
|
|
189
|
+
declare const normalizeIndents: typeof normaliseIndents;
|
|
190
|
+
//#endregion
|
|
177
191
|
//#region src/functions/taggedTemplate/removeIndents.d.ts
|
|
178
192
|
interface RemoveIndentsOptions {
|
|
179
193
|
preserveTabs?: boolean;
|
|
180
194
|
}
|
|
181
195
|
type RemoveIndentsFunction = (strings: TemplateStringsArray, ...interpolations: unknown[]) => string;
|
|
196
|
+
/** @deprecated This function has been renamed to normaliseIndents */
|
|
182
197
|
declare function removeIndents(options: RemoveIndentsOptions): RemoveIndentsFunction;
|
|
198
|
+
/** @deprecated This function has been renamed to normaliseIndents */
|
|
183
199
|
declare function removeIndents(strings: TemplateStringsArray, ...interpolations: unknown[]): string;
|
|
184
200
|
//#endregion
|
|
185
201
|
//#region src/functions/truncate.d.ts
|
|
@@ -188,4 +204,4 @@ declare function truncate(stringToTruncate: string, maxLength?: number): string;
|
|
|
188
204
|
//#region src/functions/wait.d.ts
|
|
189
205
|
declare function wait(seconds: number): Promise<void>;
|
|
190
206
|
//#endregion
|
|
191
|
-
export { APIError, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Email, Env, FormDataNullableResolutionStrategy
|
|
207
|
+
export { APIError, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Email, Env, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, RecordKey, RemoveIndentsFunction, RemoveIndentsOptions, StringListToArrayOptions, UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEmail, parseEnv, parseFormData, parseIntStrict, parseUUID, parseZodSchema, randomiseArray, range, removeDuplicates, removeIndents, stringListToArray, stringToBoolean, truncate, wait };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import z, { ZodType, core, z as z$1 } from "zod";
|
|
2
2
|
|
|
3
|
+
//#region src/constants/NAMESPACE_EXPORT_REGEX.d.ts
|
|
4
|
+
declare const NAMESPACE_EXPORT_REGEX = "export\\s+\\*\\s+from";
|
|
5
|
+
//#endregion
|
|
3
6
|
//#region src/functions/appendSemicolon.d.ts
|
|
4
7
|
declare function appendSemicolon(stringToAppendTo: string): string;
|
|
5
8
|
//#endregion
|
|
@@ -174,12 +177,25 @@ declare function interpolate(strings: TemplateStringsArray, ...interpolations: u
|
|
|
174
177
|
//#region src/functions/taggedTemplate/interpolateObjects.d.ts
|
|
175
178
|
declare function interpolateObjects(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
176
179
|
//#endregion
|
|
180
|
+
//#region src/functions/taggedTemplate/normaliseIndents.d.ts
|
|
181
|
+
interface NormaliseIndentsOptions {
|
|
182
|
+
preserveTabs?: boolean;
|
|
183
|
+
}
|
|
184
|
+
type NormalizeIndentsOptions = NormaliseIndentsOptions;
|
|
185
|
+
type NormaliseIndentsFunction = (strings: TemplateStringsArray, ...interpolations: unknown[]) => string;
|
|
186
|
+
type NormalizeIndentsFunction = NormaliseIndentsFunction;
|
|
187
|
+
declare function normaliseIndents(options: NormaliseIndentsOptions): NormaliseIndentsFunction;
|
|
188
|
+
declare function normaliseIndents(strings: TemplateStringsArray, ...interpolations: unknown[]): string;
|
|
189
|
+
declare const normalizeIndents: typeof normaliseIndents;
|
|
190
|
+
//#endregion
|
|
177
191
|
//#region src/functions/taggedTemplate/removeIndents.d.ts
|
|
178
192
|
interface RemoveIndentsOptions {
|
|
179
193
|
preserveTabs?: boolean;
|
|
180
194
|
}
|
|
181
195
|
type RemoveIndentsFunction = (strings: TemplateStringsArray, ...interpolations: unknown[]) => string;
|
|
196
|
+
/** @deprecated This function has been renamed to normaliseIndents */
|
|
182
197
|
declare function removeIndents(options: RemoveIndentsOptions): RemoveIndentsFunction;
|
|
198
|
+
/** @deprecated This function has been renamed to normaliseIndents */
|
|
183
199
|
declare function removeIndents(strings: TemplateStringsArray, ...interpolations: unknown[]): string;
|
|
184
200
|
//#endregion
|
|
185
201
|
//#region src/functions/truncate.d.ts
|
|
@@ -188,4 +204,4 @@ declare function truncate(stringToTruncate: string, maxLength?: number): string;
|
|
|
188
204
|
//#region src/functions/wait.d.ts
|
|
189
205
|
declare function wait(seconds: number): Promise<void>;
|
|
190
206
|
//#endregion
|
|
191
|
-
export { APIError, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, type Email, type Env, type
|
|
207
|
+
export { APIError, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, type Email, type Env, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, type OptionalOnCondition, type RecordKey, RemoveIndentsFunction, RemoveIndentsOptions, type StringListToArrayOptions, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEmail, parseEnv, parseFormData, parseIntStrict, parseUUID, parseZodSchema, randomiseArray, range, removeDuplicates, removeIndents, stringListToArray, stringToBoolean, truncate, wait };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import z, { z as z$1 } from "zod";
|
|
3
3
|
|
|
4
|
+
//#region src/constants/NAMESPACE_EXPORT_REGEX.ts
|
|
5
|
+
const NAMESPACE_EXPORT_REGEX = "export\\s+\\*\\s+from";
|
|
6
|
+
var NAMESPACE_EXPORT_REGEX_default = NAMESPACE_EXPORT_REGEX;
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
4
9
|
//#region src/functions/appendSemicolon.ts
|
|
5
10
|
function appendSemicolon(stringToAppendTo) {
|
|
6
11
|
if (stringToAppendTo.includes("\n")) throw new Error("MULTIPLE_LINE_ERROR");
|
|
@@ -486,6 +491,46 @@ function interpolateObjects(strings, ...values) {
|
|
|
486
491
|
}
|
|
487
492
|
var interpolateObjects_default = interpolateObjects;
|
|
488
493
|
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region src/functions/taggedTemplate/normaliseIndents.ts
|
|
496
|
+
function calculateTabSize$1(line, whitespaceLength) {
|
|
497
|
+
const potentialWhitespacePart = line.slice(0, whitespaceLength);
|
|
498
|
+
const trimmedString = line.trimStart();
|
|
499
|
+
if (potentialWhitespacePart.trim() !== "") return 0;
|
|
500
|
+
const tabSize = line.length - (trimmedString.length + whitespaceLength);
|
|
501
|
+
return tabSize < 0 ? 0 : tabSize;
|
|
502
|
+
}
|
|
503
|
+
function getWhitespaceLength$1(lines) {
|
|
504
|
+
const [firstNonEmptyLine] = lines.filter((line) => {
|
|
505
|
+
return line.trim() !== "";
|
|
506
|
+
});
|
|
507
|
+
return firstNonEmptyLine.length - firstNonEmptyLine.trimStart().length;
|
|
508
|
+
}
|
|
509
|
+
function reduceLines$1(lines, { preserveTabs = true }) {
|
|
510
|
+
const slicedLines = lines.slice(1);
|
|
511
|
+
const isFirstLineEmpty = lines[0].trim() === "";
|
|
512
|
+
const whitespaceLength = getWhitespaceLength$1(isFirstLineEmpty ? lines : slicedLines);
|
|
513
|
+
return (isFirstLineEmpty ? slicedLines : lines).map((line) => {
|
|
514
|
+
const tabSize = calculateTabSize$1(line, whitespaceLength);
|
|
515
|
+
return (preserveTabs ? fillArray_default(() => {
|
|
516
|
+
return " ";
|
|
517
|
+
}, tabSize).join("") : "") + line.trimStart();
|
|
518
|
+
}).join("\n");
|
|
519
|
+
}
|
|
520
|
+
function normaliseIndents(first, ...args) {
|
|
521
|
+
if (typeof first === "object" && first !== null && !Array.isArray(first)) {
|
|
522
|
+
const options$1 = first;
|
|
523
|
+
return (strings$1, ...interpolations) => {
|
|
524
|
+
return normaliseIndents(strings$1, ...interpolations, options$1);
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
const strings = first;
|
|
528
|
+
const options = typeof args[args.length - 1] === "object" && !Array.isArray(args[args.length - 1]) ? args.pop() : {};
|
|
529
|
+
return reduceLines$1(interpolate_default(strings, ...[...args]).split("\n"), options);
|
|
530
|
+
}
|
|
531
|
+
const normalizeIndents = normaliseIndents;
|
|
532
|
+
var normaliseIndents_default = normaliseIndents;
|
|
533
|
+
|
|
489
534
|
//#endregion
|
|
490
535
|
//#region src/functions/taggedTemplate/removeIndents.ts
|
|
491
536
|
function calculateTabSize(line, whitespaceLength) {
|
|
@@ -544,4 +589,4 @@ function wait(seconds) {
|
|
|
544
589
|
var wait_default = wait;
|
|
545
590
|
|
|
546
591
|
//#endregion
|
|
547
|
-
export { APIError_default as APIError, DataError_default as DataError, addDaysToDate_default as addDaysToDate, appendSemicolon_default as appendSemicolon, camelToKebab_default as camelToKebab, convertFileToBase64_default as convertFileToBase64, createFormData_default as createFormData, createTemplateStringsArray_default as createTemplateStringsArray, fillArray_default as fillArray, formatDateAndTime_default as formatDateAndTime, getRandomNumber_default as getRandomNumber, getRecordKeys_default as getRecordKeys, httpErrorCodeLookup, interpolate_default as interpolate, interpolateObjects_default as interpolateObjects, isAnniversary_default as isAnniversary, isLeapYear_default as isLeapYear, isMonthlyMultiple_default as isMonthlyMultiple, isOrdered_default as isOrdered, isSameDate_default as isSameDate, kebabToCamel_default as kebabToCamel, normaliseImportPath, normalizeImportPath_default as normalizeImportPath, omitProperties_default as omitProperties, paralleliseArrays_default as paralleliseArrays, parseBoolean_default as parseBoolean, Email_default as parseEmail, Env_default as parseEnv, parseFormData_default as parseFormData, parseIntStrict_default as parseIntStrict, UUID_default as parseUUID, parseZodSchema_default as parseZodSchema, randomiseArray_default as randomiseArray, range_default as range, removeDuplicates_default as removeDuplicates, removeIndents_default as removeIndents, stringListToArray_default as stringListToArray, stringToBoolean, truncate_default as truncate, wait_default as wait };
|
|
592
|
+
export { APIError_default as APIError, DataError_default as DataError, NAMESPACE_EXPORT_REGEX_default as NAMESPACE_EXPORT_REGEX, addDaysToDate_default as addDaysToDate, appendSemicolon_default as appendSemicolon, camelToKebab_default as camelToKebab, convertFileToBase64_default as convertFileToBase64, createFormData_default as createFormData, createTemplateStringsArray_default as createTemplateStringsArray, fillArray_default as fillArray, formatDateAndTime_default as formatDateAndTime, getRandomNumber_default as getRandomNumber, getRecordKeys_default as getRecordKeys, httpErrorCodeLookup, interpolate_default as interpolate, interpolateObjects_default as interpolateObjects, isAnniversary_default as isAnniversary, isLeapYear_default as isLeapYear, isMonthlyMultiple_default as isMonthlyMultiple, isOrdered_default as isOrdered, isSameDate_default as isSameDate, kebabToCamel_default as kebabToCamel, normaliseImportPath, normaliseIndents_default as normaliseIndents, normalizeImportPath_default as normalizeImportPath, normalizeIndents, omitProperties_default as omitProperties, paralleliseArrays_default as paralleliseArrays, parseBoolean_default as parseBoolean, Email_default as parseEmail, Env_default as parseEnv, parseFormData_default as parseFormData, parseIntStrict_default as parseIntStrict, UUID_default as parseUUID, parseZodSchema_default as parseZodSchema, randomiseArray_default as randomiseArray, range_default as range, removeDuplicates_default as removeDuplicates, removeIndents_default as removeIndents, stringListToArray_default as stringListToArray, stringToBoolean, truncate_default as truncate, wait_default as wait };
|