ddan-js 2.6.18 → 2.6.19

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.
@@ -1,24 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const _object_1 = require("../common/_object");
4
+ const _root_1 = require("../common/_root");
5
+ const nodeTypes_1 = require("../common/internal/nodeTypes");
4
6
  /** `Object#toString` result references. */
5
7
  var argsTag = '[object Arguments]', funcTag = '[object Function]', genTag = '[object GeneratorFunction]', asyncTag = '[object AsyncFunction]', stringTag = '[object String]', promiseTag = '[object Promise]';
6
8
  var MAX_SAFE_INTEGER = 9007199254740991, NAN = 0 / 0;
7
9
  /** Used to detect unsigned integer values. */
8
10
  const reIsUint = /^(?:0|[1-9]\d*)$/;
11
+ const nativeIsBuffer = _root_1.default?.Buffer?.isBuffer;
12
+ const reTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/;
13
+ /* Node.js helper references. */
14
+ const nodeIsTypedArray = nodeTypes_1.default && nodeTypes_1.default.isTypedArray;
9
15
  function is(val, type) {
10
16
  return _object_1.default.getTag(val) === `[object ${type}]`;
11
17
  }
12
18
  function isNumber(value) {
13
- return _object_1.default.getTag(value) === "[object Number]";
19
+ return _object_1.default.getTag(value) === '[object Number]';
14
20
  }
15
21
  function isString(value) {
16
- return typeof value == 'string' ||
17
- (!isArray(value) && isObjectLike(value) && _object_1.default.getTag(value) == stringTag);
22
+ return (typeof value == 'string' ||
23
+ (!isArray(value) && isObjectLike(value) && _object_1.default.getTag(value) == stringTag));
18
24
  }
19
25
  function isObject(value) {
20
26
  const type = typeof value;
21
- return value != null && (type == "object" || type == "function");
27
+ return value != null && (type == 'object' || type == 'function');
22
28
  }
23
29
  function isObjectLike(value) {
24
30
  return value != null && typeof value == 'object';
@@ -37,7 +43,8 @@ function isPlainObject(value) {
37
43
  return Object.getPrototypeOf(value) === proto;
38
44
  }
39
45
  function isSymbol(value) {
40
- return typeof value === 'symbol' || (isObjectLike(value) && _object_1.default.getTag(value) === '[object Symbol]');
46
+ return (typeof value === 'symbol' ||
47
+ (isObjectLike(value) && _object_1.default.getTag(value) === '[object Symbol]'));
41
48
  }
42
49
  const isArray = Array.isArray;
43
50
  function isArrayLike(value) {
@@ -55,22 +62,24 @@ function isPromise(value) {
55
62
  return tag === promiseTag;
56
63
  }
57
64
  function isLength(value) {
58
- return typeof value == 'number' &&
59
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
65
+ return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
60
66
  }
61
67
  function isIndex(value, length) {
62
68
  length = length == null ? MAX_SAFE_INTEGER : length;
63
- return !!length &&
69
+ return (!!length &&
64
70
  (typeof value == 'number' || reIsUint.test(value)) &&
65
- (value > -1 && value % 1 == 0 && value < length);
71
+ value > -1 &&
72
+ value % 1 == 0 &&
73
+ value < length);
66
74
  }
67
75
  function isPrototype(value) {
68
76
  var Ctor = value && value.constructor, proto = (typeof Ctor == 'function' && Ctor.prototype) || Object.prototype;
69
77
  return value === proto;
70
78
  }
71
79
  function isArguments(value) {
72
- return isArrayLikeObject(value) && _object_1.default.hasOwnProperty.call(value, 'callee') &&
73
- (!_object_1.default.propertyIsEnumerable.call(value, 'callee') || _object_1.default.toString.call(value) == argsTag);
80
+ return (isArrayLikeObject(value) &&
81
+ _object_1.default.hasOwnProperty.call(value, 'callee') &&
82
+ (!_object_1.default.propertyIsEnumerable.call(value, 'callee') || _object_1.default.toString.call(value) == argsTag));
74
83
  }
75
84
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
76
85
  const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
@@ -83,6 +92,37 @@ const isUint8Array = (data) => {
83
92
  const isArrayBuffer = (data) => {
84
93
  return data instanceof ArrayBuffer;
85
94
  };
95
+ const isTypedArray = nodeIsTypedArray
96
+ ? (value) => nodeIsTypedArray(value)
97
+ : (value) => isObjectLike(value) && reTypedTag.test(_object_1.default.getTag(value));
98
+ const isBuffer = typeof nativeIsBuffer === 'function' ? nativeIsBuffer : () => false;
99
+ const isEmpty = (value) => {
100
+ if (value == null) {
101
+ return true;
102
+ }
103
+ if (isArrayLike(value) &&
104
+ (Array.isArray(value) ||
105
+ typeof value === 'string' ||
106
+ typeof value.splice === 'function' ||
107
+ isBuffer(value) ||
108
+ isTypedArray(value) ||
109
+ isArguments(value))) {
110
+ return !value.length;
111
+ }
112
+ const tag = _object_1.default.getTag(value);
113
+ if (tag === '[object Map]' || tag === '[object Set]') {
114
+ return !value.size;
115
+ }
116
+ if (isPrototype(value)) {
117
+ return !Object.keys(value).length;
118
+ }
119
+ for (const key in value) {
120
+ if (_object_1.default.hasOwnProperty.call(value, key)) {
121
+ return false;
122
+ }
123
+ }
124
+ return true;
125
+ };
86
126
  exports.default = {
87
127
  is,
88
128
  isNumber,
@@ -103,5 +143,6 @@ exports.default = {
103
143
  isNode,
104
144
  isBlobOrBuffer,
105
145
  isUint8Array,
106
- isArrayBuffer
146
+ isArrayBuffer,
147
+ isEmpty,
107
148
  };
@@ -1,3 +1,3 @@
1
1
  /** Detect free variable `global` from Node.js. */
2
- declare var freeGlobal: any;
2
+ declare const freeGlobal: any;
3
3
  export default freeGlobal;
@@ -1,3 +1,3 @@
1
1
  /** Used as a reference to the global object. */
2
- declare var root: any;
2
+ declare const root: any;
3
3
  export default root;
@@ -0,0 +1,3 @@
1
+ /** Used to access faster Node.js helpers. */
2
+ declare const nodeTypes: any;
3
+ export default nodeTypes;
@@ -500,8 +500,8 @@ declare const dWeb: {
500
500
  };
501
501
  declare const dNode: {
502
502
  Ecdh: typeof import("./modules/node/ecdh").default;
503
- EcdhSpki: typeof import("./modules/node/ecdhSpki").default;
504
- SockServer: typeof import("./modules/node/sockServer").SockServer;
503
+ EcdhSpki: typeof import("./modules/node/ecdh-spki").default;
504
+ SocksServer: typeof import("./modules/node/socks-server").SocksServer;
505
505
  brotliCompress: typeof import("./modules/node/brotli").brotliCompress;
506
506
  brotliDecompress: typeof import("./modules/node/brotli").brotliDecompress;
507
507
  };
@@ -1,10 +1,10 @@
1
1
  import Ecdh from "./ecdh";
2
- import EcdhSpki from "./ecdhSpki";
3
- import { SockServer } from "./sockServer";
2
+ import EcdhSpki from "./ecdh-spki";
3
+ import { SocksServer } from "./socks-server";
4
4
  declare const _default: {
5
5
  Ecdh: typeof Ecdh;
6
6
  EcdhSpki: typeof EcdhSpki;
7
- SockServer: typeof SockServer;
7
+ SocksServer: typeof SocksServer;
8
8
  brotliCompress: typeof import("./brotli").brotliCompress;
9
9
  brotliDecompress: typeof import("./brotli").brotliDecompress;
10
10
  };
@@ -5,7 +5,7 @@ interface IProxyConfig {
5
5
  userId: string;
6
6
  password: string;
7
7
  }
8
- export declare class SockServer {
8
+ export declare class SocksServer {
9
9
  private upstreamProxy;
10
10
  private server;
11
11
  private clientSockets;
@@ -13,7 +13,7 @@ export declare class SockServer {
13
13
  private connectionPool;
14
14
  __debug: boolean;
15
15
  constructor(upstreamProxy: IProxyConfig, allowedDomains?: string[], debug?: boolean);
16
- validateProxyConfig(proxyConfig: IProxyConfig): "无效的上游代理 IP 地址" | "无效的上游代理端口" | "无效的上游代理用户名" | "无效的上游代理密码" | "";
16
+ validateProxyConfig(): "无效的上游代理 IP 地址" | "无效的上游代理端口" | "无效的上游代理用户名" | "无效的上游代理密码" | "";
17
17
  start(startPort?: number): Promise<number>;
18
18
  private findAvailablePort;
19
19
  private handleSocksConnection;
@@ -33,5 +33,6 @@ declare const _default: {
33
33
  isBlobOrBuffer: (data: any) => boolean;
34
34
  isUint8Array: (data: any) => boolean;
35
35
  isArrayBuffer: (data: any) => boolean;
36
+ isEmpty: (value: any) => boolean;
36
37
  };
37
38
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ddan-js",
3
- "version": "2.6.18",
3
+ "version": "2.6.19",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "ddan-js",