xjs-node 2.1.0 → 2.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.
- package/build/func/u-file.d.ts +11 -2
- package/build/func/u-file.js +15 -5
- package/build/index.d.ts +3 -3
- package/build/index.js +2 -2
- package/build/{prcs/http/i-http-client.d.ts → obj/http-client.d.ts} +3 -3
- package/build/prcs/{http/http-resolver-context.d.ts → http-resolver-context.d.ts} +2 -2
- package/build/prcs/{http/http-resolver-context.js → http-resolver-context.js} +2 -2
- package/build/prcs/{http/http-resolver.d.ts → http-resolver.d.ts} +2 -2
- package/package.json +2 -2
- /package/build/{prcs/http/i-http-client.js → obj/http-client.js} +0 -0
- /package/build/prcs/{http/http-resolver.js → http-resolver.js} +0 -0
package/build/func/u-file.d.ts
CHANGED
|
@@ -12,9 +12,11 @@ export declare namespace UFile {
|
|
|
12
12
|
function mkdir(p: MaybeArray<string>): boolean;
|
|
13
13
|
function write(p: MaybeArray<string>, c: string): void;
|
|
14
14
|
/**
|
|
15
|
-
* remove a file. no error if the file to be removed doesn't exist.
|
|
15
|
+
* remove a file. default is no error if the file to be removed doesn't exist.
|
|
16
|
+
* @param p path of the file. if passed as an array those are joined.
|
|
17
|
+
* @param errorIfAbsent raise an error if the file to be removed doesn't exist.
|
|
16
18
|
*/
|
|
17
|
-
function rm(p: MaybeArray<string
|
|
19
|
+
function rm(p: MaybeArray<string>, errorIfAbsent?: boolean): void;
|
|
18
20
|
function exists(p: MaybeArray<string>): boolean;
|
|
19
21
|
/**
|
|
20
22
|
* return a file status. if the file of the status doesn't exist, this returns `null`.
|
|
@@ -22,6 +24,13 @@ export declare namespace UFile {
|
|
|
22
24
|
function status(p: MaybeArray<string>): FileStatus;
|
|
23
25
|
function read(p: MaybeArray<string>): Buffer;
|
|
24
26
|
function read(p: MaybeArray<string>, encoding: BufferEncoding): string;
|
|
27
|
+
/**
|
|
28
|
+
* read specified file path as a json object.
|
|
29
|
+
* @param p file path
|
|
30
|
+
* @param d default value if the file path doesn't exist. default of this is `{}`.
|
|
31
|
+
* @param encoding encoding used by file reading. default is `utf-8`.
|
|
32
|
+
*/
|
|
33
|
+
function readAsJson<T>(p: MaybeArray<string>, d?: any, encoding?: BufferEncoding): T;
|
|
25
34
|
function cp(from: MaybeArray<string>, to: MaybeArray<string>): void;
|
|
26
35
|
function mv(from: MaybeArray<string>, to: MaybeArray<string>): void;
|
|
27
36
|
function ls(p: MaybeArray<string>): string[];
|
package/build/func/u-file.js
CHANGED
|
@@ -56,12 +56,12 @@ var UFile;
|
|
|
56
56
|
}
|
|
57
57
|
UFile.write = write;
|
|
58
58
|
/**
|
|
59
|
-
* remove a file. no error if the file to be removed doesn't exist.
|
|
59
|
+
* remove a file. default is no error if the file to be removed doesn't exist.
|
|
60
|
+
* @param p path of the file. if passed as an array those are joined.
|
|
61
|
+
* @param errorIfAbsent raise an error if the file to be removed doesn't exist.
|
|
60
62
|
*/
|
|
61
|
-
function rm(p) {
|
|
62
|
-
|
|
63
|
-
if (fs.existsSync(pt))
|
|
64
|
-
fs.rmSync(pt, { recursive: true });
|
|
63
|
+
function rm(p, errorIfAbsent) {
|
|
64
|
+
fs.rmSync((0, u_1.joinPath)(p), { recursive: true, force: !errorIfAbsent });
|
|
65
65
|
}
|
|
66
66
|
UFile.rm = rm;
|
|
67
67
|
function exists(p) {
|
|
@@ -83,6 +83,16 @@ var UFile;
|
|
|
83
83
|
return fs.readFileSync(f, encoding);
|
|
84
84
|
}
|
|
85
85
|
UFile.read = read;
|
|
86
|
+
/**
|
|
87
|
+
* read specified file path as a json object.
|
|
88
|
+
* @param p file path
|
|
89
|
+
* @param d default value if the file path doesn't exist. default of this is `{}`.
|
|
90
|
+
* @param encoding encoding used by file reading. default is `utf-8`.
|
|
91
|
+
*/
|
|
92
|
+
function readAsJson(p, d = {}, encoding = "utf-8") {
|
|
93
|
+
return UFile.exists(p) ? JSON.parse(UFile.read(p, encoding)) : d;
|
|
94
|
+
}
|
|
95
|
+
UFile.readAsJson = readAsJson;
|
|
86
96
|
function cp(from, to) {
|
|
87
97
|
const f = (0, u_1.joinPath)(from), t = (0, u_1.joinPath)(to);
|
|
88
98
|
if (!fs.existsSync(f))
|
package/build/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./func/u";
|
|
2
2
|
export * from "./func/u-file";
|
|
3
|
-
export { HttpResolver, ClientMode } from "./prcs/http
|
|
4
|
-
export { s_clientMode } from "./prcs/http
|
|
5
|
-
export {
|
|
3
|
+
export { HttpResolver, ClientMode } from "./prcs/http-resolver";
|
|
4
|
+
export { s_clientMode } from "./prcs/http-resolver-context";
|
|
5
|
+
export { HttpClient, HttpResponse } from "./obj/http-client";
|
package/build/index.js
CHANGED
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.s_clientMode = exports.HttpResolver = void 0;
|
|
18
18
|
__exportStar(require("./func/u"), exports);
|
|
19
19
|
__exportStar(require("./func/u-file"), exports);
|
|
20
|
-
var http_resolver_1 = require("./prcs/http
|
|
20
|
+
var http_resolver_1 = require("./prcs/http-resolver");
|
|
21
21
|
Object.defineProperty(exports, "HttpResolver", { enumerable: true, get: function () { return http_resolver_1.HttpResolver; } });
|
|
22
|
-
var http_resolver_context_1 = require("./prcs/http
|
|
22
|
+
var http_resolver_context_1 = require("./prcs/http-resolver-context");
|
|
23
23
|
Object.defineProperty(exports, "s_clientMode", { enumerable: true, get: function () { return http_resolver_context_1.s_clientMode; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IncomingHttpHeaders, OutgoingHttpHeaders } from "http";
|
|
2
|
-
import { ClientMode, ProxyConfig } from "
|
|
2
|
+
import { ClientMode, ProxyConfig } from "../prcs/http-resolver";
|
|
3
3
|
export interface ClientOption {
|
|
4
4
|
/**
|
|
5
5
|
* {@link s_clientMode} that is imitated. default is random between chrome or firefox.
|
|
@@ -30,7 +30,7 @@ export interface RequestOption {
|
|
|
30
30
|
*/
|
|
31
31
|
responseType?: "string" | "buffer";
|
|
32
32
|
}
|
|
33
|
-
export interface HttpResponse<T = string
|
|
33
|
+
export interface HttpResponse<T = string> {
|
|
34
34
|
/**
|
|
35
35
|
* http headers in the response.
|
|
36
36
|
*/
|
|
@@ -40,7 +40,7 @@ export interface HttpResponse<T = string | Buffer> {
|
|
|
40
40
|
*/
|
|
41
41
|
payload?: T;
|
|
42
42
|
}
|
|
43
|
-
export interface
|
|
43
|
+
export interface HttpClient {
|
|
44
44
|
/**
|
|
45
45
|
* request GET to the url with new context.
|
|
46
46
|
* @param url target url. (currently https only)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClientOption, HttpResponse,
|
|
1
|
+
import { ClientOption, HttpResponse, HttpClient, RequestOption } from "../obj/http-client";
|
|
2
2
|
import { Loggable } from "xjs-common";
|
|
3
3
|
export declare const s_clientMode: {
|
|
4
4
|
nodejs: {
|
|
@@ -14,7 +14,7 @@ export declare const s_clientMode: {
|
|
|
14
14
|
cipherOrder: number[];
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
-
export declare class HttpResolverContext implements
|
|
17
|
+
export declare class HttpResolverContext implements HttpClient {
|
|
18
18
|
readonly cmv: number;
|
|
19
19
|
private _l;
|
|
20
20
|
private readonly _als;
|
|
@@ -42,8 +42,8 @@ const url_1 = require("url");
|
|
|
42
42
|
const https_1 = require("https");
|
|
43
43
|
const http_1 = require("http");
|
|
44
44
|
const async_hooks_1 = require("async_hooks");
|
|
45
|
-
const u_file_1 = require("
|
|
46
|
-
const u_1 = require("
|
|
45
|
+
const u_file_1 = require("../func/u-file");
|
|
46
|
+
const u_1 = require("../func/u");
|
|
47
47
|
const xjs_common_1 = require("xjs-common");
|
|
48
48
|
const stream_1 = require("stream");
|
|
49
49
|
exports.s_clientMode = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Loggable } from "xjs-common";
|
|
2
2
|
import { HttpResolverContext } from "./http-resolver-context";
|
|
3
|
-
import { ClientOption, HttpResponse,
|
|
3
|
+
import { ClientOption, HttpResponse, HttpClient, RequestOption } from "../obj/http-client";
|
|
4
4
|
export interface ClientMode {
|
|
5
5
|
id: number;
|
|
6
6
|
cipherOrder: number[];
|
|
@@ -13,7 +13,7 @@ export interface ProxyConfig {
|
|
|
13
13
|
pass: string;
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
export declare class HttpResolver implements
|
|
16
|
+
export declare class HttpResolver implements HttpClient {
|
|
17
17
|
private _baseCmv;
|
|
18
18
|
private _l;
|
|
19
19
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xjs-node",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "library modules for nodejs + typescript that bundled general-purpose implementations.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,4 +38,4 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"xjs-common": "^13.0.0"
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
}
|
|
File without changes
|
|
File without changes
|