@nano-lib/util 1.1.0 → 1.1.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.
@@ -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;
@@ -1,4 +1,4 @@
1
- import { PromiseFn, Fn } from '../types';
1
+ import { PromiseFn, Fn, ProtocolType } 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,6 +18,19 @@ 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
+ * Gets the current location configuration.
23
+ * @param httpsPort the port for HTTPS protocol, default is '443'
24
+ * @param httpPort the port for HTTP protocol, default is '80'
25
+ * @returns the current location configuration
26
+ */
27
+ export declare const getLocationConfig: (httpsPort?: string, httpPort?: string) => {
28
+ hostname: string;
29
+ protocol: ProtocolType;
30
+ port: string;
31
+ pathname: string;
32
+ };
33
+ export declare const transformPathName: (path: string) => string;
21
34
  export declare const getFullUrl: (relativeUrl: string, domain?: string) => string;
22
35
  export declare const getArrayFullUrl: (relativeUrls: string | string[], domain?: string) => string[];
23
36
  export declare function ricTask(tasks: Fn[]): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nano-lib/util",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Custom utility functions for the nano library",
5
5
  "author": "xylo",
6
6
  "license": "MIT",