@alextheman/utility 2.17.0 → 2.18.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 CHANGED
@@ -75,6 +75,7 @@ __export(index_exports, {
75
75
  removeDuplicates: () => removeDuplicates_default,
76
76
  stringListToArray: () => stringListToArray_default,
77
77
  stringToBoolean: () => stringToBoolean_default,
78
+ stripIndents: () => stripIndents_default,
78
79
  truncate: () => truncate_default,
79
80
  wait: () => wait_default
80
81
  });
@@ -518,6 +519,31 @@ function interpolateObjects(strings, ...values) {
518
519
  }
519
520
  var interpolateObjects_default = interpolateObjects;
520
521
 
522
+ // src/functions/taggedTemplate/stripIndents.ts
523
+ function calculateTabSize(line) {
524
+ const defaultWhitespaceLength = 12;
525
+ const potentialWhitespacePart = line.slice(0, defaultWhitespaceLength);
526
+ const trimmedString = line.trim();
527
+ if (potentialWhitespacePart.trim() !== "") {
528
+ return 0;
529
+ }
530
+ const tabSize = line.length - (trimmedString.length + defaultWhitespaceLength);
531
+ return tabSize < 0 ? 0 : tabSize;
532
+ }
533
+ function reduceLines(lines) {
534
+ return lines.map((line) => {
535
+ const tabSize = calculateTabSize(line);
536
+ return fillArray_default(() => {
537
+ return " ";
538
+ }, tabSize).join("") + line.trim();
539
+ }).join("\n");
540
+ }
541
+ function stripIndents(strings, ...interpolations) {
542
+ const fullString = interpolate_default(strings, ...interpolations);
543
+ return reduceLines(fullString.split("\n"));
544
+ }
545
+ var stripIndents_default = stripIndents;
546
+
521
547
  // src/types/APIError.ts
522
548
  var httpErrorCodeLookup = {
523
549
  400: "BAD_REQUEST",
@@ -605,6 +631,7 @@ var UUID_default = parseUUID;
605
631
  removeDuplicates,
606
632
  stringListToArray,
607
633
  stringToBoolean,
634
+ stripIndents,
608
635
  truncate,
609
636
  wait
610
637
  });
package/dist/index.d.cts CHANGED
@@ -115,4 +115,6 @@ declare function interpolate(strings: TemplateStringsArray, ...interpolations: u
115
115
 
116
116
  declare function interpolateObjects(strings: TemplateStringsArray, ...values: unknown[]): string;
117
117
 
118
- export { APIError, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, type DisallowUndefined, type Email, type Env, type FormDataNullableResolutionStrategy as FormDataResolutionStrategy, type HTTPErrorCode, type HTTPErrorCodes, type IgnoreCase, type KebabToCamelOptions, type NonUndefined, type OptionalOnCondition, type RecordKey, type StringListToArrayOptions, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolate, interpolateObjects, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, omitProperties, paralleliseArrays, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringListToArray, stringToBoolean, truncate, wait };
118
+ declare function stripIndents(strings: TemplateStringsArray, ...interpolations: unknown[]): string;
119
+
120
+ export { APIError, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, type DisallowUndefined, type Email, type Env, type FormDataNullableResolutionStrategy as FormDataResolutionStrategy, type HTTPErrorCode, type HTTPErrorCodes, type IgnoreCase, type KebabToCamelOptions, type NonUndefined, type OptionalOnCondition, type RecordKey, type StringListToArrayOptions, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolate, interpolateObjects, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, omitProperties, paralleliseArrays, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringListToArray, stringToBoolean, stripIndents, truncate, wait };
package/dist/index.d.ts CHANGED
@@ -115,4 +115,6 @@ declare function interpolate(strings: TemplateStringsArray, ...interpolations: u
115
115
 
116
116
  declare function interpolateObjects(strings: TemplateStringsArray, ...values: unknown[]): string;
117
117
 
118
- export { APIError, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, type DisallowUndefined, type Email, type Env, type FormDataNullableResolutionStrategy as FormDataResolutionStrategy, type HTTPErrorCode, type HTTPErrorCodes, type IgnoreCase, type KebabToCamelOptions, type NonUndefined, type OptionalOnCondition, type RecordKey, type StringListToArrayOptions, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolate, interpolateObjects, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, omitProperties, paralleliseArrays, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringListToArray, stringToBoolean, truncate, wait };
118
+ declare function stripIndents(strings: TemplateStringsArray, ...interpolations: unknown[]): string;
119
+
120
+ export { APIError, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, type DisallowUndefined, type Email, type Env, type FormDataNullableResolutionStrategy as FormDataResolutionStrategy, type HTTPErrorCode, type HTTPErrorCodes, type IgnoreCase, type KebabToCamelOptions, type NonUndefined, type OptionalOnCondition, type RecordKey, type StringListToArrayOptions, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolate, interpolateObjects, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, omitProperties, paralleliseArrays, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringListToArray, stringToBoolean, stripIndents, truncate, wait };
package/dist/index.js CHANGED
@@ -454,6 +454,31 @@ function interpolateObjects(strings, ...values) {
454
454
  }
455
455
  var interpolateObjects_default = interpolateObjects;
456
456
 
457
+ // src/functions/taggedTemplate/stripIndents.ts
458
+ function calculateTabSize(line) {
459
+ const defaultWhitespaceLength = 12;
460
+ const potentialWhitespacePart = line.slice(0, defaultWhitespaceLength);
461
+ const trimmedString = line.trim();
462
+ if (potentialWhitespacePart.trim() !== "") {
463
+ return 0;
464
+ }
465
+ const tabSize = line.length - (trimmedString.length + defaultWhitespaceLength);
466
+ return tabSize < 0 ? 0 : tabSize;
467
+ }
468
+ function reduceLines(lines) {
469
+ return lines.map((line) => {
470
+ const tabSize = calculateTabSize(line);
471
+ return fillArray_default(() => {
472
+ return " ";
473
+ }, tabSize).join("") + line.trim();
474
+ }).join("\n");
475
+ }
476
+ function stripIndents(strings, ...interpolations) {
477
+ const fullString = interpolate_default(strings, ...interpolations);
478
+ return reduceLines(fullString.split("\n"));
479
+ }
480
+ var stripIndents_default = stripIndents;
481
+
457
482
  // src/types/APIError.ts
458
483
  var httpErrorCodeLookup = {
459
484
  400: "BAD_REQUEST",
@@ -540,6 +565,7 @@ export {
540
565
  removeDuplicates_default as removeDuplicates,
541
566
  stringListToArray_default as stringListToArray,
542
567
  stringToBoolean_default as stringToBoolean,
568
+ stripIndents_default as stripIndents,
543
569
  truncate_default as truncate,
544
570
  wait_default as wait
545
571
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/utility",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
4
4
  "description": "Helpful utility functions",
5
5
  "repository": {
6
6
  "type": "git",