@alextheman/utility 1.9.0 → 1.9.2
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 +112 -44
- package/dist/index.d.cts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +109 -44
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -22,8 +22,11 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
addDaysToDate: () => add_days_to_date_default,
|
|
24
24
|
appendSemicolon: () => append_semicolon_default,
|
|
25
|
+
convertFileToBase64: () => convert_file_to_base_64_default,
|
|
25
26
|
formatDateAndTime: () => format_date_and_time_default,
|
|
26
27
|
getRandomNumber: () => get_random_number_default,
|
|
28
|
+
isMonthlyMultiple: () => is_monthly_multiple_default,
|
|
29
|
+
isSameDate: () => is_same_date_default,
|
|
27
30
|
randomiseArray: () => randomise_array_default,
|
|
28
31
|
range: () => range_default,
|
|
29
32
|
truncate: () => truncate_default,
|
|
@@ -31,37 +34,6 @@ __export(index_exports, {
|
|
|
31
34
|
});
|
|
32
35
|
module.exports = __toCommonJS(index_exports);
|
|
33
36
|
|
|
34
|
-
// src/get-random-number.ts
|
|
35
|
-
function getRandomNumber(lowerBound, upperBound) {
|
|
36
|
-
if (lowerBound % 1 !== 0 || upperBound % 1 !== 0) {
|
|
37
|
-
throw new Error("NON_INTEGER_INPUTS");
|
|
38
|
-
}
|
|
39
|
-
return Math.floor(Math.random() * (upperBound - lowerBound + 1) + lowerBound);
|
|
40
|
-
}
|
|
41
|
-
var get_random_number_default = getRandomNumber;
|
|
42
|
-
|
|
43
|
-
// src/randomise-array.ts
|
|
44
|
-
function randomiseArray(array) {
|
|
45
|
-
const mutableArray = [...array];
|
|
46
|
-
const outputArray = [];
|
|
47
|
-
do {
|
|
48
|
-
const indexToRemove = get_random_number_default(0, mutableArray.length - 1);
|
|
49
|
-
outputArray.push(mutableArray.splice(indexToRemove, 1)[0]);
|
|
50
|
-
} while (mutableArray.length > 0);
|
|
51
|
-
return outputArray;
|
|
52
|
-
}
|
|
53
|
-
var randomise_array_default = randomiseArray;
|
|
54
|
-
|
|
55
|
-
// src/wait.ts
|
|
56
|
-
function wait(seconds) {
|
|
57
|
-
return new Promise((resolve, _) => {
|
|
58
|
-
setTimeout(() => {
|
|
59
|
-
resolve();
|
|
60
|
-
}, seconds * 1e3);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
var wait_default = wait;
|
|
64
|
-
|
|
65
37
|
// src/add-days-to-date.ts
|
|
66
38
|
function addDaysToDate(currentDate = /* @__PURE__ */ new Date(), dayIncrement = 1) {
|
|
67
39
|
const newDate = currentDate;
|
|
@@ -70,6 +42,38 @@ function addDaysToDate(currentDate = /* @__PURE__ */ new Date(), dayIncrement =
|
|
|
70
42
|
}
|
|
71
43
|
var add_days_to_date_default = addDaysToDate;
|
|
72
44
|
|
|
45
|
+
// src/append-semicolon.ts
|
|
46
|
+
function appendSemicolon(stringToAppendTo) {
|
|
47
|
+
if (stringToAppendTo.includes("\n")) {
|
|
48
|
+
throw new Error("MULTIPLE_LINE_ERROR");
|
|
49
|
+
}
|
|
50
|
+
const stringWithNoTrailingWhitespace = stringToAppendTo.trimEnd();
|
|
51
|
+
if (stringWithNoTrailingWhitespace === "") {
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
return stringWithNoTrailingWhitespace[stringWithNoTrailingWhitespace.length - 1] === ";" ? stringWithNoTrailingWhitespace : `${stringWithNoTrailingWhitespace};`;
|
|
55
|
+
}
|
|
56
|
+
var append_semicolon_default = appendSemicolon;
|
|
57
|
+
|
|
58
|
+
// src/convert-file-to-base-64.ts
|
|
59
|
+
function convertFileToBase64(file) {
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
const reader = new FileReader();
|
|
62
|
+
reader.readAsDataURL(file);
|
|
63
|
+
reader.onload = () => {
|
|
64
|
+
if (reader.result === null) {
|
|
65
|
+
reject(new Error("FILE_CONVERSION_ERROR"));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
resolve(reader.result);
|
|
69
|
+
};
|
|
70
|
+
reader.onerror = () => {
|
|
71
|
+
reject(new Error("FILE_READER_ERROR"));
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
var convert_file_to_base_64_default = convertFileToBase64;
|
|
76
|
+
|
|
73
77
|
// src/format-date-and-time.ts
|
|
74
78
|
function formatDateAndTime(inputDate) {
|
|
75
79
|
const yesterday = add_days_to_date_default(/* @__PURE__ */ new Date(), -1);
|
|
@@ -88,24 +92,69 @@ function formatDateAndTime(inputDate) {
|
|
|
88
92
|
}
|
|
89
93
|
var format_date_and_time_default = formatDateAndTime;
|
|
90
94
|
|
|
91
|
-
// src/
|
|
92
|
-
function
|
|
93
|
-
|
|
95
|
+
// src/get-random-number.ts
|
|
96
|
+
function getRandomNumber(lowerBound, upperBound) {
|
|
97
|
+
if (lowerBound % 1 !== 0 || upperBound % 1 !== 0) {
|
|
98
|
+
throw new Error("NON_INTEGER_INPUTS");
|
|
99
|
+
}
|
|
100
|
+
return Math.floor(Math.random() * (upperBound - lowerBound + 1) + lowerBound);
|
|
94
101
|
}
|
|
95
|
-
var
|
|
102
|
+
var get_random_number_default = getRandomNumber;
|
|
96
103
|
|
|
97
|
-
// src/
|
|
98
|
-
function
|
|
99
|
-
if (
|
|
100
|
-
|
|
104
|
+
// src/is-monthly-multiple.ts
|
|
105
|
+
function endOfMonthChecksButNotFebruary(firstDate, secondDate) {
|
|
106
|
+
if ([3, 5, 8, 10].includes(firstDate.getMonth())) {
|
|
107
|
+
return firstDate.getDate() === 30 && secondDate.getDate() === 31;
|
|
101
108
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
function nonLeapYearFebruaryChecks(firstDate, secondDate) {
|
|
112
|
+
if (firstDate.getMonth() === 1) {
|
|
113
|
+
if (firstDate.getFullYear() % 4 !== 0 && firstDate.getDate() === 28) {
|
|
114
|
+
return [28, 29, 30, 31].includes(secondDate.getDate());
|
|
115
|
+
}
|
|
105
116
|
}
|
|
106
|
-
return
|
|
117
|
+
return false;
|
|
107
118
|
}
|
|
108
|
-
|
|
119
|
+
function leapYearFebruaryChecks(firstDate, secondDate) {
|
|
120
|
+
if (firstDate.getMonth() === 1) {
|
|
121
|
+
if (firstDate.getFullYear() % 4 === 0 && firstDate.getDate() === 29) {
|
|
122
|
+
return [29, 30, 31].includes(secondDate.getDate());
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
function isMonthlyMultiple(firstDate, secondDate) {
|
|
128
|
+
if (endOfMonthChecksButNotFebruary(firstDate, secondDate) || endOfMonthChecksButNotFebruary(secondDate, firstDate)) {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
if (nonLeapYearFebruaryChecks(firstDate, secondDate) || nonLeapYearFebruaryChecks(secondDate, firstDate)) {
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
if (leapYearFebruaryChecks(firstDate, secondDate) || leapYearFebruaryChecks(secondDate, firstDate)) {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
return firstDate.getDate() === secondDate.getDate();
|
|
138
|
+
}
|
|
139
|
+
var is_monthly_multiple_default = isMonthlyMultiple;
|
|
140
|
+
|
|
141
|
+
// src/is-same-date.ts
|
|
142
|
+
function isSameDate(firstDate, secondDate) {
|
|
143
|
+
return firstDate.getDate() === secondDate.getDate() && firstDate.getMonth() === secondDate.getMonth() && firstDate.getFullYear() === secondDate.getFullYear();
|
|
144
|
+
}
|
|
145
|
+
var is_same_date_default = isSameDate;
|
|
146
|
+
|
|
147
|
+
// src/randomise-array.ts
|
|
148
|
+
function randomiseArray(array) {
|
|
149
|
+
const mutableArray = [...array];
|
|
150
|
+
const outputArray = [];
|
|
151
|
+
do {
|
|
152
|
+
const indexToRemove = get_random_number_default(0, mutableArray.length - 1);
|
|
153
|
+
outputArray.push(mutableArray.splice(indexToRemove, 1)[0]);
|
|
154
|
+
} while (mutableArray.length > 0);
|
|
155
|
+
return outputArray;
|
|
156
|
+
}
|
|
157
|
+
var randomise_array_default = randomiseArray;
|
|
109
158
|
|
|
110
159
|
// src/range.ts
|
|
111
160
|
function range(start, stop, step = 1) {
|
|
@@ -130,12 +179,31 @@ function range(start, stop, step = 1) {
|
|
|
130
179
|
return numbers;
|
|
131
180
|
}
|
|
132
181
|
var range_default = range;
|
|
182
|
+
|
|
183
|
+
// src/truncate.ts
|
|
184
|
+
function truncate(stringToTruncate, maxLength = 5) {
|
|
185
|
+
return stringToTruncate.length > maxLength ? `${stringToTruncate.slice(0, maxLength)}...` : stringToTruncate;
|
|
186
|
+
}
|
|
187
|
+
var truncate_default = truncate;
|
|
188
|
+
|
|
189
|
+
// src/wait.ts
|
|
190
|
+
function wait(seconds) {
|
|
191
|
+
return new Promise((resolve, _) => {
|
|
192
|
+
setTimeout(() => {
|
|
193
|
+
resolve();
|
|
194
|
+
}, seconds * 1e3);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
var wait_default = wait;
|
|
133
198
|
// Annotate the CommonJS export names for ESM import in node:
|
|
134
199
|
0 && (module.exports = {
|
|
135
200
|
addDaysToDate,
|
|
136
201
|
appendSemicolon,
|
|
202
|
+
convertFileToBase64,
|
|
137
203
|
formatDateAndTime,
|
|
138
204
|
getRandomNumber,
|
|
205
|
+
isMonthlyMultiple,
|
|
206
|
+
isSameDate,
|
|
139
207
|
randomiseArray,
|
|
140
208
|
range,
|
|
141
209
|
truncate,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
declare function
|
|
1
|
+
declare function addDaysToDate(currentDate?: Date, dayIncrement?: number): Date;
|
|
2
2
|
|
|
3
|
-
declare function
|
|
3
|
+
declare function appendSemicolon(stringToAppendTo: string): string;
|
|
4
4
|
|
|
5
|
-
declare function
|
|
5
|
+
declare function convertFileToBase64(file: File): Promise<string>;
|
|
6
6
|
|
|
7
7
|
declare function formatDateAndTime(inputDate: Date): string;
|
|
8
8
|
|
|
9
|
-
declare function
|
|
9
|
+
declare function getRandomNumber(lowerBound: number, upperBound: number): number;
|
|
10
10
|
|
|
11
|
-
declare function
|
|
11
|
+
declare function isMonthlyMultiple(firstDate: Date, secondDate: Date): boolean;
|
|
12
12
|
|
|
13
|
-
declare function
|
|
13
|
+
declare function isSameDate(firstDate: Date, secondDate: Date): boolean;
|
|
14
|
+
|
|
15
|
+
declare function randomiseArray(array: unknown[]): unknown[];
|
|
14
16
|
|
|
15
17
|
declare function range(start: number, stop: number, step?: number): number[];
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
declare function truncate(stringToTruncate: string, maxLength?: number): string;
|
|
20
|
+
|
|
21
|
+
declare function wait(seconds: number): Promise<void>;
|
|
22
|
+
|
|
23
|
+
export { addDaysToDate, appendSemicolon, convertFileToBase64, formatDateAndTime, getRandomNumber, isMonthlyMultiple, isSameDate, randomiseArray, range, truncate, wait };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
declare function
|
|
1
|
+
declare function addDaysToDate(currentDate?: Date, dayIncrement?: number): Date;
|
|
2
2
|
|
|
3
|
-
declare function
|
|
3
|
+
declare function appendSemicolon(stringToAppendTo: string): string;
|
|
4
4
|
|
|
5
|
-
declare function
|
|
5
|
+
declare function convertFileToBase64(file: File): Promise<string>;
|
|
6
6
|
|
|
7
7
|
declare function formatDateAndTime(inputDate: Date): string;
|
|
8
8
|
|
|
9
|
-
declare function
|
|
9
|
+
declare function getRandomNumber(lowerBound: number, upperBound: number): number;
|
|
10
10
|
|
|
11
|
-
declare function
|
|
11
|
+
declare function isMonthlyMultiple(firstDate: Date, secondDate: Date): boolean;
|
|
12
12
|
|
|
13
|
-
declare function
|
|
13
|
+
declare function isSameDate(firstDate: Date, secondDate: Date): boolean;
|
|
14
|
+
|
|
15
|
+
declare function randomiseArray(array: unknown[]): unknown[];
|
|
14
16
|
|
|
15
17
|
declare function range(start: number, stop: number, step?: number): number[];
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
declare function truncate(stringToTruncate: string, maxLength?: number): string;
|
|
20
|
+
|
|
21
|
+
declare function wait(seconds: number): Promise<void>;
|
|
22
|
+
|
|
23
|
+
export { addDaysToDate, appendSemicolon, convertFileToBase64, formatDateAndTime, getRandomNumber, isMonthlyMultiple, isSameDate, randomiseArray, range, truncate, wait };
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,3 @@
|
|
|
1
|
-
// src/get-random-number.ts
|
|
2
|
-
function getRandomNumber(lowerBound, upperBound) {
|
|
3
|
-
if (lowerBound % 1 !== 0 || upperBound % 1 !== 0) {
|
|
4
|
-
throw new Error("NON_INTEGER_INPUTS");
|
|
5
|
-
}
|
|
6
|
-
return Math.floor(Math.random() * (upperBound - lowerBound + 1) + lowerBound);
|
|
7
|
-
}
|
|
8
|
-
var get_random_number_default = getRandomNumber;
|
|
9
|
-
|
|
10
|
-
// src/randomise-array.ts
|
|
11
|
-
function randomiseArray(array) {
|
|
12
|
-
const mutableArray = [...array];
|
|
13
|
-
const outputArray = [];
|
|
14
|
-
do {
|
|
15
|
-
const indexToRemove = get_random_number_default(0, mutableArray.length - 1);
|
|
16
|
-
outputArray.push(mutableArray.splice(indexToRemove, 1)[0]);
|
|
17
|
-
} while (mutableArray.length > 0);
|
|
18
|
-
return outputArray;
|
|
19
|
-
}
|
|
20
|
-
var randomise_array_default = randomiseArray;
|
|
21
|
-
|
|
22
|
-
// src/wait.ts
|
|
23
|
-
function wait(seconds) {
|
|
24
|
-
return new Promise((resolve, _) => {
|
|
25
|
-
setTimeout(() => {
|
|
26
|
-
resolve();
|
|
27
|
-
}, seconds * 1e3);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
var wait_default = wait;
|
|
31
|
-
|
|
32
1
|
// src/add-days-to-date.ts
|
|
33
2
|
function addDaysToDate(currentDate = /* @__PURE__ */ new Date(), dayIncrement = 1) {
|
|
34
3
|
const newDate = currentDate;
|
|
@@ -37,6 +6,38 @@ function addDaysToDate(currentDate = /* @__PURE__ */ new Date(), dayIncrement =
|
|
|
37
6
|
}
|
|
38
7
|
var add_days_to_date_default = addDaysToDate;
|
|
39
8
|
|
|
9
|
+
// src/append-semicolon.ts
|
|
10
|
+
function appendSemicolon(stringToAppendTo) {
|
|
11
|
+
if (stringToAppendTo.includes("\n")) {
|
|
12
|
+
throw new Error("MULTIPLE_LINE_ERROR");
|
|
13
|
+
}
|
|
14
|
+
const stringWithNoTrailingWhitespace = stringToAppendTo.trimEnd();
|
|
15
|
+
if (stringWithNoTrailingWhitespace === "") {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
return stringWithNoTrailingWhitespace[stringWithNoTrailingWhitespace.length - 1] === ";" ? stringWithNoTrailingWhitespace : `${stringWithNoTrailingWhitespace};`;
|
|
19
|
+
}
|
|
20
|
+
var append_semicolon_default = appendSemicolon;
|
|
21
|
+
|
|
22
|
+
// src/convert-file-to-base-64.ts
|
|
23
|
+
function convertFileToBase64(file) {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
const reader = new FileReader();
|
|
26
|
+
reader.readAsDataURL(file);
|
|
27
|
+
reader.onload = () => {
|
|
28
|
+
if (reader.result === null) {
|
|
29
|
+
reject(new Error("FILE_CONVERSION_ERROR"));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
resolve(reader.result);
|
|
33
|
+
};
|
|
34
|
+
reader.onerror = () => {
|
|
35
|
+
reject(new Error("FILE_READER_ERROR"));
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
var convert_file_to_base_64_default = convertFileToBase64;
|
|
40
|
+
|
|
40
41
|
// src/format-date-and-time.ts
|
|
41
42
|
function formatDateAndTime(inputDate) {
|
|
42
43
|
const yesterday = add_days_to_date_default(/* @__PURE__ */ new Date(), -1);
|
|
@@ -55,24 +56,69 @@ function formatDateAndTime(inputDate) {
|
|
|
55
56
|
}
|
|
56
57
|
var format_date_and_time_default = formatDateAndTime;
|
|
57
58
|
|
|
58
|
-
// src/
|
|
59
|
-
function
|
|
60
|
-
|
|
59
|
+
// src/get-random-number.ts
|
|
60
|
+
function getRandomNumber(lowerBound, upperBound) {
|
|
61
|
+
if (lowerBound % 1 !== 0 || upperBound % 1 !== 0) {
|
|
62
|
+
throw new Error("NON_INTEGER_INPUTS");
|
|
63
|
+
}
|
|
64
|
+
return Math.floor(Math.random() * (upperBound - lowerBound + 1) + lowerBound);
|
|
61
65
|
}
|
|
62
|
-
var
|
|
66
|
+
var get_random_number_default = getRandomNumber;
|
|
63
67
|
|
|
64
|
-
// src/
|
|
65
|
-
function
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
+
// src/is-monthly-multiple.ts
|
|
69
|
+
function endOfMonthChecksButNotFebruary(firstDate, secondDate) {
|
|
70
|
+
if ([3, 5, 8, 10].includes(firstDate.getMonth())) {
|
|
71
|
+
return firstDate.getDate() === 30 && secondDate.getDate() === 31;
|
|
68
72
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
function nonLeapYearFebruaryChecks(firstDate, secondDate) {
|
|
76
|
+
if (firstDate.getMonth() === 1) {
|
|
77
|
+
if (firstDate.getFullYear() % 4 !== 0 && firstDate.getDate() === 28) {
|
|
78
|
+
return [28, 29, 30, 31].includes(secondDate.getDate());
|
|
79
|
+
}
|
|
72
80
|
}
|
|
73
|
-
return
|
|
81
|
+
return false;
|
|
74
82
|
}
|
|
75
|
-
|
|
83
|
+
function leapYearFebruaryChecks(firstDate, secondDate) {
|
|
84
|
+
if (firstDate.getMonth() === 1) {
|
|
85
|
+
if (firstDate.getFullYear() % 4 === 0 && firstDate.getDate() === 29) {
|
|
86
|
+
return [29, 30, 31].includes(secondDate.getDate());
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
function isMonthlyMultiple(firstDate, secondDate) {
|
|
92
|
+
if (endOfMonthChecksButNotFebruary(firstDate, secondDate) || endOfMonthChecksButNotFebruary(secondDate, firstDate)) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
if (nonLeapYearFebruaryChecks(firstDate, secondDate) || nonLeapYearFebruaryChecks(secondDate, firstDate)) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
if (leapYearFebruaryChecks(firstDate, secondDate) || leapYearFebruaryChecks(secondDate, firstDate)) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
return firstDate.getDate() === secondDate.getDate();
|
|
102
|
+
}
|
|
103
|
+
var is_monthly_multiple_default = isMonthlyMultiple;
|
|
104
|
+
|
|
105
|
+
// src/is-same-date.ts
|
|
106
|
+
function isSameDate(firstDate, secondDate) {
|
|
107
|
+
return firstDate.getDate() === secondDate.getDate() && firstDate.getMonth() === secondDate.getMonth() && firstDate.getFullYear() === secondDate.getFullYear();
|
|
108
|
+
}
|
|
109
|
+
var is_same_date_default = isSameDate;
|
|
110
|
+
|
|
111
|
+
// src/randomise-array.ts
|
|
112
|
+
function randomiseArray(array) {
|
|
113
|
+
const mutableArray = [...array];
|
|
114
|
+
const outputArray = [];
|
|
115
|
+
do {
|
|
116
|
+
const indexToRemove = get_random_number_default(0, mutableArray.length - 1);
|
|
117
|
+
outputArray.push(mutableArray.splice(indexToRemove, 1)[0]);
|
|
118
|
+
} while (mutableArray.length > 0);
|
|
119
|
+
return outputArray;
|
|
120
|
+
}
|
|
121
|
+
var randomise_array_default = randomiseArray;
|
|
76
122
|
|
|
77
123
|
// src/range.ts
|
|
78
124
|
function range(start, stop, step = 1) {
|
|
@@ -97,11 +143,30 @@ function range(start, stop, step = 1) {
|
|
|
97
143
|
return numbers;
|
|
98
144
|
}
|
|
99
145
|
var range_default = range;
|
|
146
|
+
|
|
147
|
+
// src/truncate.ts
|
|
148
|
+
function truncate(stringToTruncate, maxLength = 5) {
|
|
149
|
+
return stringToTruncate.length > maxLength ? `${stringToTruncate.slice(0, maxLength)}...` : stringToTruncate;
|
|
150
|
+
}
|
|
151
|
+
var truncate_default = truncate;
|
|
152
|
+
|
|
153
|
+
// src/wait.ts
|
|
154
|
+
function wait(seconds) {
|
|
155
|
+
return new Promise((resolve, _) => {
|
|
156
|
+
setTimeout(() => {
|
|
157
|
+
resolve();
|
|
158
|
+
}, seconds * 1e3);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
var wait_default = wait;
|
|
100
162
|
export {
|
|
101
163
|
add_days_to_date_default as addDaysToDate,
|
|
102
164
|
append_semicolon_default as appendSemicolon,
|
|
165
|
+
convert_file_to_base_64_default as convertFileToBase64,
|
|
103
166
|
format_date_and_time_default as formatDateAndTime,
|
|
104
167
|
get_random_number_default as getRandomNumber,
|
|
168
|
+
is_monthly_multiple_default as isMonthlyMultiple,
|
|
169
|
+
is_same_date_default as isSameDate,
|
|
105
170
|
randomise_array_default as randomiseArray,
|
|
106
171
|
range_default as range,
|
|
107
172
|
truncate_default as truncate,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/utility",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
4
4
|
"main": "dist/index.cjs",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"license": "ISC",
|
|
26
26
|
"description": "",
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@alextheman/eslint-plugin": "^1.2.
|
|
29
|
-
"@eslint/js": "^9.
|
|
30
|
-
"@types/node": "^24.2.
|
|
31
|
-
"eslint": "^9.
|
|
28
|
+
"@alextheman/eslint-plugin": "^1.2.11",
|
|
29
|
+
"@eslint/js": "^9.33.0",
|
|
30
|
+
"@types/node": "^24.2.1",
|
|
31
|
+
"eslint": "^9.33.0",
|
|
32
32
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
33
33
|
"eslint-plugin-import": "^2.32.0",
|
|
34
34
|
"globals": "^16.3.0",
|