@nano-lib/util 1.1.1 → 1.1.3
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/lib/index.d.ts +2 -1
- package/lib/index.js +1 -1
- package/lib/index.mjs +739 -719
- package/lib/utils/baseUrl.d.ts +15 -0
- package/lib/utils/common.d.ts +7 -14
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the request base URL from the cache, or applies a handler to it if present.
|
|
3
|
+
* @param {Object} options The options object
|
|
4
|
+
* @param {string} options.cacheKey The cache key to storage
|
|
5
|
+
* @param {'session'|'local'} [options.cacheMode] The cache mode to use. 'session' or 'local', default is 'session'
|
|
6
|
+
* @param {boolean} [options.saveState] Whether to save the base URL to the state
|
|
7
|
+
* @param {(baseUrl: string) => string} [options.handler] A handler function to apply to the retrieved base URL
|
|
8
|
+
* @returns {string} The base URL
|
|
9
|
+
*/
|
|
10
|
+
export default function getRequestBaseUrl(options: {
|
|
11
|
+
cacheKey: string;
|
|
12
|
+
cacheMode?: 'session' | 'local';
|
|
13
|
+
saveState?: boolean;
|
|
14
|
+
handler?: (baseUrl: string) => string;
|
|
15
|
+
}): string | null;
|
package/lib/utils/common.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PromiseFn, Fn, ProtocolType } from '../types';
|
|
1
|
+
import { PromiseFn, Nullable, Fn, ProtocolType, AnyObj } from '../types';
|
|
2
2
|
export declare const NOOP: () => void;
|
|
3
3
|
export declare function sleep(x: number): Promise<unknown>;
|
|
4
4
|
export declare function countdownTimer(x: number, cb: (x: number) => void | undefined): Promise<boolean>;
|
|
@@ -18,19 +18,12 @@ export declare function getGenderByIdNumber(idNumber: string): "1" | "2";
|
|
|
18
18
|
* @throws error if the given ID number is invalid
|
|
19
19
|
*/
|
|
20
20
|
export declare function getBirthdayByIdNumber(idNumber: string): string;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* @returns {string} The base URL
|
|
28
|
-
*/
|
|
29
|
-
export declare const getRequestBaseUrl: (options: {
|
|
30
|
-
cacheKey: string;
|
|
31
|
-
cacheMode?: "session" | "local";
|
|
32
|
-
handler?: (path: string) => string;
|
|
33
|
-
}) => string;
|
|
21
|
+
export declare function getSystemConfig<T extends AnyObj, U>(options: {
|
|
22
|
+
baseUrl: Nullable<string> | Fn<Nullable<string>>;
|
|
23
|
+
initUrl: string;
|
|
24
|
+
initParams?: T;
|
|
25
|
+
initFn: (initUrl: string, initParams: T) => Promise<U>;
|
|
26
|
+
}): Promise<boolean | U>;
|
|
34
27
|
/**
|
|
35
28
|
* Gets the current location configuration.
|
|
36
29
|
* @param httpsPort the port for HTTPS protocol, default is '443'
|