@stackone/utils 0.7.0 → 0.8.1

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.
@@ -0,0 +1,126 @@
1
+ import { randomUUID } from "crypto";
2
+
3
+ //#region src/base64.d.ts
4
+ declare function encodeToBase64(data: string): string;
5
+ declare function decodeFromBase64(encodedData: string): string;
6
+ //#endregion
7
+ //#region src/countries/types.d.ts
8
+
9
+ type ISO31662SubDivisionCodeNamePairs = {
10
+ [subDivisionCode: string]: string;
11
+ };
12
+ //#endregion
13
+ //#region src/countries/countriesGetters.d.ts
14
+ declare const getCountryAlpha2CodeByAlpha2Code: (alpha2Code: string) => string | undefined;
15
+ declare const getCountryAlpha3CodeByAlpha3Code: (alpha3Code: string) => string | undefined;
16
+ declare const getCountryCodeByCountryCode: (countryCode: string) => string | undefined;
17
+ declare const getCountryNameByCountryName: (countryName: string) => string | undefined;
18
+ declare const getCountryNameByAlpha3Code: (alpha3Code: string) => string | undefined;
19
+ declare const getCountryNameByAlpha2Code: (alpha2Code: string) => string | undefined;
20
+ declare const getCountryNameByCountryCode: (countryCode: string) => string | undefined;
21
+ declare const getCountryAlpha3CodeByAlpha2Code: (alpha2Code: string) => string | undefined;
22
+ declare const getCountryAlpha3CodeByCountryName: (countryName: string) => string | undefined;
23
+ declare const getCountryAlpha3CodeByCountryCode: (countryCode: string) => string | undefined;
24
+ declare const getCountryAlpha2CodeByAlpha3Code: (alpha3Code: string) => string | undefined;
25
+ declare const getCountryAlpha2CodeByCountryName: (countryName: string) => string | undefined;
26
+ declare const getCountryAlpha2CodeByCountryCode: (countryCode: string) => string | undefined;
27
+ declare const getCountryCodeByAlpha2Code: (alpha2Code: string) => string | undefined;
28
+ declare const getCountryCodeByAlpha3Code: (alpha3Code: string) => string | undefined;
29
+ declare const getCountryCodeByCountryName: (countryName: string) => string | undefined;
30
+ declare const getCountrySubDivisionsByAlpha2Code: (alpha2Code: string) => ISO31662SubDivisionCodeNamePairs | undefined;
31
+ declare const getCountrySubDivisionByAlpha2CodeAndName: (alpha2Code: string, subDivisionName: string) => string | undefined;
32
+ declare const getCountrySubDivisionNameBySubDivisionCode: (subDivisionCode: string) => string | undefined;
33
+ declare const getCountrySubDivisionCodeBySubDivisionName: (subDivisionName: string) => string | undefined;
34
+ declare const getCountryAlpha2CodeByCitizenship: (citizenship: string) => string | undefined;
35
+ //#endregion
36
+ //#region src/dataStructures/normalizedKeyMap.d.ts
37
+ declare class NormalizedKeyMap<V> extends Map<string, any> {
38
+ #private;
39
+ set(key: string, value: V): this;
40
+ get(key: string): V | undefined;
41
+ has(key: string): boolean;
42
+ delete(key: string): boolean;
43
+ }
44
+ //#endregion
45
+ //#region src/dates.d.ts
46
+ type InputDate = Date | string | null;
47
+ declare const calculateNextAnniversary: ({
48
+ initialDate,
49
+ format
50
+ }: {
51
+ initialDate?: InputDate;
52
+ format?: string;
53
+ }) => Date | null;
54
+ declare const calculateYearsElapsed: ({
55
+ startDate,
56
+ endDate,
57
+ format
58
+ }: {
59
+ startDate?: InputDate;
60
+ endDate?: InputDate;
61
+ format?: string;
62
+ }) => number | null;
63
+ declare const dateHasPassed: ({
64
+ date,
65
+ yearsToAdd,
66
+ format
67
+ }: {
68
+ date?: InputDate;
69
+ yearsToAdd?: number;
70
+ format?: string;
71
+ }) => boolean;
72
+ //#endregion
73
+ //#region src/exponentialBackoff.d.ts
74
+ declare const exponentialBackoffInMS: (retryCount: number, baseRetryDelayInMS?: number, jitterFactor?: number) => number;
75
+ //#endregion
76
+ //#region src/hashContent.d.ts
77
+ declare const getContentHash: (content: unknown) => string;
78
+ //#endregion
79
+ //#region src/parsers.d.ts
80
+ declare const safeParseToString: ({
81
+ value
82
+ }: {
83
+ value: unknown;
84
+ }) => string | null;
85
+ declare const safeParseToNumber: ({
86
+ value
87
+ }: {
88
+ value: unknown;
89
+ }) => number | null;
90
+ declare const safeParseToBoolean: ({
91
+ value
92
+ }: {
93
+ value: unknown;
94
+ }) => boolean | null;
95
+ declare const safeParseToDateTime: ({
96
+ value,
97
+ format
98
+ }: {
99
+ value: unknown;
100
+ format?: string;
101
+ }) => Date | null;
102
+ declare const safeParseToDateTimeString: ({
103
+ value,
104
+ format
105
+ }: {
106
+ value: unknown;
107
+ format?: string;
108
+ }) => string | null;
109
+ //#endregion
110
+ //#region src/timeouts.d.ts
111
+ declare const delay: (ms: number) => Promise<unknown>;
112
+ //#endregion
113
+ //#region src/typeguards.d.ts
114
+ declare const notMissing: <T>(value: T | null | undefined) => value is T;
115
+ declare const isMissing: <T>(value: T | null | undefined) => value is null | undefined;
116
+ declare const isString: (value: unknown) => value is string;
117
+ declare const isNumber: (value: unknown) => value is number;
118
+ declare const isBoolean: (value: unknown) => value is boolean;
119
+ declare const isDate: (value: unknown) => value is Date;
120
+ declare const isObject: (value: unknown) => value is Record<string, unknown>;
121
+ //#endregion
122
+ //#region src/uuids.d.ts
123
+ declare const isValidUUID: (uuid: string) => boolean;
124
+ declare const generateRequestId: (randomUUIDGenerator?: typeof randomUUID) => string;
125
+ //#endregion
126
+ export { NormalizedKeyMap, calculateNextAnniversary, calculateYearsElapsed, dateHasPassed, decodeFromBase64, delay, encodeToBase64, exponentialBackoffInMS, generateRequestId, getContentHash, getCountryAlpha2CodeByAlpha2Code, getCountryAlpha2CodeByAlpha3Code, getCountryAlpha2CodeByCitizenship, getCountryAlpha2CodeByCountryCode, getCountryAlpha2CodeByCountryName, getCountryAlpha3CodeByAlpha2Code, getCountryAlpha3CodeByAlpha3Code, getCountryAlpha3CodeByCountryCode, getCountryAlpha3CodeByCountryName, getCountryCodeByAlpha2Code, getCountryCodeByAlpha3Code, getCountryCodeByCountryCode, getCountryCodeByCountryName, getCountryNameByAlpha2Code, getCountryNameByAlpha3Code, getCountryNameByCountryCode, getCountryNameByCountryName, getCountrySubDivisionByAlpha2CodeAndName, getCountrySubDivisionCodeBySubDivisionName, getCountrySubDivisionNameBySubDivisionCode, getCountrySubDivisionsByAlpha2Code, isBoolean, isDate, isMissing, isNumber, isObject, isString, isValidUUID, notMissing, safeParseToBoolean, safeParseToDateTime, safeParseToDateTimeString, safeParseToNumber, safeParseToString };
@@ -0,0 +1,126 @@
1
+ import { randomUUID } from "crypto";
2
+
3
+ //#region src/base64.d.ts
4
+ declare function encodeToBase64(data: string): string;
5
+ declare function decodeFromBase64(encodedData: string): string;
6
+ //#endregion
7
+ //#region src/countries/types.d.ts
8
+
9
+ type ISO31662SubDivisionCodeNamePairs = {
10
+ [subDivisionCode: string]: string;
11
+ };
12
+ //#endregion
13
+ //#region src/countries/countriesGetters.d.ts
14
+ declare const getCountryAlpha2CodeByAlpha2Code: (alpha2Code: string) => string | undefined;
15
+ declare const getCountryAlpha3CodeByAlpha3Code: (alpha3Code: string) => string | undefined;
16
+ declare const getCountryCodeByCountryCode: (countryCode: string) => string | undefined;
17
+ declare const getCountryNameByCountryName: (countryName: string) => string | undefined;
18
+ declare const getCountryNameByAlpha3Code: (alpha3Code: string) => string | undefined;
19
+ declare const getCountryNameByAlpha2Code: (alpha2Code: string) => string | undefined;
20
+ declare const getCountryNameByCountryCode: (countryCode: string) => string | undefined;
21
+ declare const getCountryAlpha3CodeByAlpha2Code: (alpha2Code: string) => string | undefined;
22
+ declare const getCountryAlpha3CodeByCountryName: (countryName: string) => string | undefined;
23
+ declare const getCountryAlpha3CodeByCountryCode: (countryCode: string) => string | undefined;
24
+ declare const getCountryAlpha2CodeByAlpha3Code: (alpha3Code: string) => string | undefined;
25
+ declare const getCountryAlpha2CodeByCountryName: (countryName: string) => string | undefined;
26
+ declare const getCountryAlpha2CodeByCountryCode: (countryCode: string) => string | undefined;
27
+ declare const getCountryCodeByAlpha2Code: (alpha2Code: string) => string | undefined;
28
+ declare const getCountryCodeByAlpha3Code: (alpha3Code: string) => string | undefined;
29
+ declare const getCountryCodeByCountryName: (countryName: string) => string | undefined;
30
+ declare const getCountrySubDivisionsByAlpha2Code: (alpha2Code: string) => ISO31662SubDivisionCodeNamePairs | undefined;
31
+ declare const getCountrySubDivisionByAlpha2CodeAndName: (alpha2Code: string, subDivisionName: string) => string | undefined;
32
+ declare const getCountrySubDivisionNameBySubDivisionCode: (subDivisionCode: string) => string | undefined;
33
+ declare const getCountrySubDivisionCodeBySubDivisionName: (subDivisionName: string) => string | undefined;
34
+ declare const getCountryAlpha2CodeByCitizenship: (citizenship: string) => string | undefined;
35
+ //#endregion
36
+ //#region src/dataStructures/normalizedKeyMap.d.ts
37
+ declare class NormalizedKeyMap<V> extends Map<string, any> {
38
+ #private;
39
+ set(key: string, value: V): this;
40
+ get(key: string): V | undefined;
41
+ has(key: string): boolean;
42
+ delete(key: string): boolean;
43
+ }
44
+ //#endregion
45
+ //#region src/dates.d.ts
46
+ type InputDate = Date | string | null;
47
+ declare const calculateNextAnniversary: ({
48
+ initialDate,
49
+ format
50
+ }: {
51
+ initialDate?: InputDate;
52
+ format?: string;
53
+ }) => Date | null;
54
+ declare const calculateYearsElapsed: ({
55
+ startDate,
56
+ endDate,
57
+ format
58
+ }: {
59
+ startDate?: InputDate;
60
+ endDate?: InputDate;
61
+ format?: string;
62
+ }) => number | null;
63
+ declare const dateHasPassed: ({
64
+ date,
65
+ yearsToAdd,
66
+ format
67
+ }: {
68
+ date?: InputDate;
69
+ yearsToAdd?: number;
70
+ format?: string;
71
+ }) => boolean;
72
+ //#endregion
73
+ //#region src/exponentialBackoff.d.ts
74
+ declare const exponentialBackoffInMS: (retryCount: number, baseRetryDelayInMS?: number, jitterFactor?: number) => number;
75
+ //#endregion
76
+ //#region src/hashContent.d.ts
77
+ declare const getContentHash: (content: unknown) => string;
78
+ //#endregion
79
+ //#region src/parsers.d.ts
80
+ declare const safeParseToString: ({
81
+ value
82
+ }: {
83
+ value: unknown;
84
+ }) => string | null;
85
+ declare const safeParseToNumber: ({
86
+ value
87
+ }: {
88
+ value: unknown;
89
+ }) => number | null;
90
+ declare const safeParseToBoolean: ({
91
+ value
92
+ }: {
93
+ value: unknown;
94
+ }) => boolean | null;
95
+ declare const safeParseToDateTime: ({
96
+ value,
97
+ format
98
+ }: {
99
+ value: unknown;
100
+ format?: string;
101
+ }) => Date | null;
102
+ declare const safeParseToDateTimeString: ({
103
+ value,
104
+ format
105
+ }: {
106
+ value: unknown;
107
+ format?: string;
108
+ }) => string | null;
109
+ //#endregion
110
+ //#region src/timeouts.d.ts
111
+ declare const delay: (ms: number) => Promise<unknown>;
112
+ //#endregion
113
+ //#region src/typeguards.d.ts
114
+ declare const notMissing: <T>(value: T | null | undefined) => value is T;
115
+ declare const isMissing: <T>(value: T | null | undefined) => value is null | undefined;
116
+ declare const isString: (value: unknown) => value is string;
117
+ declare const isNumber: (value: unknown) => value is number;
118
+ declare const isBoolean: (value: unknown) => value is boolean;
119
+ declare const isDate: (value: unknown) => value is Date;
120
+ declare const isObject: (value: unknown) => value is Record<string, unknown>;
121
+ //#endregion
122
+ //#region src/uuids.d.ts
123
+ declare const isValidUUID: (uuid: string) => boolean;
124
+ declare const generateRequestId: (randomUUIDGenerator?: typeof randomUUID) => string;
125
+ //#endregion
126
+ export { NormalizedKeyMap, calculateNextAnniversary, calculateYearsElapsed, dateHasPassed, decodeFromBase64, delay, encodeToBase64, exponentialBackoffInMS, generateRequestId, getContentHash, getCountryAlpha2CodeByAlpha2Code, getCountryAlpha2CodeByAlpha3Code, getCountryAlpha2CodeByCitizenship, getCountryAlpha2CodeByCountryCode, getCountryAlpha2CodeByCountryName, getCountryAlpha3CodeByAlpha2Code, getCountryAlpha3CodeByAlpha3Code, getCountryAlpha3CodeByCountryCode, getCountryAlpha3CodeByCountryName, getCountryCodeByAlpha2Code, getCountryCodeByAlpha3Code, getCountryCodeByCountryCode, getCountryCodeByCountryName, getCountryNameByAlpha2Code, getCountryNameByAlpha3Code, getCountryNameByCountryCode, getCountryNameByCountryName, getCountrySubDivisionByAlpha2CodeAndName, getCountrySubDivisionCodeBySubDivisionName, getCountrySubDivisionNameBySubDivisionCode, getCountrySubDivisionsByAlpha2Code, isBoolean, isDate, isMissing, isNumber, isObject, isString, isValidUUID, notMissing, safeParseToBoolean, safeParseToDateTime, safeParseToDateTimeString, safeParseToNumber, safeParseToString };