@alextheman/utility 2.1.1 → 2.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 +22 -0
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +20 -0
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -48,6 +48,7 @@ __export(index_exports, {
|
|
|
48
48
|
APIError: () => APIError_default,
|
|
49
49
|
addDaysToDate: () => addDaysToDate_default,
|
|
50
50
|
appendSemicolon: () => appendSemicolon_default,
|
|
51
|
+
camelToKebab: () => camelToKebab_default,
|
|
51
52
|
convertFileToBase64: () => convertFileToBase64_default,
|
|
52
53
|
fillArray: () => fillArray_default,
|
|
53
54
|
formatDateAndTime: () => formatDateAndTime_default,
|
|
@@ -64,6 +65,7 @@ __export(index_exports, {
|
|
|
64
65
|
parseUUID: () => UUID_default,
|
|
65
66
|
randomiseArray: () => randomiseArray_default,
|
|
66
67
|
range: () => range_default,
|
|
68
|
+
removeDuplicates: () => removeDuplicates_default,
|
|
67
69
|
stringToBoolean: () => stringToBoolean_default,
|
|
68
70
|
truncate: () => truncate_default,
|
|
69
71
|
wait: () => wait_default
|
|
@@ -91,6 +93,12 @@ function appendSemicolon(stringToAppendTo) {
|
|
|
91
93
|
}
|
|
92
94
|
var appendSemicolon_default = appendSemicolon;
|
|
93
95
|
|
|
96
|
+
// src/functions/camelToKebab.ts
|
|
97
|
+
function camelToKebab(string) {
|
|
98
|
+
return string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").toLowerCase();
|
|
99
|
+
}
|
|
100
|
+
var camelToKebab_default = camelToKebab;
|
|
101
|
+
|
|
94
102
|
// src/functions/convertFileToBase64.ts
|
|
95
103
|
function convertFileToBase64(file) {
|
|
96
104
|
return new Promise((resolve, reject) => {
|
|
@@ -275,6 +283,18 @@ function range(start, stop, step = 1) {
|
|
|
275
283
|
}
|
|
276
284
|
var range_default = range;
|
|
277
285
|
|
|
286
|
+
// src/functions/removeDuplicates.ts
|
|
287
|
+
function removeDuplicates(array) {
|
|
288
|
+
const outputArray = [];
|
|
289
|
+
for (const item of array) {
|
|
290
|
+
if (!outputArray.includes(item)) {
|
|
291
|
+
outputArray.push(item);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return outputArray;
|
|
295
|
+
}
|
|
296
|
+
var removeDuplicates_default = removeDuplicates;
|
|
297
|
+
|
|
278
298
|
// src/functions/stringToBoolean.ts
|
|
279
299
|
function stringToBoolean(inputString) {
|
|
280
300
|
const normalisedString = inputString.toLowerCase();
|
|
@@ -374,6 +394,7 @@ var UUID_default = parseUUID;
|
|
|
374
394
|
APIError,
|
|
375
395
|
addDaysToDate,
|
|
376
396
|
appendSemicolon,
|
|
397
|
+
camelToKebab,
|
|
377
398
|
convertFileToBase64,
|
|
378
399
|
fillArray,
|
|
379
400
|
formatDateAndTime,
|
|
@@ -390,6 +411,7 @@ var UUID_default = parseUUID;
|
|
|
390
411
|
parseUUID,
|
|
391
412
|
randomiseArray,
|
|
392
413
|
range,
|
|
414
|
+
removeDuplicates,
|
|
393
415
|
stringToBoolean,
|
|
394
416
|
truncate,
|
|
395
417
|
wait
|
package/dist/index.d.cts
CHANGED
|
@@ -4,6 +4,8 @@ declare function addDaysToDate(currentDate?: Date, dayIncrement?: number): Date;
|
|
|
4
4
|
|
|
5
5
|
declare function appendSemicolon(stringToAppendTo: string): string;
|
|
6
6
|
|
|
7
|
+
declare function camelToKebab(string: string): string;
|
|
8
|
+
|
|
7
9
|
declare function convertFileToBase64(file: File): Promise<string>;
|
|
8
10
|
|
|
9
11
|
declare function fillArray<T>(callback: (index: number) => T | Promise<T>, length?: number): T[] | Promise<T[]>;
|
|
@@ -26,6 +28,8 @@ declare function randomiseArray<T>(array: T[]): T[];
|
|
|
26
28
|
|
|
27
29
|
declare function range(start: number, stop: number, step?: number): number[];
|
|
28
30
|
|
|
31
|
+
declare function removeDuplicates<T>(array: T[]): T[];
|
|
32
|
+
|
|
29
33
|
declare function stringToBoolean(inputString: string): boolean;
|
|
30
34
|
|
|
31
35
|
declare function truncate(stringToTruncate: string, maxLength?: number): string;
|
|
@@ -62,4 +66,4 @@ type DisallowUndefined<T> = undefined extends T ? ["Error: Generic type cannot i
|
|
|
62
66
|
|
|
63
67
|
type NonUndefined<T> = T extends undefined ? never : T;
|
|
64
68
|
|
|
65
|
-
export { APIError, type DisallowUndefined, type Email, type Env, type HTTPErrorCodes, type NonUndefined, type UUID, addDaysToDate, appendSemicolon, convertFileToBase64, fillArray, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isSameDate, omitProperties, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, stringToBoolean, truncate, wait };
|
|
69
|
+
export { APIError, type DisallowUndefined, type Email, type Env, type HTTPErrorCodes, type NonUndefined, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, fillArray, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isSameDate, omitProperties, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringToBoolean, truncate, wait };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ declare function addDaysToDate(currentDate?: Date, dayIncrement?: number): Date;
|
|
|
4
4
|
|
|
5
5
|
declare function appendSemicolon(stringToAppendTo: string): string;
|
|
6
6
|
|
|
7
|
+
declare function camelToKebab(string: string): string;
|
|
8
|
+
|
|
7
9
|
declare function convertFileToBase64(file: File): Promise<string>;
|
|
8
10
|
|
|
9
11
|
declare function fillArray<T>(callback: (index: number) => T | Promise<T>, length?: number): T[] | Promise<T[]>;
|
|
@@ -26,6 +28,8 @@ declare function randomiseArray<T>(array: T[]): T[];
|
|
|
26
28
|
|
|
27
29
|
declare function range(start: number, stop: number, step?: number): number[];
|
|
28
30
|
|
|
31
|
+
declare function removeDuplicates<T>(array: T[]): T[];
|
|
32
|
+
|
|
29
33
|
declare function stringToBoolean(inputString: string): boolean;
|
|
30
34
|
|
|
31
35
|
declare function truncate(stringToTruncate: string, maxLength?: number): string;
|
|
@@ -62,4 +66,4 @@ type DisallowUndefined<T> = undefined extends T ? ["Error: Generic type cannot i
|
|
|
62
66
|
|
|
63
67
|
type NonUndefined<T> = T extends undefined ? never : T;
|
|
64
68
|
|
|
65
|
-
export { APIError, type DisallowUndefined, type Email, type Env, type HTTPErrorCodes, type NonUndefined, type UUID, addDaysToDate, appendSemicolon, convertFileToBase64, fillArray, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isSameDate, omitProperties, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, stringToBoolean, truncate, wait };
|
|
69
|
+
export { APIError, type DisallowUndefined, type Email, type Env, type HTTPErrorCodes, type NonUndefined, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, fillArray, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isSameDate, omitProperties, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringToBoolean, truncate, wait };
|
package/dist/index.js
CHANGED
|
@@ -37,6 +37,12 @@ function appendSemicolon(stringToAppendTo) {
|
|
|
37
37
|
}
|
|
38
38
|
var appendSemicolon_default = appendSemicolon;
|
|
39
39
|
|
|
40
|
+
// src/functions/camelToKebab.ts
|
|
41
|
+
function camelToKebab(string) {
|
|
42
|
+
return string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").toLowerCase();
|
|
43
|
+
}
|
|
44
|
+
var camelToKebab_default = camelToKebab;
|
|
45
|
+
|
|
40
46
|
// src/functions/convertFileToBase64.ts
|
|
41
47
|
function convertFileToBase64(file) {
|
|
42
48
|
return new Promise((resolve, reject) => {
|
|
@@ -221,6 +227,18 @@ function range(start, stop, step = 1) {
|
|
|
221
227
|
}
|
|
222
228
|
var range_default = range;
|
|
223
229
|
|
|
230
|
+
// src/functions/removeDuplicates.ts
|
|
231
|
+
function removeDuplicates(array) {
|
|
232
|
+
const outputArray = [];
|
|
233
|
+
for (const item of array) {
|
|
234
|
+
if (!outputArray.includes(item)) {
|
|
235
|
+
outputArray.push(item);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return outputArray;
|
|
239
|
+
}
|
|
240
|
+
var removeDuplicates_default = removeDuplicates;
|
|
241
|
+
|
|
224
242
|
// src/functions/stringToBoolean.ts
|
|
225
243
|
function stringToBoolean(inputString) {
|
|
226
244
|
const normalisedString = inputString.toLowerCase();
|
|
@@ -319,6 +337,7 @@ export {
|
|
|
319
337
|
APIError_default as APIError,
|
|
320
338
|
addDaysToDate_default as addDaysToDate,
|
|
321
339
|
appendSemicolon_default as appendSemicolon,
|
|
340
|
+
camelToKebab_default as camelToKebab,
|
|
322
341
|
convertFileToBase64_default as convertFileToBase64,
|
|
323
342
|
fillArray_default as fillArray,
|
|
324
343
|
formatDateAndTime_default as formatDateAndTime,
|
|
@@ -335,6 +354,7 @@ export {
|
|
|
335
354
|
UUID_default as parseUUID,
|
|
336
355
|
randomiseArray_default as randomiseArray,
|
|
337
356
|
range_default as range,
|
|
357
|
+
removeDuplicates_default as removeDuplicates,
|
|
338
358
|
stringToBoolean_default as stringToBoolean,
|
|
339
359
|
truncate_default as truncate,
|
|
340
360
|
wait_default as wait
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/utility",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Helpful utility functions",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "alextheman",
|
|
@@ -36,20 +36,20 @@
|
|
|
36
36
|
"zod": "^4.1.12"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@alextheman/eslint-plugin": "^
|
|
39
|
+
"@alextheman/eslint-plugin": "^2.2.1",
|
|
40
40
|
"@eslint/js": "^9.38.0",
|
|
41
|
-
"@types/node": "^24.
|
|
41
|
+
"@types/node": "^24.9.1",
|
|
42
42
|
"eslint": "^9.38.0",
|
|
43
43
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
44
44
|
"eslint-plugin-import": "^2.32.0",
|
|
45
45
|
"globals": "^16.4.0",
|
|
46
46
|
"husky": "^9.1.7",
|
|
47
|
-
"jsdom": "^27.0.
|
|
47
|
+
"jsdom": "^27.0.1",
|
|
48
48
|
"prettier": "^3.6.2",
|
|
49
49
|
"tsup": "^8.5.0",
|
|
50
50
|
"typescript": "^5.9.3",
|
|
51
|
-
"typescript-eslint": "^8.46.
|
|
51
|
+
"typescript-eslint": "^8.46.2",
|
|
52
52
|
"vite-tsconfig-paths": "^5.1.4",
|
|
53
|
-
"vitest": "^
|
|
53
|
+
"vitest": "^4.0.3"
|
|
54
54
|
}
|
|
55
55
|
}
|