xjs-common 8.0.2 → 8.0.4
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/README.md +10 -4
- package/dist/const/types.d.ts +11 -0
- package/dist/func/u.d.ts +1 -1
- package/dist/func/u.js +2 -2
- package/dist/prcs/http/http-resolver.d.ts +2 -4
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
[](https://github.com/begyyal/xjs_commons/actions/workflows/test.yml)
|
2
2
|
|
3
|
-
Available to `npm i xjs-common`.
|
4
|
-
**NOTE**: The versions <= `v6.2.0` was unpublished. If you has been used these versions, please update to the version >= `v7.0.0`.
|
5
|
-
|
6
3
|
# Overview
|
7
4
|
Library modules for nodejs + typescript that bundled general-purpose implementations.
|
8
5
|
This module is very simple, therefore it has no dependencies.
|
9
6
|
|
7
|
+
# Install
|
8
|
+
```
|
9
|
+
npm i xjs-common
|
10
|
+
```
|
11
|
+
**NOTE**: The versions <= `v6.2.0` was unpublished. If you has been used these versions, please update to the version >= `v7.0.0`.
|
12
|
+
|
10
13
|
# Code example (only part)
|
11
14
|
- Miscellaneous utilities.
|
12
15
|
```ts
|
@@ -205,7 +208,7 @@ class Cls_B {
|
|
205
208
|
console.log(UType.validate(Object.assign(new Cls_A(), invalid6))); // [ 'objA.aryB' ]
|
206
209
|
})();
|
207
210
|
```
|
208
|
-
|
211
|
+
# Error definition
|
209
212
|
XJS throws error with `code` property which has one of the following numbers.
|
210
213
|
|code|thrown by|
|
211
214
|
|:---|:---|
|
@@ -214,3 +217,6 @@ XJS throws error with `code` property which has one of the following numbers.
|
|
214
217
|
|30|`func/u-type` (include `func/decorator/d-type`) |
|
215
218
|
|100|`func/decorator/transaction`|
|
216
219
|
|200|`prcs/http/http-resolver`|
|
220
|
+
|
221
|
+
# License
|
222
|
+
[Apache-License](./LICENSE)
|
package/dist/const/types.d.ts
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
export type IndexSignature = string | number | symbol;
|
2
2
|
export type NormalRecord = Record<IndexSignature, any>;
|
3
3
|
export type MaybeArray<T> = T | T[];
|
4
|
+
export type Loggable = {
|
5
|
+
log: (msg: any) => void;
|
6
|
+
warn: (msg: any) => void;
|
7
|
+
error: (msg: any) => void;
|
8
|
+
};
|
9
|
+
export type Unique<T = number> = {
|
10
|
+
id: T;
|
11
|
+
};
|
12
|
+
export type IdName<T = number> = {
|
13
|
+
name: string;
|
14
|
+
} & Unique<T>;
|
4
15
|
export declare enum Type {
|
5
16
|
string = "string",
|
6
17
|
number = "number",
|
package/dist/func/u.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export declare function getJSTDate(): Date;
|
1
|
+
export declare function getJSTDate(d?: Date): Date;
|
2
2
|
export declare function delay(sec: number): Promise<void>;
|
3
3
|
export declare function int2array(size: number): number[];
|
4
4
|
export declare function array2map<K, T>(array: T[], keyGen: (e: T) => K): Map<K, T[]>;
|
package/dist/func/u.js
CHANGED
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkPortAvailability = exports.bitor = exports.array2map = exports.int2array = exports.delay = exports.getJSTDate = void 0;
|
4
4
|
const xjs_err_1 = require("../obj/xjs-err");
|
5
5
|
const s_errCode = 10;
|
6
|
-
function getJSTDate() {
|
7
|
-
return new Date(Date.now() + 9 * 60 * 60 * 1000);
|
6
|
+
function getJSTDate(d) {
|
7
|
+
return new Date((d ? d.getTime() : Date.now()) + 9 * 60 * 60 * 1000);
|
8
8
|
}
|
9
9
|
exports.getJSTDate = getJSTDate;
|
10
10
|
function delay(sec) {
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { Loggable } from "../../const/types";
|
1
2
|
import { HttpResolverContext } from "./http-resolver-context";
|
2
3
|
import { ClientOption, IHttpClient, RequestOption } from "./i-http-client";
|
3
4
|
export interface ClientMode {
|
@@ -19,10 +20,7 @@ export declare class HttpResolver implements IHttpClient {
|
|
19
20
|
* @param _baseCmv chrome major version refered when construct a user agent, and the version will be randomized between `n` to `n-4`.
|
20
21
|
* @param _l custom logger. default is `console`.
|
21
22
|
*/
|
22
|
-
constructor(_baseCmv: number, _l?:
|
23
|
-
log: (msg: any) => void;
|
24
|
-
warn: (msg: any) => void;
|
25
|
-
});
|
23
|
+
constructor(_baseCmv: number, _l?: Loggable);
|
26
24
|
/**
|
27
25
|
* create a http client as new context that keeps some states. (browser type, cookies, ciphers order, etc...)
|
28
26
|
* @param op.mode {@link s_clientMode} that is imitated. default is random between chrome or firefox.
|