typeshi 1.3.0 → 1.5.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.
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
* - or maybe have them return boolean type predicates ?
|
|
12
12
|
* - -> maybe have to make a class
|
|
13
13
|
* - research the thingy where a type is after the function name and before parens
|
|
14
|
-
* @consideration add a default export named 'validate'
|
|
15
14
|
*/
|
|
16
15
|
import { TypeOfEnum } from "./typeValidation";
|
|
17
16
|
/**
|
|
@@ -192,4 +191,19 @@ export declare function existingPathArgument(source: string, arg2: string | {
|
|
|
192
191
|
* @returns **`bracketedString`** `string`
|
|
193
192
|
*/
|
|
194
193
|
export declare const bracketed: (s: string) => string;
|
|
195
|
-
|
|
194
|
+
declare const validate: {
|
|
195
|
+
stringArgument: typeof stringArgument;
|
|
196
|
+
multipleStringArguments: typeof multipleStringArguments;
|
|
197
|
+
numericStringArgument: typeof numericStringArgument;
|
|
198
|
+
booleanArgument: typeof booleanArgument;
|
|
199
|
+
numberArgument: typeof numberArgument;
|
|
200
|
+
arrayArgument: typeof arrayArgument;
|
|
201
|
+
enumArgument: typeof enumArgument;
|
|
202
|
+
objectArgument: typeof objectArgument;
|
|
203
|
+
functionArgument: typeof functionArgument;
|
|
204
|
+
existingPathArgument: typeof existingPathArgument;
|
|
205
|
+
existingDirectoryArgument: typeof existingDirectoryArgument;
|
|
206
|
+
existingFileArgument: typeof existingFileArgument;
|
|
207
|
+
multipleExistingFileArguments: typeof multipleExistingFileArguments;
|
|
208
|
+
};
|
|
209
|
+
export default validate;
|
|
@@ -63,7 +63,6 @@ exports.existingPathArgument = existingPathArgument;
|
|
|
63
63
|
* - or maybe have them return boolean type predicates ?
|
|
64
64
|
* - -> maybe have to make a class
|
|
65
65
|
* - research the thingy where a type is after the function name and before parens
|
|
66
|
-
* @consideration add a default export named 'validate'
|
|
67
66
|
*/
|
|
68
67
|
const typeValidation_1 = require("./typeValidation");
|
|
69
68
|
const setupLog_1 = require("../config/setupLog");
|
|
@@ -315,6 +314,9 @@ function functionArgument(source, arg2, value) {
|
|
|
315
314
|
throw new Error(msg);
|
|
316
315
|
}
|
|
317
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* `re = /(?<=^is).*$/i`
|
|
319
|
+
*/
|
|
318
320
|
const typeGuardNamePattern = /(?<=^is).*$/i;
|
|
319
321
|
/**
|
|
320
322
|
* @note `if` `elementTypeGuard`'s name or its label includes 'Array' then only check `elementTypeGuard(value)`
|
|
@@ -808,3 +810,22 @@ function getSourceString(fileName, func, funcInfo, startLine, endLine) {
|
|
|
808
810
|
let funcName = typeof func === 'string' ? func : func.name;
|
|
809
811
|
return `[${fileName}.${funcName}(${(0, typeValidation_1.isNonEmptyString)(funcInfo) ? ` ${funcInfo} ` : ''})${lineNumberText}]`;
|
|
810
812
|
}
|
|
813
|
+
const validate = {
|
|
814
|
+
stringArgument,
|
|
815
|
+
multipleStringArguments,
|
|
816
|
+
numericStringArgument,
|
|
817
|
+
booleanArgument,
|
|
818
|
+
numberArgument,
|
|
819
|
+
arrayArgument,
|
|
820
|
+
enumArgument,
|
|
821
|
+
// isEnumArgumentOptions,
|
|
822
|
+
// isEnumObject,
|
|
823
|
+
objectArgument,
|
|
824
|
+
// isObjectArgumentOptions,
|
|
825
|
+
functionArgument,
|
|
826
|
+
existingPathArgument,
|
|
827
|
+
existingDirectoryArgument,
|
|
828
|
+
existingFileArgument,
|
|
829
|
+
multipleExistingFileArguments
|
|
830
|
+
};
|
|
831
|
+
exports.default = validate;
|
|
@@ -94,3 +94,26 @@ export declare function getCurrentPacificTime(): string;
|
|
|
94
94
|
* @returns {string} The date string in Pacific Time
|
|
95
95
|
*/
|
|
96
96
|
export declare function toPacificTime(initialDateString: string): string;
|
|
97
|
+
export declare const Milliseconds: {
|
|
98
|
+
from: {
|
|
99
|
+
hours: (n: number) => number;
|
|
100
|
+
minutes: (n: number) => number;
|
|
101
|
+
seconds: (n: number) => number;
|
|
102
|
+
/**
|
|
103
|
+
* @param d `Date` object
|
|
104
|
+
* @returns `number` milliseconds since epoch
|
|
105
|
+
*/
|
|
106
|
+
date: (d: Date) => number;
|
|
107
|
+
};
|
|
108
|
+
to: {
|
|
109
|
+
hours: (n: number) => number;
|
|
110
|
+
minutes: (n: number) => number;
|
|
111
|
+
seconds: (n: number) => number;
|
|
112
|
+
/**
|
|
113
|
+
* interprets `n` as milliseconds since epoch
|
|
114
|
+
* @param n `number` milliseconds
|
|
115
|
+
* @returns `Date` object
|
|
116
|
+
*/
|
|
117
|
+
date: (n: number) => Date;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @file src/utils/io/dateTime.ts
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DEFAULT_TIMEZONE = exports.DEFAULT_LOCALE = exports.ISO_PATTERN = exports.TimeUnitEnum = exports.DateFormatEnum = void 0;
|
|
6
|
+
exports.Milliseconds = exports.DEFAULT_TIMEZONE = exports.DEFAULT_LOCALE = exports.ISO_PATTERN = exports.TimeUnitEnum = exports.DateFormatEnum = void 0;
|
|
7
7
|
exports.getDateFromUnixTimestamp = getDateFromUnixTimestamp;
|
|
8
8
|
exports.calculateDifferenceOfDateStrings = calculateDifferenceOfDateStrings;
|
|
9
9
|
exports.getUnixTimestampFromISO = getUnixTimestampFromISO;
|
|
@@ -200,3 +200,42 @@ function toPacificTime(initialDateString) {
|
|
|
200
200
|
const pacificTime = initialDate.toLocaleString(exports.DEFAULT_LOCALE, { timeZone: exports.DEFAULT_TIMEZONE });
|
|
201
201
|
return pacificTime;
|
|
202
202
|
}
|
|
203
|
+
exports.Milliseconds = {
|
|
204
|
+
from: {
|
|
205
|
+
hours: (n) => {
|
|
206
|
+
return n * (1000 * 60 * 60);
|
|
207
|
+
},
|
|
208
|
+
minutes: (n) => {
|
|
209
|
+
return n * (1000 * 60);
|
|
210
|
+
},
|
|
211
|
+
seconds: (n) => {
|
|
212
|
+
return n * (1000);
|
|
213
|
+
},
|
|
214
|
+
/**
|
|
215
|
+
* @param d `Date` object
|
|
216
|
+
* @returns `number` milliseconds since epoch
|
|
217
|
+
*/
|
|
218
|
+
date: (d) => {
|
|
219
|
+
return d.getTime();
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
to: {
|
|
223
|
+
hours: (n) => {
|
|
224
|
+
return n / (1000 * 60 * 60);
|
|
225
|
+
},
|
|
226
|
+
minutes: (n) => {
|
|
227
|
+
return n / (1000 * 60);
|
|
228
|
+
},
|
|
229
|
+
seconds: (n) => {
|
|
230
|
+
return n / (1000);
|
|
231
|
+
},
|
|
232
|
+
/**
|
|
233
|
+
* interprets `n` as milliseconds since epoch
|
|
234
|
+
* @param n `number` milliseconds
|
|
235
|
+
* @returns `Date` object
|
|
236
|
+
*/
|
|
237
|
+
date: (n) => {
|
|
238
|
+
return new Date(n);
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typeshi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "TypeScript utility modules",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,25 +23,24 @@
|
|
|
23
23
|
],
|
|
24
24
|
"author": "Andrew Garwood",
|
|
25
25
|
"license": "MIT",
|
|
26
|
-
"
|
|
27
|
-
"@types/jest": "^29.5.14",
|
|
28
|
-
"@types/node": "^22.15.15",
|
|
29
|
-
"addresser": "^1.1.20",
|
|
30
|
-
"axios": "^1.9.0",
|
|
31
|
-
"csv-parser": "^3.2.0",
|
|
32
|
-
"fastest-levenshtein": "^1.0.16",
|
|
33
|
-
"fs": "^0.0.1-security",
|
|
34
|
-
"jest": "^29.7.0",
|
|
35
|
-
"lodash": "^4.17.21",
|
|
36
|
-
"puppeteer-core": "^24.9.0",
|
|
26
|
+
"dependencies": {
|
|
37
27
|
"rimraf": "^5.0.0",
|
|
38
28
|
"ts-jest": "^29.3.4",
|
|
39
29
|
"ts-node": "^10.9.2",
|
|
40
|
-
"tsconfig-paths": "^4.2.0",
|
|
41
30
|
"tslog": "^4.9.3",
|
|
42
|
-
"
|
|
31
|
+
"lodash": "^4.17.21",
|
|
32
|
+
"addresser": "^1.1.20",
|
|
33
|
+
"csv-parser": "^3.2.0",
|
|
34
|
+
"fastest-levenshtein": "^1.0.16",
|
|
43
35
|
"xlsx": "https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz"
|
|
44
36
|
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/jest": "^29.5.14",
|
|
39
|
+
"@types/node": "^22.15.15",
|
|
40
|
+
"jest": "^29.7.0",
|
|
41
|
+
"tsconfig-paths": "^4.2.0",
|
|
42
|
+
"typescript": "^5.0.0"
|
|
43
|
+
},
|
|
45
44
|
"engines": {
|
|
46
45
|
"node": ">=16.0.0"
|
|
47
46
|
},
|