typeshi 1.7.13 → 1.7.15

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.
@@ -19,12 +19,12 @@ export declare function autoFormatLogsOnExit(filePaths?: string[]): void;
19
19
  /**
20
20
  * Formats a debug log file from JSON format to a more readable text format.
21
21
  * Removes the numeric keys and properly handles escape sequences.
22
- * @param inputFilePath `string` - path to the input log file (e.g., DEBUG.txt)
23
- * @param outputFilePath `string` - optional, path to the output formatted file.
24
- * If not provided, will use inputFilePath with '.FORMATTED' inserted before the extension.
22
+ * @param inputPath `string` - path to the input log file (e.g., DEBUG.txt)
23
+ * @param outputPath `string` - optional, path to the output formatted file.
24
+ * If not provided, will use inputPath with '.FORMATTED' inserted before the extension.
25
25
  * @returns `void`
26
26
  */
27
- export declare function formatDebugLogFile(inputFilePath: string, outputFilePath?: string): void;
27
+ export declare function formatDebugLogFile(inputPath: string, outputPath?: string): void;
28
28
  /**
29
29
  * Formats all debug log files in the log directory.
30
30
  * Looks for .txt files and creates .FORMATTED.txt versions.
@@ -101,23 +101,23 @@ function autoFormatLogsOnExit(filePaths) {
101
101
  /**
102
102
  * Formats a debug log file from JSON format to a more readable text format.
103
103
  * Removes the numeric keys and properly handles escape sequences.
104
- * @param inputFilePath `string` - path to the input log file (e.g., DEBUG.txt)
105
- * @param outputFilePath `string` - optional, path to the output formatted file.
106
- * If not provided, will use inputFilePath with '.FORMATTED' inserted before the extension.
104
+ * @param inputPath `string` - path to the input log file (e.g., DEBUG.txt)
105
+ * @param outputPath `string` - optional, path to the output formatted file.
106
+ * If not provided, will use inputPath with '.FORMATTED' inserted before the extension.
107
107
  * @returns `void`
108
108
  */
109
- function formatDebugLogFile(inputFilePath, outputFilePath) {
110
- validate.existingPathArgument(`logging.formatDebugLogFile`, { inputFilePath });
109
+ function formatDebugLogFile(inputPath, outputPath) {
110
+ validate.existingPathArgument(`logging.formatDebugLogFile`, { inputPath });
111
111
  // Generate output path if not provided
112
- if (!outputFilePath) {
113
- const parsedPath = node_path_1.default.parse(inputFilePath);
114
- outputFilePath = node_path_1.default.join(parsedPath.dir, `${parsedPath.name}.FORMATTED${parsedPath.ext}`);
112
+ if (!outputPath) {
113
+ const parsedPath = node_path_1.default.parse(inputPath);
114
+ outputPath = node_path_1.default.join(parsedPath.dir, `${parsedPath.name}.FORMATTED${parsedPath.ext}`);
115
115
  }
116
116
  try {
117
- const fileContent = fs.readFileSync(inputFilePath, 'utf-8');
117
+ const fileContent = fs.readFileSync(inputPath, 'utf-8');
118
118
  const formattedContent = formatLogContent(fileContent);
119
- fs.writeFileSync(outputFilePath, formattedContent, { encoding: 'utf-8' });
120
- // mlog.info(`[formatDebugLogFile()] Formatted log file saved to '${outputFilePath}'`);
119
+ fs.writeFileSync(outputPath, formattedContent, { encoding: 'utf-8' });
120
+ // mlog.info(`[formatDebugLogFile()] Formatted log file saved to '${outputPath}'`);
121
121
  }
122
122
  catch (error) {
123
123
  setupLog_1.typeshiLogger.error('[formatDebugLogFile()] Error formatting log file:', error);
@@ -14,8 +14,9 @@ export declare function isFile(value: string): value is string;
14
14
  export declare function getDelimiterFromFilePath(filePath: string): DelimiterCharacterEnum | string;
15
15
  /**
16
16
  * @param filePath `string`
17
- * @returns **`jsonData`** — `Record<string, any>`
18
- * - JSON data as an object
17
+ * @returns **`jsonData`** — `T extends Record<string, any>` - JSON data as an object
18
+ * @note returns empty object if error occurred while reading `filepath` or parsing json
19
+ * - use {@link readJsonSyncOrThrow} if throwing error is desired behavior
19
20
  */
20
21
  export declare const readJsonSync: typeof readJsonFileAsObject;
21
22
  /**
@@ -109,8 +109,9 @@ function getDelimiterFromFilePath(filePath) {
109
109
  }
110
110
  /**
111
111
  * @param filePath `string`
112
- * @returns **`jsonData`** — `Record<string, any>`
113
- * - JSON data as an object
112
+ * @returns **`jsonData`** — `T extends Record<string, any>` - JSON data as an object
113
+ * @note returns empty object if error occurred while reading `filepath` or parsing json
114
+ * - use {@link readJsonSyncOrThrow} if throwing error is desired behavior
114
115
  */
115
116
  exports.readJsonSync = readJsonFileAsObject;
116
117
  /**
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @file src/utils/io/writing.ts
3
+ */
4
+ import * as fs from "node:fs";
1
5
  import { WriteJsonOptions } from "./types";
2
6
  /**
3
7
  * Output JSON data to a file with `fs.writeFileSync` or `fs.appendFileSync`.
@@ -21,17 +25,7 @@ export declare function writeObjectToJsonSync(options: WriteJsonOptions): void;
21
25
  */
22
26
  export declare function writeObjectToJsonSync(data: Record<string, any> | string, filePath: string, indent?: number, enableOverwrite?: boolean): void;
23
27
  export declare const writeJsonSync: typeof writeObjectToJsonSync;
24
- /**
25
- * @param data `Record<string, any> | string` - JSON data to stringify
26
- * @param indent `number` `optional`, default=`0` - number of additional indents to add to each line
27
- * @param spaces `number` `optional`, default=`4`
28
- * @returns **`jsonString`** `string`
29
- */
30
- export declare function indentedStringify(data: Record<string, any> | string, indent?: number, spaces?: number): string;
31
- /**
32
- * @returns **`timestamp`** `string` = `(${MM}-${DD})_(${HH}.${mm}.${ss}.${ms})`
33
- */
34
- export declare function getFileNameTimestamp(): string;
28
+ export declare const writeArraysToCsvSync: typeof writeListsToCsvSync;
35
29
  /**
36
30
  * @param listData `Record<string, Array<string>>` map col names to col values
37
31
  * @param outputPath `string`
@@ -39,6 +33,23 @@ export declare function getFileNameTimestamp(): string;
39
33
  * @param columnDelimiter `string` - optional, default=`''`
40
34
  */
41
35
  export declare function writeListsToCsvSync(listData: Record<string, Array<string>>, outputPath: string, delimiter?: string, columnDelimiter?: string): void;
36
+ /**
37
+ * @param arr `T[]`
38
+ * @param outputPath `string`
39
+ * @param separator `string` `default` = `'\n'`
40
+ * @param options {@link fs.WriteFileOptions} `default` = `{ encoding: 'utf-8', flag: 'w' }`
41
+ * - use `flag: 'a'` to append rather than overwrite
42
+ */
43
+ export declare function writeArrayToFileSync<T>(arr: T[], outputPath: string, separator?: string, options?: fs.WriteFileOptions): void;
44
+ /**
45
+ * @consideration maybe it would be better to have the delimiter be an explicit param rather
46
+ * than implicitly determined by `outputPath`
47
+ * - can write to `tsv` by having `outputPath` end with `'.tsv'`
48
+ * @param rows `Record<string, any>[]` - array of objects to write to CSV
49
+ * @param outputPath `string` - path to the output CSV file.
50
+ * @returns **`void`**
51
+ */
52
+ export declare function writeRowsToCsvSync(rows: Record<string, any>[], outputPath: string, headers?: string[]): void;
42
53
  /**
43
54
  * @TODO handle other file extensions
44
55
  * @param maxMB - Maximum size in MB to keep in the file, default is `5` -> 5MB.
@@ -57,11 +68,13 @@ export declare function clearFileSync(...filePaths: string[]): void;
57
68
  */
58
69
  export declare function clearFile(...filePaths: string[]): Promise<void>;
59
70
  /**
60
- * @consideration maybe it would be better to have the delimiter be an explicit param rather
61
- * than implicitly determined by `outputPath`
62
- * - can write to `tsv` by having `outputPath` end with `'.tsv'`
63
- * @param rows `Record<string, any>[]` - array of objects to write to CSV
64
- * @param outputPath `string` - path to the output CSV file.
65
- * @returns **`void`**
71
+ * @param data `Record<string, any> | string` - JSON data to stringify
72
+ * @param indent `number` `optional`, default=`0` - number of additional indents to add to each line
73
+ * @param spaces `number` `optional`, default=`4`
74
+ * @returns **`jsonString`** `string`
66
75
  */
67
- export declare function writeRowsToCsvSync(rows: Record<string, any>[], outputPath: string, headers?: string[]): void;
76
+ export declare function indentedStringify(data: Record<string, any> | string, indent?: number, spaces?: number): string;
77
+ /**
78
+ * @returns **`timestamp`** `string` = `(${MM}-${DD})_(${HH}.${mm}.${ss}.${ms})`
79
+ */
80
+ export declare function getFileNameTimestamp(): string;
@@ -33,27 +33,26 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.writeJsonSync = void 0;
36
+ exports.writeArraysToCsvSync = exports.writeJsonSync = void 0;
37
37
  exports.writeObjectToJsonSync = writeObjectToJsonSync;
38
- exports.indentedStringify = indentedStringify;
39
- exports.getFileNameTimestamp = getFileNameTimestamp;
40
38
  exports.writeListsToCsvSync = writeListsToCsvSync;
39
+ exports.writeArrayToFileSync = writeArrayToFileSync;
40
+ exports.writeRowsToCsvSync = writeRowsToCsvSync;
41
41
  exports.trimFileSync = trimFileSync;
42
42
  exports.trimFile = trimFile;
43
43
  exports.clearFileSync = clearFileSync;
44
44
  exports.clearFile = clearFile;
45
- exports.writeRowsToCsvSync = writeRowsToCsvSync;
45
+ exports.indentedStringify = indentedStringify;
46
+ exports.getFileNameTimestamp = getFileNameTimestamp;
46
47
  /**
47
48
  * @file src/utils/io/writing.ts
48
49
  */
49
- const fs = __importStar(require("fs"));
50
+ const fs = __importStar(require("node:fs"));
50
51
  const env_1 = require("../../config/env");
51
52
  const setupLog_1 = require("../../config/setupLog");
52
53
  const reading_1 = require("./reading");
53
54
  const types_1 = require("./types");
54
55
  const typeValidation_1 = require("../typeValidation");
55
- const validate = __importStar(require("../argumentValidation"));
56
- const fs_1 = require("fs");
57
56
  const logging_1 = require("./logging");
58
57
  function writeObjectToJsonSync(
59
58
  /** {@link WriteJsonOptions} `| Record<string, any> | string`, */
@@ -115,38 +114,7 @@ arg1, filePath, indent = 4, enableOverwrite = true) {
115
114
  }
116
115
  }
117
116
  exports.writeJsonSync = writeObjectToJsonSync;
118
- /**
119
- * @param data `Record<string, any> | string` - JSON data to stringify
120
- * @param indent `number` `optional`, default=`0` - number of additional indents to add to each line
121
- * @param spaces `number` `optional`, default=`4`
122
- * @returns **`jsonString`** `string`
123
- */
124
- function indentedStringify(data, indent = 0, spaces = 4) {
125
- if (!data) {
126
- return '';
127
- }
128
- let jsonString = typeof data === 'string'
129
- ? data : JSON.stringify(data, null, spaces);
130
- jsonString = jsonString
131
- .split('\n')
132
- .map(line => setupLog_1.INDENT_LOG_LINE + '\t'.repeat(indent) + line)
133
- .join('')
134
- .replace(/^\n\t. /, '').replace(/•/g, '');
135
- return jsonString;
136
- }
137
- /**
138
- * @returns **`timestamp`** `string` = `(${MM}-${DD})_(${HH}.${mm}.${ss}.${ms})`
139
- */
140
- function getFileNameTimestamp() {
141
- const now = new Date();
142
- const MM = String(now.getMonth() + 1).padStart(2, '0');
143
- const DD = String(now.getDate()).padStart(2, '0');
144
- const HH = String(now.getHours()).padStart(2, '0');
145
- const mm = String(now.getMinutes()).padStart(2, '0');
146
- const ss = String(now.getSeconds()).padStart(2, '0');
147
- const ms = String(now.getMilliseconds()).padStart(3, '0');
148
- return `(${MM}-${DD})_(${HH}.${mm}.${ss}.${ms})`;
149
- }
117
+ exports.writeArraysToCsvSync = writeListsToCsvSync;
150
118
  /**
151
119
  * @param listData `Record<string, Array<string>>` map col names to col values
152
120
  * @param outputPath `string`
@@ -173,6 +141,56 @@ function writeListsToCsvSync(listData, outputPath, delimiter = types_1.Delimiter
173
141
  setupLog_1.typeshiLogger.info(`CSV file has been saved to ${outputPath}`);
174
142
  });
175
143
  }
144
+ /**
145
+ * @param arr `T[]`
146
+ * @param outputPath `string`
147
+ * @param separator `string` `default` = `'\n'`
148
+ * @param options {@link fs.WriteFileOptions} `default` = `{ encoding: 'utf-8', flag: 'w' }`
149
+ * - use `flag: 'a'` to append rather than overwrite
150
+ */
151
+ function writeArrayToFileSync(arr, outputPath, separator = '\n', options = { encoding: 'utf-8', flag: 'w' }) {
152
+ const source = (0, logging_1.getSourceString)(__filename, writeArrayToFileSync.name);
153
+ try {
154
+ const content = arr.map(el => JSON.stringify(el)).join(separator);
155
+ fs.writeFileSync(outputPath, content, options);
156
+ }
157
+ catch (error) {
158
+ setupLog_1.typeshiLogger.error([`${source} Error writing array to file`,
159
+ `intended outputPath: '${outputPath}'`,
160
+ `caught error: ${error}`
161
+ ].join(setupLog_1.INDENT_LOG_LINE));
162
+ }
163
+ return;
164
+ }
165
+ /**
166
+ * @consideration maybe it would be better to have the delimiter be an explicit param rather
167
+ * than implicitly determined by `outputPath`
168
+ * - can write to `tsv` by having `outputPath` end with `'.tsv'`
169
+ * @param rows `Record<string, any>[]` - array of objects to write to CSV
170
+ * @param outputPath `string` - path to the output CSV file.
171
+ * @returns **`void`**
172
+ */
173
+ function writeRowsToCsvSync(rows, outputPath, headers) {
174
+ const source = (0, logging_1.getSourceString)(__filename, writeRowsToCsvSync.name);
175
+ try {
176
+ const delimiter = (0, reading_1.getDelimiterFromFilePath)(outputPath);
177
+ if (!(0, typeValidation_1.isStringArray)(headers)) {
178
+ headers = Array.from(new Set(rows.map(r => Object.keys(r)).flat()));
179
+ }
180
+ if ((0, typeValidation_1.isEmptyArray)(headers)) {
181
+ setupLog_1.typeshiLogger.error([`${source} No headers found in rows, nothing to write.`,
182
+ `Intended outputPath: '${outputPath}'`,
183
+ ].join(setupLog_1.INDENT_LOG_LINE));
184
+ return;
185
+ }
186
+ const csvContent = [headers.join(delimiter)].concat(rows.map(row => (headers ?? []).map(h => row[h] ?? '').join(delimiter))).join('\n');
187
+ fs.writeFileSync(outputPath, csvContent, { encoding: 'utf-8' });
188
+ setupLog_1.typeshiLogger.info(`${source} file has been saved to '${outputPath}'`);
189
+ }
190
+ catch (error) {
191
+ setupLog_1.typeshiLogger.error(`${source} Error writing to CSV file`, error);
192
+ }
193
+ }
176
194
  /**
177
195
  * @TODO handle other file extensions
178
196
  * @param maxMB - Maximum size in MB to keep in the file, default is `5` -> 5MB.
@@ -241,19 +259,19 @@ async function trimFile(maxMB = 5, ...filePaths) {
241
259
  */
242
260
  function clearFileSync(...filePaths) {
243
261
  for (const filePath of filePaths) {
244
- if (!filePath || !(0, fs_1.existsSync)(filePath)) {
262
+ if (!filePath || !fs.existsSync(filePath)) {
245
263
  setupLog_1.typeshiLogger.warn(`clearFileSync() Log file does not exist: ${filePath}`);
246
264
  continue;
247
265
  }
248
266
  try {
249
- (0, fs_1.writeFileSync)(filePath, '', { encoding: 'utf-8', flag: 'w' });
267
+ fs.writeFileSync(filePath, '', { encoding: 'utf-8', flag: 'w' });
250
268
  }
251
269
  catch (error) {
252
270
  if (error.code === 'EBUSY' || error.code === 'EMFILE') {
253
271
  // File is busy, try again after a short delay
254
272
  setTimeout(() => {
255
273
  try {
256
- (0, fs_1.writeFileSync)(filePath, '', { encoding: 'utf-8', flag: 'w' });
274
+ fs.writeFileSync(filePath, '', { encoding: 'utf-8', flag: 'w' });
257
275
  }
258
276
  catch (retryError) {
259
277
  setupLog_1.typeshiLogger.warn(`clearFileSync() Failed to clear file after retry: ${filePath}`, retryError);
@@ -272,14 +290,14 @@ function clearFileSync(...filePaths) {
272
290
  */
273
291
  async function clearFile(...filePaths) {
274
292
  const promises = filePaths.map(async (filePath) => {
275
- if (!filePath || !(0, fs_1.existsSync)(filePath)) {
293
+ if (!filePath || !fs.existsSync(filePath)) {
276
294
  setupLog_1.typeshiLogger.warn(`clearFile() Log file does not exist: ${filePath}`);
277
295
  return;
278
296
  }
279
297
  return new Promise((resolve, reject) => {
280
298
  const tryWrite = (attempt = 1) => {
281
299
  try {
282
- (0, fs_1.writeFileSync)(filePath, '', { encoding: 'utf-8', flag: 'w' });
300
+ fs.writeFileSync(filePath, '', { encoding: 'utf-8', flag: 'w' });
283
301
  resolve();
284
302
  }
285
303
  catch (error) {
@@ -299,34 +317,34 @@ async function clearFile(...filePaths) {
299
317
  await (0, env_1.DELAY)(1000, ` > [clearFile()] Releasing file handles...`);
300
318
  }
301
319
  /**
302
- * @consideration maybe it would be better to have the delimiter be an explicit param rather
303
- * than implicitly determined by `outputPath`
304
- * - can write to `tsv` by having `outputPath` end with `'.tsv'`
305
- * @param rows `Record<string, any>[]` - array of objects to write to CSV
306
- * @param outputPath `string` - path to the output CSV file.
307
- * @returns **`void`**
320
+ * @param data `Record<string, any> | string` - JSON data to stringify
321
+ * @param indent `number` `optional`, default=`0` - number of additional indents to add to each line
322
+ * @param spaces `number` `optional`, default=`4`
323
+ * @returns **`jsonString`** `string`
308
324
  */
309
- function writeRowsToCsvSync(rows, outputPath, headers) {
310
- const source = (0, logging_1.getSourceString)(__filename, writeRowsToCsvSync.name);
311
- validate.arrayArgument(source, { rows });
312
- validate.stringArgument(source, { outputPath });
313
- const delimiter = (0, reading_1.getDelimiterFromFilePath)(outputPath);
314
- if (!(0, typeValidation_1.isStringArray)(headers)) {
315
- headers = Array.from(new Set(rows.map(r => Object.keys(r)).flat()));
316
- }
317
- if ((0, typeValidation_1.isEmptyArray)(headers)) {
318
- setupLog_1.typeshiLogger.error([`${source} No headers found in rows, nothing to write.`,
319
- `Intended outputPath: '${outputPath}'`,
320
- ].join(setupLog_1.INDENT_LOG_LINE));
321
- return;
322
- }
323
- const csvContent = [headers.join(delimiter)].concat(rows.map(row => headers.map(h => row[h] ?? '').join(delimiter))).join('\n');
324
- try {
325
- fs.writeFileSync(outputPath, csvContent, { encoding: 'utf-8' });
326
- setupLog_1.typeshiLogger.info(`${source} file has been saved to '${outputPath}'`);
327
- }
328
- catch (e) {
329
- setupLog_1.typeshiLogger.error('[writeRowsToCsv()] Error writing to CSV file', e);
330
- throw e;
325
+ function indentedStringify(data, indent = 0, spaces = 4) {
326
+ if (!data) {
327
+ return '';
331
328
  }
329
+ let jsonString = typeof data === 'string'
330
+ ? data : JSON.stringify(data, null, spaces);
331
+ jsonString = jsonString
332
+ .split('\n')
333
+ .map(line => setupLog_1.INDENT_LOG_LINE + '\t'.repeat(indent) + line)
334
+ .join('')
335
+ .replace(/^\n\t. /, '').replace(/•/g, '');
336
+ return jsonString;
337
+ }
338
+ /**
339
+ * @returns **`timestamp`** `string` = `(${MM}-${DD})_(${HH}.${mm}.${ss}.${ms})`
340
+ */
341
+ function getFileNameTimestamp() {
342
+ const now = new Date();
343
+ const MM = String(now.getMonth() + 1).padStart(2, '0');
344
+ const DD = String(now.getDate()).padStart(2, '0');
345
+ const HH = String(now.getHours()).padStart(2, '0');
346
+ const mm = String(now.getMinutes()).padStart(2, '0');
347
+ const ss = String(now.getSeconds()).padStart(2, '0');
348
+ const ms = String(now.getMilliseconds()).padStart(3, '0');
349
+ return `(${MM}-${DD})_(${HH}.${mm}.${ss}.${ms})`;
332
350
  }
@@ -40,14 +40,14 @@ export declare function stringContainsAnyOf(s: string, substrings: string | stri
40
40
  * - **`false`** `otherwise`.
41
41
  */
42
42
  export declare function equivalentAlphanumericStrings(s1: string, s2: string, tolerance?: number): boolean;
43
- export declare class StringOperation {
43
+ export declare namespace Str {
44
44
  /**
45
45
  * @param s `string`
46
46
  * @param prefixes `string | string[] | RegExp` possible starting string(s).
47
47
  * @param flags `RegExpFlagsEnum[] (Optional)` regex flags to use when creating the {@link RegExp} object. see {@link RegExpFlagsEnum}
48
48
  * @returns **`true`** if the string starts with any of the prefixes, **`false`** otherwise.
49
49
  */
50
- static startsWith: typeof stringStartsWithAnyOf;
50
+ const startsWith: typeof stringStartsWithAnyOf;
51
51
  /**
52
52
  * Checks if a string ends with any of the specified suffixes.
53
53
  * @param s `string`
@@ -55,14 +55,14 @@ export declare class StringOperation {
55
55
  * @param flags `RegExpFlagsEnum[] (Optional)` regex flags to use when creating the {@link RegExp} object. see {@link RegExpFlagsEnum}
56
56
  * @returns **`true`** if the string ends with any of the suffixes, **`false`** otherwise.
57
57
  */
58
- static endsWith: typeof stringEndsWithAnyOf;
58
+ const endsWith: typeof stringEndsWithAnyOf;
59
59
  /**
60
- * @param s `string` to check.
61
- * @param substrings `string | string[] | RegExp`.
60
+ * @param s `string`
61
+ * @param substrings `string | string[] | RegExp`
62
62
  * @param flags `RegExpFlagsEnum[] (Optional)` regex flags to use when creating the {@link RegExp} object. see {@link RegExpFlagsEnum}
63
63
  * @returns **`true`** if the string contains any of the substrings, **`false`** otherwise.
64
64
  */
65
- static contains: typeof stringContainsAnyOf;
65
+ const contains: typeof stringContainsAnyOf;
66
66
  /**
67
67
  * Ignores case by default:
68
68
  * - converts `s1` & `s2` to lowercase and removes all non-alphanumeric characters from both strings,
@@ -75,7 +75,7 @@ export declare class StringOperation {
75
75
  * - **`true`** `if` the two alphanumeric strings are equivalent,
76
76
  * - **`false`** `otherwise`.
77
77
  */
78
- static equivalentAlphanumeric: typeof equivalentAlphanumericStrings;
78
+ const equivalentAlphanumeric: typeof equivalentAlphanumericStrings;
79
79
  }
80
80
  /** for simple regular expressions...
81
81
  * so like not ones that have parentheses, pipes, or curly braced numbers */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StringOperation = void 0;
3
+ exports.Str = void 0;
4
4
  exports.stringEndsWithAnyOf = stringEndsWithAnyOf;
5
5
  exports.stringStartsWithAnyOf = stringStartsWithAnyOf;
6
6
  exports.stringContainsAnyOf = stringContainsAnyOf;
@@ -173,44 +173,44 @@ function equivalentAlphanumericStrings(s1, s2, tolerance = 0.90) {
173
173
  }
174
174
  return false;
175
175
  }
176
- class StringOperation {
177
- }
178
- exports.StringOperation = StringOperation;
179
- /**
180
- * @param s `string`
181
- * @param prefixes `string | string[] | RegExp` possible starting string(s).
182
- * @param flags `RegExpFlagsEnum[] (Optional)` regex flags to use when creating the {@link RegExp} object. see {@link RegExpFlagsEnum}
183
- * @returns **`true`** if the string starts with any of the prefixes, **`false`** otherwise.
184
- */
185
- StringOperation.startsWith = stringStartsWithAnyOf;
186
- /**
187
- * Checks if a string ends with any of the specified suffixes.
188
- * @param s `string`
189
- * @param suffixes `string | string[] | RegExp` possible ending strings.
190
- * @param flags `RegExpFlagsEnum[] (Optional)` regex flags to use when creating the {@link RegExp} object. see {@link RegExpFlagsEnum}
191
- * @returns **`true`** if the string ends with any of the suffixes, **`false`** otherwise.
192
- */
193
- StringOperation.endsWith = stringEndsWithAnyOf;
194
- /**
195
- * @param s `string` to check.
196
- * @param substrings `string | string[] | RegExp`.
197
- * @param flags `RegExpFlagsEnum[] (Optional)` regex flags to use when creating the {@link RegExp} object. see {@link RegExpFlagsEnum}
198
- * @returns **`true`** if the string contains any of the substrings, **`false`** otherwise.
199
- */
200
- StringOperation.contains = stringContainsAnyOf;
201
- /**
202
- * Ignores case by default:
203
- * - converts `s1` & `s2` to lowercase and removes all non-alphanumeric characters from both strings,
204
- * - sorts the characters in both strings,
205
- * - then compares the two strings for equivalence.
206
- * @param s1 `string`
207
- * @param s2 `string`
208
- * @param tolerance `number` - a number between 0 and 1, default is `0.90`
209
- * @returns **`boolean`**
210
- * - **`true`** `if` the two alphanumeric strings are equivalent,
211
- * - **`false`** `otherwise`.
212
- */
213
- StringOperation.equivalentAlphanumeric = equivalentAlphanumericStrings;
176
+ var Str;
177
+ (function (Str) {
178
+ /**
179
+ * @param s `string`
180
+ * @param prefixes `string | string[] | RegExp` possible starting string(s).
181
+ * @param flags `RegExpFlagsEnum[] (Optional)` regex flags to use when creating the {@link RegExp} object. see {@link RegExpFlagsEnum}
182
+ * @returns **`true`** if the string starts with any of the prefixes, **`false`** otherwise.
183
+ */
184
+ Str.startsWith = stringStartsWithAnyOf;
185
+ /**
186
+ * Checks if a string ends with any of the specified suffixes.
187
+ * @param s `string`
188
+ * @param suffixes `string | string[] | RegExp` possible ending strings.
189
+ * @param flags `RegExpFlagsEnum[] (Optional)` regex flags to use when creating the {@link RegExp} object. see {@link RegExpFlagsEnum}
190
+ * @returns **`true`** if the string ends with any of the suffixes, **`false`** otherwise.
191
+ */
192
+ Str.endsWith = stringEndsWithAnyOf;
193
+ /**
194
+ * @param s `string`
195
+ * @param substrings `string | string[] | RegExp`
196
+ * @param flags `RegExpFlagsEnum[] (Optional)` regex flags to use when creating the {@link RegExp} object. see {@link RegExpFlagsEnum}
197
+ * @returns **`true`** if the string contains any of the substrings, **`false`** otherwise.
198
+ */
199
+ Str.contains = stringContainsAnyOf;
200
+ /**
201
+ * Ignores case by default:
202
+ * - converts `s1` & `s2` to lowercase and removes all non-alphanumeric characters from both strings,
203
+ * - sorts the characters in both strings,
204
+ * - then compares the two strings for equivalence.
205
+ * @param s1 `string`
206
+ * @param s2 `string`
207
+ * @param tolerance `number` - a number between 0 and 1, default is `0.90`
208
+ * @returns **`boolean`**
209
+ * - **`true`** `if` the two alphanumeric strings are equivalent,
210
+ * - **`false`** `otherwise`.
211
+ */
212
+ Str.equivalentAlphanumeric = equivalentAlphanumericStrings;
213
+ })(Str || (exports.Str = Str = {}));
214
214
  /** for simple regular expressions...
215
215
  * so like not ones that have parentheses, pipes, or curly braced numbers */
216
216
  function extractSource(regex) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typeshi",
3
- "version": "1.7.13",
3
+ "version": "1.7.15",
4
4
  "description": "TypeScript utility modules",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",