xjs-common 8.3.1 → 8.4.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.
- package/dist/const/ccy.d.ts +18 -0
- package/dist/const/ccy.js +20 -0
- package/dist/func/u-file.d.ts +1 -0
- package/dist/func/u-file.js +7 -0
- package/dist/func/u-string.d.ts +6 -0
- package/dist/func/u-string.js +24 -0
- package/dist/func/u.d.ts +1 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface Ccy {
|
|
2
|
+
symbol: t_ccySymbol;
|
|
3
|
+
crossUsd: string;
|
|
4
|
+
}
|
|
5
|
+
export type t_ccySymbol = keyof (typeof currencies);
|
|
6
|
+
declare const currencies: {
|
|
7
|
+
jpy: Ccy;
|
|
8
|
+
usd: Ccy;
|
|
9
|
+
gbp: Ccy;
|
|
10
|
+
eur: Ccy;
|
|
11
|
+
cad: Ccy;
|
|
12
|
+
aud: Ccy;
|
|
13
|
+
};
|
|
14
|
+
export declare const s_ccy: {
|
|
15
|
+
[k in t_ccySymbol]: Readonly<Ccy>;
|
|
16
|
+
};
|
|
17
|
+
export declare function resolveCcy(str: string): Ccy;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveCcy = exports.s_ccy = void 0;
|
|
4
|
+
const currencies = {
|
|
5
|
+
jpy: { crossUsd: "usd/jpy" },
|
|
6
|
+
usd: { crossUsd: null },
|
|
7
|
+
gbp: { crossUsd: "gbp/usd" },
|
|
8
|
+
eur: { crossUsd: "eur/usd" },
|
|
9
|
+
cad: { crossUsd: "cad/usd" },
|
|
10
|
+
aud: { crossUsd: "aud/usd" }
|
|
11
|
+
};
|
|
12
|
+
exports.s_ccy = (() => {
|
|
13
|
+
Object.entries(currencies).forEach(kv => { kv[1].symbol = kv[0]; currencies[kv[0]] = Object.freeze(kv[1]); });
|
|
14
|
+
return Object.freeze(currencies);
|
|
15
|
+
})();
|
|
16
|
+
function resolveCcy(str) {
|
|
17
|
+
const ccyKey = Object.keys(exports.s_ccy).find(k => str?.toLowerCase() == k);
|
|
18
|
+
return ccyKey && exports.s_ccy[ccyKey];
|
|
19
|
+
}
|
|
20
|
+
exports.resolveCcy = resolveCcy;
|
package/dist/func/u-file.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ export declare namespace UFile {
|
|
|
9
9
|
function read(p: MaybeArray<string>, encoding: BufferEncoding): string;
|
|
10
10
|
function cp(from: MaybeArray<string>, to: MaybeArray<string>): void;
|
|
11
11
|
function mv(from: MaybeArray<string>, to: MaybeArray<string>): void;
|
|
12
|
+
function ls(p: MaybeArray<string>): string[];
|
|
12
13
|
function joinPath(...p: MaybeArray<string>[]): string;
|
|
13
14
|
}
|
package/dist/func/u-file.js
CHANGED
|
@@ -74,6 +74,13 @@ var UFile;
|
|
|
74
74
|
fs.renameSync(f, t);
|
|
75
75
|
}
|
|
76
76
|
UFile.mv = mv;
|
|
77
|
+
function ls(p) {
|
|
78
|
+
const dir = joinPath(p);
|
|
79
|
+
if (!fs.statSync(dir).isDirectory())
|
|
80
|
+
throw new xjs_err_1.XjsErr(s_errCode, "Specified path for ls is not directory.");
|
|
81
|
+
return fs.readdirSync(dir);
|
|
82
|
+
}
|
|
83
|
+
UFile.ls = ls;
|
|
77
84
|
function joinPath(...p) {
|
|
78
85
|
return path.join(...p.flatMap(u_type_1.UType.takeAsArray));
|
|
79
86
|
}
|
package/dist/func/u-string.d.ts
CHANGED
|
@@ -15,4 +15,10 @@ export declare namespace UString {
|
|
|
15
15
|
function generateRandomString(len: number): string;
|
|
16
16
|
function idx2az(idx: number): string;
|
|
17
17
|
function az2idx(az: string): number;
|
|
18
|
+
function is_yyyy(v: string): boolean;
|
|
19
|
+
function is_yyyyMM(v: string): boolean;
|
|
20
|
+
function is_yyyyMMdd(v: string): boolean;
|
|
21
|
+
function is_yyyyMMddhh(v: string): boolean;
|
|
22
|
+
function is_yyyyMMddhhmm(v: string): boolean;
|
|
23
|
+
function is_yyyyMMddhhmmss(v: string): boolean;
|
|
18
24
|
}
|
package/dist/func/u-string.js
CHANGED
|
@@ -59,4 +59,28 @@ var UString;
|
|
|
59
59
|
.map((idx, i) => (idx + 1) * (26 ** i)).reduce((v1, v2) => v1 + v2) - 1;
|
|
60
60
|
}
|
|
61
61
|
UString.az2idx = az2idx;
|
|
62
|
+
function is_yyyy(v) {
|
|
63
|
+
return !!v?.match(/^[1-9]\d{3}$/);
|
|
64
|
+
}
|
|
65
|
+
UString.is_yyyy = is_yyyy;
|
|
66
|
+
function is_yyyyMM(v) {
|
|
67
|
+
return !!v?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])$/);
|
|
68
|
+
}
|
|
69
|
+
UString.is_yyyyMM = is_yyyyMM;
|
|
70
|
+
function is_yyyyMMdd(v) {
|
|
71
|
+
return !!v?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])$/);
|
|
72
|
+
}
|
|
73
|
+
UString.is_yyyyMMdd = is_yyyyMMdd;
|
|
74
|
+
function is_yyyyMMddhh(v) {
|
|
75
|
+
return !!v?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])(0[1-9]|1\d|2[0-3])$/);
|
|
76
|
+
}
|
|
77
|
+
UString.is_yyyyMMddhh = is_yyyyMMddhh;
|
|
78
|
+
function is_yyyyMMddhhmm(v) {
|
|
79
|
+
return !!v?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])(0[1-9]|1\d|2[0-3])[0-5]\d$/);
|
|
80
|
+
}
|
|
81
|
+
UString.is_yyyyMMddhhmm = is_yyyyMMddhhmm;
|
|
82
|
+
function is_yyyyMMddhhmmss(v) {
|
|
83
|
+
return !!v?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])(0[1-9]|1\d|2[0-3])[0-5]\d[0-5]\d$/);
|
|
84
|
+
}
|
|
85
|
+
UString.is_yyyyMMddhhmmss = is_yyyyMMddhhmmss;
|
|
62
86
|
})(UString = exports.UString || (exports.UString = {}));
|
package/dist/func/u.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare function int2array(size: number): number[];
|
|
|
5
5
|
export declare function array2map<K, T>(array: T[], keyGen: (e: T) => K): Map<K, T[]>;
|
|
6
6
|
export declare function bitor(...bit: number[]): number;
|
|
7
7
|
export declare function checkPortAvailability(port: number): Promise<boolean>;
|
|
8
|
-
interface RetryOption<T = void | Promise<void>> {
|
|
8
|
+
export interface RetryOption<T = void | Promise<void>> {
|
|
9
9
|
count?: number;
|
|
10
10
|
logger?: Loggable;
|
|
11
11
|
errorCriterion?: (e: any) => boolean;
|
|
@@ -23,4 +23,3 @@ export declare function retry<T>(cb: () => T, op?: RetryOption<void>): T;
|
|
|
23
23
|
export declare function retry<T>(cb: () => T, op?: RetryOption<Promise<void>>): Promise<T>;
|
|
24
24
|
export declare function retry<T>(cb: () => Promise<T>, op?: RetryOption<void>): Promise<T>;
|
|
25
25
|
export declare function retry<T>(cb: () => Promise<T>, op?: RetryOption<Promise<void>>): Promise<T>;
|
|
26
|
-
export {};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./const/types"), exports);
|
|
|
19
19
|
__exportStar(require("./const/time-unit"), exports);
|
|
20
20
|
__exportStar(require("./const/gender"), exports);
|
|
21
21
|
__exportStar(require("./const/http-method"), exports);
|
|
22
|
+
__exportStar(require("./const/ccy"), exports);
|
|
22
23
|
__exportStar(require("./func/u"), exports);
|
|
23
24
|
__exportStar(require("./func/u-obj"), exports);
|
|
24
25
|
__exportStar(require("./func/u-string"), exports);
|