full-utils 3.0.6 → 3.0.8
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/dist/browser.cjs +1 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/browser.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3146
- package/dist/index.d.ts +3 -3146
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -145
- package/dist/node.d.ts +1 -145
- package/dist/node.mjs +1 -1
- package/dist/node.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node.d.cts
CHANGED
|
@@ -1,166 +1,22 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { JsonLike, PasswordOptions, TimeParts, UniqueDeepOptions, arrFuncArgs, arrReplaceTemplate, arrSplitBatches, arrUniqueDeep, boolNormalize, dateFloorMin, datePartsSec, dateSecParts, dateStr, env, ipNumStr, ipStrNum, isArr, isArrFilled, isBool, isBoolOrBoolTree, isClass, isDate, isEmail, isExists, isFunc, isIpAddr, isMacAddr, isNum, isNumFloat, isNumN, isNumNZ, isNumP, isNumPZ, isObj, isObjFilled, isObjFlat, isPassword, isPhone, isStr, isStrAscDesc, isStrBool, isStrFilled, isVar, numNormalize, strLowerCase, strNormalCase, strNormalize, strNull, strPhone, strTrim, strUndefined, urlDecode, urlObj, wait } from './index.cjs';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Options controlling TCP connection behavior, request formatting, and response handling.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
3
|
interface NetTCPOptions {
|
|
9
|
-
/**
|
|
10
|
-
* Remote TCP port to connect to.
|
|
11
|
-
*
|
|
12
|
-
* @defaultValue 4028
|
|
13
|
-
* @remarks Must be an integer in the range 1–65535, otherwise `EBADPORT` is thrown.
|
|
14
|
-
*/
|
|
15
4
|
port?: number;
|
|
16
|
-
/**
|
|
17
|
-
* Idle timeout in milliseconds applied to the underlying socket.
|
|
18
|
-
* If no data is received within this period after connection, the operation fails.
|
|
19
|
-
*
|
|
20
|
-
* @defaultValue 0 (no idle timeout)
|
|
21
|
-
* @remarks On expiry, the promise rejects with `ETIMEDOUT` ("Idle timeout").
|
|
22
|
-
*/
|
|
23
5
|
timeoutMs?: number;
|
|
24
|
-
/**
|
|
25
|
-
* Cooperative cancellation token. If the signal is already aborted (or aborts later),
|
|
26
|
-
* the operation is terminated early.
|
|
27
|
-
*
|
|
28
|
-
* @remarks Rejects with `EABORT` ("Operation cancelled").
|
|
29
|
-
*/
|
|
30
6
|
signal?: AbortSignal;
|
|
31
|
-
/**
|
|
32
|
-
* Hard cap on response size in bytes. If the cumulative number of bytes read
|
|
33
|
-
* exceeds this limit, the read is aborted.
|
|
34
|
-
*
|
|
35
|
-
* @defaultValue 0 (no limit)
|
|
36
|
-
* @remarks On overflow, rejects with `ERESPONSE_TOO_LARGE`.
|
|
37
|
-
*/
|
|
38
7
|
maxBytes?: number;
|
|
39
|
-
/**
|
|
40
|
-
* When `true`, call `socket.end()` immediately after the request payload is fully written.
|
|
41
|
-
* This is useful for protocols where the client signals “no more data” by half-closing.
|
|
42
|
-
*
|
|
43
|
-
* @defaultValue false
|
|
44
|
-
*/
|
|
45
8
|
halfCloseAfterWrite?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Optional line terminator automatically appended to the outgoing message.
|
|
48
|
-
*
|
|
49
|
-
* @defaultValue '' (no terminator)
|
|
50
|
-
* @remarks Common values are `'\n'` or `'\r\n'` for CRLF-terminated protocols.
|
|
51
|
-
*/
|
|
52
9
|
lineTerminator?: '' | '\n' | '\r\n';
|
|
53
|
-
/**
|
|
54
|
-
* Separate timeout for the **connect phase** (DNS+TCP handshake).
|
|
55
|
-
* If the connection is not established within this period, the operation fails.
|
|
56
|
-
*
|
|
57
|
-
* @defaultValue 0 (no connect timeout)
|
|
58
|
-
* @remarks On expiry, rejects with `ETIMEDOUT` ("Connect timed out").
|
|
59
|
-
*/
|
|
60
10
|
connectTimeoutMs?: number;
|
|
61
|
-
/**
|
|
62
|
-
* Text encoding used to encode the outgoing message and decode the response.
|
|
63
|
-
*
|
|
64
|
-
* @defaultValue 'utf8'
|
|
65
|
-
* @remarks The accepted values are `'utf8'` or `'utf-8'` (normalized to `'utf8'`).
|
|
66
|
-
*/
|
|
67
11
|
encoding?: 'utf8' | 'utf-8';
|
|
68
12
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Error object shape for socket-level failures. Extends the standard {@link Error}
|
|
71
|
-
* with common Node.js errno-style fields when available.
|
|
72
|
-
*
|
|
73
|
-
* @public
|
|
74
|
-
*/
|
|
75
13
|
interface TcpError extends Error {
|
|
76
|
-
/**
|
|
77
|
-
* Optional string error code (e.g., `'ECONNREFUSED'`, `'ETIMEDOUT'`, `'EPIPE'`).
|
|
78
|
-
*/
|
|
79
14
|
code?: string;
|
|
80
|
-
/**
|
|
81
|
-
* Optional numeric errno associated with low-level system errors.
|
|
82
|
-
*/
|
|
83
15
|
errno?: number;
|
|
84
|
-
/**
|
|
85
|
-
* The system call that failed, when available (e.g., `'connect'`, `'read'`, `'write'`).
|
|
86
|
-
*/
|
|
87
16
|
syscall?: string;
|
|
88
|
-
/**
|
|
89
|
-
* Related filesystem/IPC path when applicable (usually `undefined` for TCP).
|
|
90
|
-
*/
|
|
91
17
|
path?: string;
|
|
92
18
|
}
|
|
93
19
|
|
|
94
|
-
/**
|
|
95
|
-
* Open a TCP connection to a host, send a text payload, and return the server’s response as a string.
|
|
96
|
-
*
|
|
97
|
-
* @param message - The request body to send. If `lineTerminator` is set, it is appended automatically.
|
|
98
|
-
* @param host - Hostname or IP address to connect to.
|
|
99
|
-
* @param options - Behavior and safety knobs for the connection, timeouts, encoding, and buffering.
|
|
100
|
-
* @param options.port - Remote TCP port. Default: 4028}
|
|
101
|
-
* @param options.timeoutMs - Idle timeout after connect/read in milliseconds. Default: 0}
|
|
102
|
-
* @param options.signal - AbortSignal for cooperative cancellation.
|
|
103
|
-
* @param options.maxBytes - Maximum response size in bytes; 0 means unlimited. Default: 0}
|
|
104
|
-
* @param options.halfCloseAfterWrite - Call `socket.end()` after writing the request. Default: false}
|
|
105
|
-
* @param options.lineTerminator - Optional `'\n'` / `'\r\n'` suffix to append. Default: ''}
|
|
106
|
-
* @param options.connectTimeoutMs - Timeout for establishing the connection. Default: 0}
|
|
107
|
-
* @param options.encoding - `'utf8'` or `'utf-8'` used for I/O. Default: 'utf8'}
|
|
108
|
-
*
|
|
109
|
-
* @returns A promise that resolves to the full response string (decoded using `encoding`).
|
|
110
|
-
*
|
|
111
|
-
* @throws {Error} ENODEONLY
|
|
112
|
-
* Thrown when executed in a non-Node.js environment (e.g., a browser).
|
|
113
|
-
*
|
|
114
|
-
* @throws {Error} EBADHOST
|
|
115
|
-
* Thrown when `host` is not a non-empty string.
|
|
116
|
-
*
|
|
117
|
-
* @throws {Error} EBADMSG
|
|
118
|
-
* Thrown when `message` is not a non-empty string.
|
|
119
|
-
*
|
|
120
|
-
* @throws {Error} EBADPORT
|
|
121
|
-
* Thrown when `port` is outside the range 1–65535 or not an integer.
|
|
122
|
-
*
|
|
123
|
-
* @throws {Error} ENETIMPORT
|
|
124
|
-
* Thrown if dynamic import of the `node:net` module fails.
|
|
125
|
-
*
|
|
126
|
-
* @throws {Error} EABORT
|
|
127
|
-
* Thrown if the provided {@link AbortSignal} is already aborted or aborts during the operation.
|
|
128
|
-
*
|
|
129
|
-
* @throws {Error} ETIMEDOUT
|
|
130
|
-
* Thrown in these cases:
|
|
131
|
-
* - `"Connect timed out"`: connect phase exceeded `connectTimeoutMs`.
|
|
132
|
-
* - `"Idle timeout"`: no data within `timeoutMs` after connection.
|
|
133
|
-
*
|
|
134
|
-
* @throws {Error} ERESPONSE_TOO_LARGE
|
|
135
|
-
* Thrown when the accumulated response exceeds `maxBytes`.
|
|
136
|
-
*
|
|
137
|
-
* @throws {TcpError}
|
|
138
|
-
* Any socket `'error'` event is forwarded (e.g., `ECONNREFUSED`, `ENOTFOUND`, `EPIPE`).
|
|
139
|
-
*
|
|
140
|
-
* @remarks
|
|
141
|
-
* - **Lifecycle:** The socket’s listeners are cleaned up and the socket destroyed on settle.
|
|
142
|
-
* - **Close semantics:** If the socket emits `'close'` with `hadError=true`, the promise rejects with `ECLOSE`.
|
|
143
|
-
* - **Performance:** If you expect large responses, set a realistic `maxBytes` to avoid excessive memory usage.
|
|
144
|
-
* - **Protocols:** For request/response style text protocols (e.g., simple line-based services), set
|
|
145
|
-
* `lineTerminator` (e.g., `'\n'`) and optionally `halfCloseAfterWrite=true` if the server expects EOF to start responding.
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* ```ts
|
|
149
|
-
* // CRLF-terminated request with half-close to signal EOF
|
|
150
|
-
* const resp = await netTCP('STATUS', '192.0.2.10', {
|
|
151
|
-
* port: 9000,
|
|
152
|
-
* lineTerminator: '\r\n',
|
|
153
|
-
* halfCloseAfterWrite: true,
|
|
154
|
-
* timeoutMs: 3000,
|
|
155
|
-
* maxBytes: 256 * 1024, // 256 KiB cap
|
|
156
|
-
* });
|
|
157
|
-
* console.log(resp);
|
|
158
|
-
* ```
|
|
159
|
-
*
|
|
160
|
-
* @see AbortSignal
|
|
161
|
-
* @see https://nodejs.org/api/net.html Node.js net module
|
|
162
|
-
* @since 2.0.0
|
|
163
|
-
*/
|
|
164
20
|
declare function netTCP(message: string, host: string, { port, timeoutMs, connectTimeoutMs, encoding, signal, maxBytes, halfCloseAfterWrite, lineTerminator, }?: NetTCPOptions): Promise<string>;
|
|
165
21
|
|
|
166
22
|
export { type NetTCPOptions, type TcpError, netTCP };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,166 +1,22 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { JsonLike, PasswordOptions, TimeParts, UniqueDeepOptions, arrFuncArgs, arrReplaceTemplate, arrSplitBatches, arrUniqueDeep, boolNormalize, dateFloorMin, datePartsSec, dateSecParts, dateStr, env, ipNumStr, ipStrNum, isArr, isArrFilled, isBool, isBoolOrBoolTree, isClass, isDate, isEmail, isExists, isFunc, isIpAddr, isMacAddr, isNum, isNumFloat, isNumN, isNumNZ, isNumP, isNumPZ, isObj, isObjFilled, isObjFlat, isPassword, isPhone, isStr, isStrAscDesc, isStrBool, isStrFilled, isVar, numNormalize, strLowerCase, strNormalCase, strNormalize, strNull, strPhone, strTrim, strUndefined, urlDecode, urlObj, wait } from './index.js';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Options controlling TCP connection behavior, request formatting, and response handling.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
3
|
interface NetTCPOptions {
|
|
9
|
-
/**
|
|
10
|
-
* Remote TCP port to connect to.
|
|
11
|
-
*
|
|
12
|
-
* @defaultValue 4028
|
|
13
|
-
* @remarks Must be an integer in the range 1–65535, otherwise `EBADPORT` is thrown.
|
|
14
|
-
*/
|
|
15
4
|
port?: number;
|
|
16
|
-
/**
|
|
17
|
-
* Idle timeout in milliseconds applied to the underlying socket.
|
|
18
|
-
* If no data is received within this period after connection, the operation fails.
|
|
19
|
-
*
|
|
20
|
-
* @defaultValue 0 (no idle timeout)
|
|
21
|
-
* @remarks On expiry, the promise rejects with `ETIMEDOUT` ("Idle timeout").
|
|
22
|
-
*/
|
|
23
5
|
timeoutMs?: number;
|
|
24
|
-
/**
|
|
25
|
-
* Cooperative cancellation token. If the signal is already aborted (or aborts later),
|
|
26
|
-
* the operation is terminated early.
|
|
27
|
-
*
|
|
28
|
-
* @remarks Rejects with `EABORT` ("Operation cancelled").
|
|
29
|
-
*/
|
|
30
6
|
signal?: AbortSignal;
|
|
31
|
-
/**
|
|
32
|
-
* Hard cap on response size in bytes. If the cumulative number of bytes read
|
|
33
|
-
* exceeds this limit, the read is aborted.
|
|
34
|
-
*
|
|
35
|
-
* @defaultValue 0 (no limit)
|
|
36
|
-
* @remarks On overflow, rejects with `ERESPONSE_TOO_LARGE`.
|
|
37
|
-
*/
|
|
38
7
|
maxBytes?: number;
|
|
39
|
-
/**
|
|
40
|
-
* When `true`, call `socket.end()` immediately after the request payload is fully written.
|
|
41
|
-
* This is useful for protocols where the client signals “no more data” by half-closing.
|
|
42
|
-
*
|
|
43
|
-
* @defaultValue false
|
|
44
|
-
*/
|
|
45
8
|
halfCloseAfterWrite?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Optional line terminator automatically appended to the outgoing message.
|
|
48
|
-
*
|
|
49
|
-
* @defaultValue '' (no terminator)
|
|
50
|
-
* @remarks Common values are `'\n'` or `'\r\n'` for CRLF-terminated protocols.
|
|
51
|
-
*/
|
|
52
9
|
lineTerminator?: '' | '\n' | '\r\n';
|
|
53
|
-
/**
|
|
54
|
-
* Separate timeout for the **connect phase** (DNS+TCP handshake).
|
|
55
|
-
* If the connection is not established within this period, the operation fails.
|
|
56
|
-
*
|
|
57
|
-
* @defaultValue 0 (no connect timeout)
|
|
58
|
-
* @remarks On expiry, rejects with `ETIMEDOUT` ("Connect timed out").
|
|
59
|
-
*/
|
|
60
10
|
connectTimeoutMs?: number;
|
|
61
|
-
/**
|
|
62
|
-
* Text encoding used to encode the outgoing message and decode the response.
|
|
63
|
-
*
|
|
64
|
-
* @defaultValue 'utf8'
|
|
65
|
-
* @remarks The accepted values are `'utf8'` or `'utf-8'` (normalized to `'utf8'`).
|
|
66
|
-
*/
|
|
67
11
|
encoding?: 'utf8' | 'utf-8';
|
|
68
12
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Error object shape for socket-level failures. Extends the standard {@link Error}
|
|
71
|
-
* with common Node.js errno-style fields when available.
|
|
72
|
-
*
|
|
73
|
-
* @public
|
|
74
|
-
*/
|
|
75
13
|
interface TcpError extends Error {
|
|
76
|
-
/**
|
|
77
|
-
* Optional string error code (e.g., `'ECONNREFUSED'`, `'ETIMEDOUT'`, `'EPIPE'`).
|
|
78
|
-
*/
|
|
79
14
|
code?: string;
|
|
80
|
-
/**
|
|
81
|
-
* Optional numeric errno associated with low-level system errors.
|
|
82
|
-
*/
|
|
83
15
|
errno?: number;
|
|
84
|
-
/**
|
|
85
|
-
* The system call that failed, when available (e.g., `'connect'`, `'read'`, `'write'`).
|
|
86
|
-
*/
|
|
87
16
|
syscall?: string;
|
|
88
|
-
/**
|
|
89
|
-
* Related filesystem/IPC path when applicable (usually `undefined` for TCP).
|
|
90
|
-
*/
|
|
91
17
|
path?: string;
|
|
92
18
|
}
|
|
93
19
|
|
|
94
|
-
/**
|
|
95
|
-
* Open a TCP connection to a host, send a text payload, and return the server’s response as a string.
|
|
96
|
-
*
|
|
97
|
-
* @param message - The request body to send. If `lineTerminator` is set, it is appended automatically.
|
|
98
|
-
* @param host - Hostname or IP address to connect to.
|
|
99
|
-
* @param options - Behavior and safety knobs for the connection, timeouts, encoding, and buffering.
|
|
100
|
-
* @param options.port - Remote TCP port. Default: 4028}
|
|
101
|
-
* @param options.timeoutMs - Idle timeout after connect/read in milliseconds. Default: 0}
|
|
102
|
-
* @param options.signal - AbortSignal for cooperative cancellation.
|
|
103
|
-
* @param options.maxBytes - Maximum response size in bytes; 0 means unlimited. Default: 0}
|
|
104
|
-
* @param options.halfCloseAfterWrite - Call `socket.end()` after writing the request. Default: false}
|
|
105
|
-
* @param options.lineTerminator - Optional `'\n'` / `'\r\n'` suffix to append. Default: ''}
|
|
106
|
-
* @param options.connectTimeoutMs - Timeout for establishing the connection. Default: 0}
|
|
107
|
-
* @param options.encoding - `'utf8'` or `'utf-8'` used for I/O. Default: 'utf8'}
|
|
108
|
-
*
|
|
109
|
-
* @returns A promise that resolves to the full response string (decoded using `encoding`).
|
|
110
|
-
*
|
|
111
|
-
* @throws {Error} ENODEONLY
|
|
112
|
-
* Thrown when executed in a non-Node.js environment (e.g., a browser).
|
|
113
|
-
*
|
|
114
|
-
* @throws {Error} EBADHOST
|
|
115
|
-
* Thrown when `host` is not a non-empty string.
|
|
116
|
-
*
|
|
117
|
-
* @throws {Error} EBADMSG
|
|
118
|
-
* Thrown when `message` is not a non-empty string.
|
|
119
|
-
*
|
|
120
|
-
* @throws {Error} EBADPORT
|
|
121
|
-
* Thrown when `port` is outside the range 1–65535 or not an integer.
|
|
122
|
-
*
|
|
123
|
-
* @throws {Error} ENETIMPORT
|
|
124
|
-
* Thrown if dynamic import of the `node:net` module fails.
|
|
125
|
-
*
|
|
126
|
-
* @throws {Error} EABORT
|
|
127
|
-
* Thrown if the provided {@link AbortSignal} is already aborted or aborts during the operation.
|
|
128
|
-
*
|
|
129
|
-
* @throws {Error} ETIMEDOUT
|
|
130
|
-
* Thrown in these cases:
|
|
131
|
-
* - `"Connect timed out"`: connect phase exceeded `connectTimeoutMs`.
|
|
132
|
-
* - `"Idle timeout"`: no data within `timeoutMs` after connection.
|
|
133
|
-
*
|
|
134
|
-
* @throws {Error} ERESPONSE_TOO_LARGE
|
|
135
|
-
* Thrown when the accumulated response exceeds `maxBytes`.
|
|
136
|
-
*
|
|
137
|
-
* @throws {TcpError}
|
|
138
|
-
* Any socket `'error'` event is forwarded (e.g., `ECONNREFUSED`, `ENOTFOUND`, `EPIPE`).
|
|
139
|
-
*
|
|
140
|
-
* @remarks
|
|
141
|
-
* - **Lifecycle:** The socket’s listeners are cleaned up and the socket destroyed on settle.
|
|
142
|
-
* - **Close semantics:** If the socket emits `'close'` with `hadError=true`, the promise rejects with `ECLOSE`.
|
|
143
|
-
* - **Performance:** If you expect large responses, set a realistic `maxBytes` to avoid excessive memory usage.
|
|
144
|
-
* - **Protocols:** For request/response style text protocols (e.g., simple line-based services), set
|
|
145
|
-
* `lineTerminator` (e.g., `'\n'`) and optionally `halfCloseAfterWrite=true` if the server expects EOF to start responding.
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* ```ts
|
|
149
|
-
* // CRLF-terminated request with half-close to signal EOF
|
|
150
|
-
* const resp = await netTCP('STATUS', '192.0.2.10', {
|
|
151
|
-
* port: 9000,
|
|
152
|
-
* lineTerminator: '\r\n',
|
|
153
|
-
* halfCloseAfterWrite: true,
|
|
154
|
-
* timeoutMs: 3000,
|
|
155
|
-
* maxBytes: 256 * 1024, // 256 KiB cap
|
|
156
|
-
* });
|
|
157
|
-
* console.log(resp);
|
|
158
|
-
* ```
|
|
159
|
-
*
|
|
160
|
-
* @see AbortSignal
|
|
161
|
-
* @see https://nodejs.org/api/net.html Node.js net module
|
|
162
|
-
* @since 2.0.0
|
|
163
|
-
*/
|
|
164
20
|
declare function netTCP(message: string, host: string, { port, timeoutMs, connectTimeoutMs, encoding, signal, maxBytes, halfCloseAfterWrite, lineTerminator, }?: NetTCPOptions): Promise<string>;
|
|
165
21
|
|
|
166
22
|
export { type NetTCPOptions, type TcpError, netTCP };
|
package/dist/node.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function cn(n){if(!u(n))return [n];let t=n.trim();if(t==="")return [];if(t.startsWith("[")&&t.endsWith("]")&&(t=t.slice(1,-1).trim(),t===""))return [];let r="",e=false,i=null,o=false,s=0,l=0,m=0,x=[],P=()=>{let c=r.trim();c!==""&&x.push(c),r="";};for(let c=0;c<t.length;c++){let f=t[c];if(e){if(r+=f,o){o=false;continue}if(f==="\\"){o=true;continue}f===i&&(e=false,i=null);continue}if(f==='"'||f==="'"){e=true,i=f,r+=f;continue}if(f==="("){s++,r+=f;continue}if(f===")"){s=Math.max(0,s-1),r+=f;continue}if(f==="["){l++,r+=f;continue}if(f==="]"){l=Math.max(0,l-1),r+=f;continue}if(f==="{"){m++,r+=f;continue}if(f==="}"){m=Math.max(0,m-1),r+=f;continue}if(f===","&&s===0&&l===0&&m===0){P();continue}r+=f;}return r.length&&P(),x.map(c=>{if(c.startsWith("$")&&c.includes("(")&&c.endsWith(")"))return c;if(c==="null")return null;if(c==="undefined")return;if(J(c))return M(c);let f=W(c);if(Number.isFinite(f))return f;if(c==="Infinity")return 1/0;if(c==="-Infinity")return -1/0;let g=String(c||"");if(g.length>=2&&(g.startsWith("'")&&g.endsWith("'")||g.startsWith('"')&&g.endsWith('"')))return g.slice(1,-1).replace(/\\\\/g,"\\").replace(/\\'/g,"'").replace(/\\"/g,'"');if(g.startsWith("{")&&g.endsWith("}")||g.startsWith("[")&&g.endsWith("]"))try{return U(g)}catch{}return g})}function ln(n,t){if(!Number.isInteger(t)||t<=0)return [];let r=[],e=0;for(;e<n.length;)r.push(n.slice(e,e+t)),e+=t;return r}function z(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function v(n){return n==null||typeof n!="object"||n instanceof Date}function nn(n,t){return Array.isArray(n)?Array.isArray(t)?t:[t]:t}function R(n,t){if(n==null)return n;if(v(t))return nn(n,t);if(Array.isArray(n))return n.map(i=>R(i,t));if(!z(n)||!z(t))return n;let r={...n},e=false;for(let i of Object.keys(t)){if(!(i in n))continue;let o=R(n[i],t[i]);o!==n[i]&&(r[i]=o,e=true);}return e?r:n}function pn(n,t){return R(n,t)}function tn(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)}function rn(n){let t=new WeakSet,r=e=>{if(e===null)return "null";let i=typeof e;if(i==="string")return JSON.stringify(e);if(i==="number")return Number.isNaN(e)?'"__NaN__"':String(e);if(i==="boolean")return e?"true":"false";if(i==="undefined")return '"__undefined__"';if(i==="bigint")return `"__bigint__:${String(e)}"`;if(i==="function")return '"__function__"';if(e instanceof Date)return `"__date__:${e.toISOString()}"`;if(Array.isArray(e))return "["+e.map(r).join(",")+"]";if(i==="object"&&e){let o=e;return t.has(o)?'"__circular__"':(t.add(o),"{"+Object.keys(o).sort().map(m=>JSON.stringify(m)+":"+r(o[m])).join(",")+"}")}return JSON.stringify(String(e))};return r(n)}function en(n){if(n===null)return "null";let t=typeof n;return t==="string"?"s:"+n:t==="number"?"n:"+(Number.isNaN(n)?"__NaN__":n):t==="boolean"?"b:"+n:t==="undefined"?"u:":t==="bigint"?"bi:"+String(n):n instanceof Date?"d:"+n.toISOString():"o:"+rn(n)}function gn(n,t){let r=t?.keyFn??en,e=i=>{if(Array.isArray(i)){let o=i.map(e),s=new Set,l=[];for(let m of o){let x=r(m);s.has(x)||(s.add(x),l.push(m));}return l}if(tn(i)){let o={};for(let s of Object.keys(i))o[s]=e(i[s]);return o}return i};return e(n)}function M(n){switch(true){case j(n):return n;case S(n):return true;case Z(n):return false;case(a(n)&&["true","1","yes","on"].includes(String(n??"").trim().toLowerCase())):return true;case(a(n)&&["false","0","no","off"].includes(String(n??"").trim().toLowerCase())):return false}return false}async function wn(n=0){await new Promise(t=>setTimeout(()=>t(true),n));}function kn(n){return process.env[n]}function Tn(n=1,t=new Date){let r=Math.min(60,Math.max(1,Math.trunc(Math.abs(n)))),e=t.getMinutes(),i=Math.floor(e/r)*r,o=new Date(t);return o.setMinutes(i,0,0),o}function On(n=new Date){let t=m=>String(m).padStart(2,"0"),r=n.getFullYear(),e=t(n.getMonth()+1),i=t(n.getDate()),o=t(n.getHours()),s=t(n.getMinutes()),l=t(n.getSeconds());return `${r}-${e}-${i} ${o}:${s}:${l}`}function An(n){let{days:t=0,hours:r=0,minutes:e=0,seconds:i=0}=n;return t*86400+r*3600+e*60+i}function Dn(n){if(!Number.isFinite(n)||n<0)throw new Error("Invalid total seconds");let t=Math.floor(n/86400),r=Math.floor(n%86400/3600),e=Math.floor(n%3600/60),i=n%60;return {days:t,hours:r,minutes:e,seconds:i}}function En(n){let t=n.split(".").map(o=>Number(o));if(t.length!==4||t.some(o=>!Number.isInteger(o)||o<0||o>255))throw new Error("Invalid IPv4 address");let r=new ArrayBuffer(4),e=new DataView(r),i=0;for(;i<4;)e.setUint8(i,t[i]),i++;return e.getUint32(0,false)}function Rn(n){if(!S(n))return "";let t=new ArrayBuffer(4),r=new DataView(t);r.setUint32(0,n,false);let e=[],i=0;for(;i<4;)e.push(r.getUint8(i)),i++;return e.join(".")}function N(n){return Array.isArray(n)}function V(n){return N(n)&&n.length>0}function j(n){return typeof n=="boolean"}function Wn(n){if(n instanceof Date)return !Number.isNaN(n.getTime());if(u(n)||d(n)){let t=new Date(n);return !Number.isNaN(t.getTime())}return false}var on=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z]{2,})+$/;function Vn(n){return a(n)?on.test(n):false}function qn(n){return n!=null}function F(n){return typeof n=="function"}var sn=/^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/;function Yn(n){if(!u(n))return false;let t=n.trim();return sn.test(t)}function nt(n){return u(n)&&/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/.test(n)}function d(n){return typeof n=="number"&&Number.isFinite(n)}function it(n){return d(n)&&!Number.isInteger(n)}function ut(n){return d(n)&&n<0}function Z(n){return d(n)&&n<=0}function S(n){return d(n)&&n>0}function Q(n){return d(n)&&n>=0}function O(n){return typeof n=="object"&&n!==null&&Object.prototype.toString.call(n)==="[object Object]"&&!Array.isArray(n)}function E(n){return O(n)&&Object.keys(n).length>0}function St(n){return E(n)?Object.values(n).every(t=>t===null||!O(t)&&!N(t)||!F(t)):false}function Ot(n,{minLength:t=8,maxLength:r=256,requireUppercase:e=true,requireLowercase:i=true,requireDigit:o=true,requireSpecial:s=true}={}){return !(!u(n)||n.length<t||n.length>r||e&&!/[A-ZА-Я]/.test(n)||i&&!/[a-zа-я]/.test(n)||o&&!/\d/.test(n)||s&&!/[~!?@#$%^&*_\-+()\[\]{}><\\\/|"'.,:;=]/.test(n))}function Ft(n){if(!a(n)&&!d(n))return false;let t=String(n).trim();return !(t.startsWith("-")||(t.match(/\+/g)||[]).length>1||t.includes("+")&&!t.startsWith("+")||!/^\+?[0-9-]+$/.test(t)||t.length<3||t.length>20||!/[0-9]$/.test(t)||t.includes("--"))}function u(n){return typeof n=="string"}function J(n){if(!a(n))return false;let t=n.trim().toLowerCase();return t==="true"||t==="false"}function a(n){return u(n)&&n.trim().length>0}function Bt(n){if(!a(n))return false;let t=n.trim().toLowerCase();return t==="asc"||t==="desc"}function Mt(n){return u(n)&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(n)}function Wt(n){return F(n)&&/^class\s/.test(Function.prototype.toString.call(n))}var un=/^(['"`])([\s\S]*)\1$/;function _(n,t){let r=n.trim(),e=q(r);if(e.ok)return e.value;let i=un.exec(r);return i?i[2]:t?r:null}function q(n){try{return {ok:!0,value:JSON.parse(n)}}catch{}return {ok:false}}function U(n,t=false){if(n===null||d(n)||j(n))return n;if(V(n)){let r=n,e=[];for(let i of r)a(i)?e.push(_(String(i),t)):e.push(i);return e}if(E(n)){let r=n,e={};for(let i of Object.keys(r)){let o=r[i];a(o)?e[i]=_(String(o),t):e[i]=o;}return e}return N(n)||O(n)?n:a(n)?_(String(n),t):null}function Xt(n){try{return O(n)||N(n)?JSON.stringify(n):""}catch{}return ""}function H(n){let t=n.sign<0?"-":"",r=n.digitsInteger.toString();if(n.scale===0)return t+r;let e=n.scale-r.length;if(e>=0)return t+"0."+"0".repeat(e)+r;let i=r.length-n.scale,o=r.slice(0,i),s=r.slice(i);return t+o+"."+s}function K(n){return Number(H(n))}function B(n,t){let r=/^([0-9]+)(?:\.([0-9]*))?e([+\-]?[0-9]+)$/i.exec((()=>{let[o,s]=t.split(/e/i),[l,m=""]=o.split("."),x=l.replace(/^0+/,"")+m,P=parseInt(s,10)-m.length;return `${x||"0"}e${P}`})());if(!r)throw new Error("Failed to parse exponential notation.");let e=r[1],i=parseInt(r[3],10);if(Q(i))return e=e+"0".repeat(i),{sign:n,integerPart:e||"0",fractionalPart:""};{let o=-i;if(o>=e.length){let s="0".repeat(o-e.length);return {sign:n,integerPart:"0",fractionalPart:s+e}}else {let s=e.length-o;return {sign:n,integerPart:e.slice(0,s),fractionalPart:e.slice(s)}}}}function G(n){if(typeof n=="bigint"){let t=n<0n?-1:1,r=(n<0n?-n:n).toString();return {sign:t,integerPart:r,fractionalPart:""}}if(typeof n=="number"){if(!Number.isFinite(n))throw new Error("Input number is not finite.");let t=n<0?-1:1,e=Math.abs(n).toExponential(30);return B(t,e)}if(typeof n=="string"){let t=n.trim().replace(",",".");if(!t)throw new Error("Input string is empty.");let r=1;if((t.startsWith("+")||t.startsWith("-"))&&(r=t.startsWith("-")?-1:1,t=t.slice(1)),/^[0-9]*\.?[0-9]*(e[+\-]?[0-9]+)?$/i.test(t)){if(/e/i.test(t))return B(r,t);let[e="0",i=""]=t.split(".");return {sign:r,integerPart:e,fractionalPart:i}}throw new Error("Invalid numeric string.")}throw new Error("Unsupported input type.")}function $(n){let{sign:t,integerPart:r,fractionalPart:e}=G(n),i=r.replace(/^0+/,"")||"0",o=e.replace(/0+$/,""),s=i+o||"0";return {sign:t,digitsInteger:BigInt(s),scale:o.length}}function Y(n,t,r="half-up"){let e=Math.max(0,Math.trunc(t));if(n.scale<=e)return {...n};let i=n.scale-e,o=10n**BigInt(i),s=n.digitsInteger/o,l=n.digitsInteger%o;if(r==="trunc"||l===0n)return {sign:n.sign,digitsInteger:s,scale:e};let m=o/2n,P=l>=m?s+1n:s;return {sign:n.sign,digitsInteger:P,scale:e}}function W(n,t=1,r=false){try{return K(t>1?Y($(n),t,"half-up"):$(n))}catch(e){if(r)throw e}return 0}function X(n){if(!u(n))return "";let t=w(n);return a(t)?t.toLowerCase():""}function br(n){if(!u(n))return "";let t=X(n);return a(t)?t[0].toUpperCase()+t.slice(1):""}function kr(n){return u(n)&&w(n)===""||n===void 0?null:n}function Nr(n,t="+7"){if(!u(n))return null;let r=w(n).replace(/[\s\-().]/g,"");return /^00\d{8,15}$/.test(r)?r="+"+r.slice(2):/^\d{10}$/.test(r)?r=t+r:/^\d{9,15}$/.test(r)&&!r.startsWith("0")&&(r="+"+r),/^\+\d{10,15}$/.test(r)?r:null}function w(n,t=""){let r=String(u(n)?n.trim().normalize("NFKC").replace(/[\u200B-\u200D\uFEFF]/g,""):"");return t?r.split(t).filter(e=>!!e).join(t):r}function jr(n){return u(n)&&w(n)===""||n===null?void 0:n}var Ir=n=>{if(!u(n))return n;let t=String(w(n)||"");return t===""?null:String(t.toLowerCase()||"").replace(/\s+/g," ").replace(/\t+/g,"").replace(/\n+/g,"")};function Rr(n=""){return {}}function Cr(n){if(!a(n))return String(n);let t="____RAW_PERCENT____",r=n.replace(/%(?![0-9A-Fa-f]{2})/g,t),e=new Set(["22","7B","7D","3A","2C","5B","5D","5C"]);return r.replace(/%([0-9A-Fa-f]{2})/g,(o,s)=>{let l=s.toUpperCase();return e.has(l)?decodeURIComponent(`%${l}`):`%${l}`}).split(t).join("%")}function b(n,t){let r=new Error(t??n);return r.code=n,r}var I=null;async function zr(n,t,{port:r=4028,timeoutMs:e=0,connectTimeoutMs:i=0,encoding:o="utf8",signal:s,maxBytes:l=0,halfCloseAfterWrite:m=false,lineTerminator:x=""}={}){if(!(typeof process<"u"&&!!process.versions?.node))throw b("ENODEONLY","connectTCP is Node-only");if(!a(t))throw b("EBADHOST","`host` must be a non-empty string");if(!a(n))throw b("EBADMSG","`message` must be a non-empty string");if(!S(r)||r<1||r>65535)throw b("EBADPORT","`port` must be an integer in range 1..65535");let c=o.toLowerCase()==="utf-8"?"utf8":o;if(!I)try{I=await import('net');}catch{}if(!I)throw b("ENETIMPORT","FATAL: node:net import failed");return new Promise((f,g)=>{let p=new I.Socket,A=false,D=0,h=null,C=()=>{p.destroyed||p.destroy(b("EABORT","Operation cancelled")),k(b("EABORT","Operation cancelled"));},k=(y,T)=>{A||(A=true,p.removeAllListeners(),s&&s.removeEventListener("abort",C),p.destroyed||p.destroy(),h&&clearTimeout(h),y?g(y):f(T??""));};if(s){if(s.aborted)return k(b("EABORT","Operation cancelled"));s.addEventListener("abort",C,{once:true});}S(i)&&(h=setTimeout(()=>k(b("ETIMEDOUT","Connect timed out")),i),h&&F(h.unref)&&h.unref()),S(e)&&(p.setTimeout(e),p.once("timeout",()=>k(b("ETIMEDOUT","Idle timeout"))));let L=[];p.on("data",y=>{if(A)return;let T=Buffer.isBuffer(y)?y:Buffer.from(y,c);if(S(l)&&D+T.length>l)return k(b("ERESPONSE_TOO_LARGE","Response exceeds maxBytes"));L.push(T),D+=T.length;}),p.once("end",()=>{if(A)return;let y=Buffer.concat(L,D).toString(c);k(void 0,y);}),p.once("close",y=>{if(A)return;let T=Buffer.concat(L,D).toString(c);y?k(b("ECLOSE","Socket closed with error")):k(void 0,T);}),p.once("error",y=>{A||k(y);}),p.once("connect",()=>{h&&(clearTimeout(h),h=null);let y=x?n+x:n;p.write(y,c)?m&&p.end():p.once("drain",()=>{m&&!A&&p.end();});}),p.connect({host:t,port:r});})}export{cn as arrFuncArgs,pn as arrReplaceTemplate,ln as arrSplitBatches,gn as arrUniqueDeep,M as boolNormalize,Tn as dateFloorMin,An as datePartsSec,Dn as dateSecParts,On as dateStr,kn as env,Rn as ipNumStr,En as ipStrNum,N as isArr,V as isArrFilled,j as isBool,Wt as isClass,Wn as isDate,Vn as isEmail,qn as isExists,F as isFunc,Yn as isIpAddr,nt as isMacAddr,d as isNum,it as isNumFloat,ut as isNumN,Z as isNumNZ,S as isNumP,Q as isNumPZ,O as isObj,E as isObjFilled,St as isObjFlat,Ot as isPassword,Ft as isPhone,u as isStr,Bt as isStrAscDesc,J as isStrBool,a as isStrFilled,Mt as isVar,U as jsonDecode,Xt as jsonEncode,q as jsonParse,_ as jsonStrLike,zr as netTCP,W as numNormalize,X as strLowerCase,br as strNormalCase,Ir as strNormalize,kr as strNull,Nr as strPhone,w as strTrim,jr as strUndefined,Cr as urlDecode,Rr as urlObj,wn as wait};//# sourceMappingURL=node.mjs.map
|
|
1
|
+
function it(t){if(!u(t))return [t];let n=t.trim();if(n==="")return [];if(n.startsWith("[")&&n.endsWith("]")&&(n=n.slice(1,-1).trim(),n===""))return [];let r="",e=false,i=null,o=false,s=0,a=0,l=0,h=[],N=()=>{let c=r.trim();c!==""&&h.push(c),r="";};for(let c=0;c<n.length;c++){let f=n[c];if(e){if(r+=f,o){o=false;continue}if(f==="\\"){o=true;continue}f===i&&(e=false,i=null);continue}if(f==='"'||f==="'"){e=true,i=f,r+=f;continue}if(f==="("){s++,r+=f;continue}if(f===")"){s=Math.max(0,s-1),r+=f;continue}if(f==="["){a++,r+=f;continue}if(f==="]"){a=Math.max(0,a-1),r+=f;continue}if(f==="{"){l++,r+=f;continue}if(f==="}"){l=Math.max(0,l-1),r+=f;continue}if(f===","&&s===0&&a===0&&l===0){N();continue}r+=f;}return r.length&&N(),h.map(c=>{if(c.startsWith("$")&&c.includes("(")&&c.endsWith(")"))return c;if(c==="null")return null;if(c==="undefined")return;if(W(c))return M(c);let f=z(c);if(Number.isFinite(f))return f;if(c==="Infinity")return 1/0;if(c==="-Infinity")return -1/0;let d=String(c||"");if(d.length>=2&&(d.startsWith("'")&&d.endsWith("'")||d.startsWith('"')&&d.endsWith('"')))return d.slice(1,-1).replace(/\\\\/g,"\\").replace(/\\'/g,"'").replace(/\\"/g,'"');if(d.startsWith("{")&&d.endsWith("}")||d.startsWith("[")&&d.endsWith("]"))try{return JSON.parse(d)}catch{}return d})}function st(t,n){if(!Number.isInteger(n)||n<=0)return [];let r=[],e=0;for(;e<t.length;)r.push(t.slice(e,e+n)),e+=n;return r}function L(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function K(t){return t==null||typeof t!="object"||t instanceof Date}function G(t,n){return Array.isArray(t)?Array.isArray(n)?n:[n]:n}function B(t,n){if(t==null)return t;if(K(n))return G(t,n);if(Array.isArray(t))return t.map(i=>B(i,n));if(!L(t)||!L(n))return t;let r={...t},e=false;for(let i of Object.keys(n)){if(!(i in t))continue;let o=B(t[i],n[i]);o!==t[i]&&(r[i]=o,e=true);}return e?r:t}function ft(t,n){return B(t,n)}function Y(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof Date)}function X(t){let n=new WeakSet,r=e=>{if(e===null)return "null";let i=typeof e;if(i==="string")return JSON.stringify(e);if(i==="number")return Number.isNaN(e)?'"__NaN__"':String(e);if(i==="boolean")return e?"true":"false";if(i==="undefined")return '"__undefined__"';if(i==="bigint")return `"__bigint__:${String(e)}"`;if(i==="function")return '"__function__"';if(e instanceof Date)return `"__date__:${e.toISOString()}"`;if(Array.isArray(e))return "["+e.map(r).join(",")+"]";if(i==="object"&&e){let o=e;return n.has(o)?'"__circular__"':(n.add(o),"{"+Object.keys(o).sort().map(l=>JSON.stringify(l)+":"+r(o[l])).join(",")+"}")}return JSON.stringify(String(e))};return r(t)}function v(t){if(t===null)return "null";let n=typeof t;return n==="string"?"s:"+t:n==="number"?"n:"+(Number.isNaN(t)?"__NaN__":t):n==="boolean"?"b:"+t:n==="undefined"?"u:":n==="bigint"?"bi:"+String(t):t instanceof Date?"d:"+t.toISOString():"o:"+X(t)}function at(t,n){let r=n?.keyFn??v,e=i=>{if(Array.isArray(i)){let o=i.map(e),s=new Set,a=[];for(let l of o){let h=r(l);s.has(h)||(s.add(h),a.push(l));}return a}if(Y(i)){let o={};for(let s of Object.keys(i))o[s]=e(i[s]);return o}return i};return e(t)}function M(t){switch(true){case D(t):return t;case S(t):return true;case U(t):return false;case(m(t)&&["true","1","yes","on"].includes(String(t??"").trim().toLowerCase())):return true;case(m(t)&&["false","0","no","off"].includes(String(t??"").trim().toLowerCase())):return false}return false}async function dt(t=0){await new Promise(n=>setTimeout(()=>n(true),t));}function yt(t){return process.env[t]}function ht(t=1,n=new Date){let r=Math.min(60,Math.max(1,Math.trunc(Math.abs(t)))),e=n.getMinutes(),i=Math.floor(e/r)*r,o=new Date(n);return o.setMinutes(i,0,0),o}function wt(t=new Date){let n=l=>String(l).padStart(2,"0"),r=t.getFullYear(),e=n(t.getMonth()+1),i=n(t.getDate()),o=n(t.getHours()),s=n(t.getMinutes()),a=n(t.getSeconds());return `${r}-${e}-${i} ${o}:${s}:${a}`}function St(t){let{days:n=0,hours:r=0,minutes:e=0,seconds:i=0}=t;return n*86400+r*3600+e*60+i}function Nt(t){if(!Number.isFinite(t)||t<0)throw new Error("Invalid total seconds");let n=Math.floor(t/86400),r=Math.floor(t%86400/3600),e=Math.floor(t%3600/60),i=t%60;return {days:n,hours:r,minutes:e,seconds:i}}function Ft(t){let n=t.split(".").map(o=>Number(o));if(n.length!==4||n.some(o=>!Number.isInteger(o)||o<0||o>255))throw new Error("Invalid IPv4 address");let r=new ArrayBuffer(4),e=new DataView(r),i=0;for(;i<4;)e.setUint8(i,n[i]),i++;return e.getUint32(0,false)}function Et(t){if(!S(t))return "";let n=new ArrayBuffer(4),r=new DataView(n);r.setUint32(0,t,false);let e=[],i=0;for(;i<4;)e.push(r.getUint8(i)),i++;return e.join(".")}function O(t){return Array.isArray(t)}function Bt(t){return O(t)&&t.length>0}function D(t){return typeof t=="boolean"}function E(t){return _(t)&&Object.keys(t).length>0}function tt(t){if(D(t))return true;if(!E(t))return false;for(let n of Object.keys(t))if(!tt(t[n]))return false;return true}function Zt(t){if(t instanceof Date)return !Number.isNaN(t.getTime());if(u(t)||y(t)){let n=new Date(t);return !Number.isNaN(n.getTime())}return false}var nt=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z]{2,})+$/;function Qt(t){return m(t)?nt.test(t):false}function Ht(t){return t!=null}function F(t){return typeof t=="function"}var rt=/^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/;function Xt(t){if(!u(t))return false;let n=t.trim();return rt.test(n)}function nn(t){return u(t)&&/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/.test(t)}function y(t){return typeof t=="number"&&Number.isFinite(t)}function sn(t){return y(t)&&!Number.isInteger(t)}function cn(t){return y(t)&&t<0}function U(t){return y(t)&&t<=0}function S(t){return y(t)&&t>0}function Z(t){return y(t)&&t>=0}function _(t){return typeof t=="object"&&t!==null&&Object.prototype.toString.call(t)==="[object Object]"&&!Array.isArray(t)&&!(t instanceof Date)}function Sn(t){return E(t)?Object.values(t).every(n=>n===null||!_(n)&&!O(n)||!F(n)):false}function Pn(t,{minLength:n=8,maxLength:r=256,requireUppercase:e=true,requireLowercase:i=true,requireDigit:o=true,requireSpecial:s=true}={}){return !(!u(t)||t.length<n||t.length>r||e&&!/[A-ZА-Я]/.test(t)||i&&!/[a-zа-я]/.test(t)||o&&!/\d/.test(t)||s&&!/[~!?@#$%^&*_\-+()\[\]{}><\\\/|"'.,:;=]/.test(t))}function Dn(t){if(!m(t)&&!y(t))return false;let n=String(t).trim();return !(n.startsWith("-")||(n.match(/\+/g)||[]).length>1||n.includes("+")&&!n.startsWith("+")||!/^\+?[0-9-]+$/.test(n)||n.length<3||n.length>20||!/[0-9]$/.test(n)||n.includes("--"))}function u(t){return typeof t=="string"}function W(t){if(!m(t))return false;let n=t.trim().toLowerCase();return n==="true"||n==="false"}function m(t){return u(t)&&t.trim().length>0}function Rn(t){if(!m(t))return false;let n=t.trim().toLowerCase();return n==="asc"||n==="desc"}function Wn(t){return u(t)&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)}function Un(t){return F(t)&&/^class\s/.test(Function.prototype.toString.call(t))}function V(t){let n=t.sign<0?"-":"",r=t.digitsInteger.toString();if(t.scale===0)return n+r;let e=t.scale-r.length;if(e>=0)return n+"0."+"0".repeat(e)+r;let i=r.length-t.scale,o=r.slice(0,i),s=r.slice(i);return n+o+"."+s}function J(t){return Number(V(t))}function $(t,n){let r=/^([0-9]+)(?:\.([0-9]*))?e([+\-]?[0-9]+)$/i.exec((()=>{let[o,s]=n.split(/e/i),[a,l=""]=o.split("."),h=a.replace(/^0+/,"")+l,N=parseInt(s,10)-l.length;return `${h||"0"}e${N}`})());if(!r)throw new Error("Failed to parse exponential notation.");let e=r[1],i=parseInt(r[3],10);if(Z(i))return e=e+"0".repeat(i),{sign:t,integerPart:e||"0",fractionalPart:""};{let o=-i;if(o>=e.length){let s="0".repeat(o-e.length);return {sign:t,integerPart:"0",fractionalPart:s+e}}else {let s=e.length-o;return {sign:t,integerPart:e.slice(0,s),fractionalPart:e.slice(s)}}}}function Q(t){if(typeof t=="bigint"){let n=t<0n?-1:1,r=(t<0n?-t:t).toString();return {sign:n,integerPart:r,fractionalPart:""}}if(typeof t=="number"){if(!Number.isFinite(t))throw new Error("Input number is not finite.");let n=t<0?-1:1,e=Math.abs(t).toExponential(30);return $(n,e)}if(typeof t=="string"){let n=t.trim().replace(",",".");if(!n)throw new Error("Input string is empty.");let r=1;if((n.startsWith("+")||n.startsWith("-"))&&(r=n.startsWith("-")?-1:1,n=n.slice(1)),/^[0-9]*\.?[0-9]*(e[+\-]?[0-9]+)?$/i.test(n)){if(/e/i.test(n))return $(r,n);let[e="0",i=""]=n.split(".");return {sign:r,integerPart:e,fractionalPart:i}}throw new Error("Invalid numeric string.")}throw new Error("Unsupported input type.")}function R(t){let{sign:n,integerPart:r,fractionalPart:e}=Q(t),i=r.replace(/^0+/,"")||"0",o=e.replace(/0+$/,""),s=i+o||"0";return {sign:n,digitsInteger:BigInt(s),scale:o.length}}function q(t,n,r="half-up"){let e=Math.max(0,Math.trunc(n));if(t.scale<=e)return {...t};let i=t.scale-e,o=10n**BigInt(i),s=t.digitsInteger/o,a=t.digitsInteger%o;if(r==="trunc"||a===0n)return {sign:t.sign,digitsInteger:s,scale:e};let l=o/2n,N=a>=l?s+1n:s;return {sign:t.sign,digitsInteger:N,scale:e}}function z(t,n=1,r=false){try{return J(n>1?q(R(t),n,"half-up"):R(t))}catch(e){if(r)throw e}return 0}function H(t){if(!u(t))return "";let n=x(t);return m(n)?n.toLowerCase():""}function ur(t){if(!u(t))return "";let n=H(t);return m(n)?n[0].toUpperCase()+n.slice(1):""}function lr(t){return u(t)&&x(t)===""||t===void 0?null:t}function dr(t,n="+7"){if(!u(t))return null;let r=x(t).replace(/[\s\-().]/g,"");return /^00\d{8,15}$/.test(r)?r="+"+r.slice(2):/^\d{10}$/.test(r)?r=n+r:/^\d{9,15}$/.test(r)&&!r.startsWith("0")&&(r="+"+r),/^\+\d{10,15}$/.test(r)?r:null}function x(t,n=""){let r=String(u(t)?t.trim().normalize("NFKC").replace(/[\u200B-\u200D\uFEFF]/g,""):"");return n?r.split(n).filter(e=>!!e).join(n):r}function wr(t){return u(t)&&x(t)===""||t===null?void 0:t}var kr=t=>{if(!u(t))return t;let n=String(x(t)||"");return n===""?null:String(n.toLowerCase()||"").replace(/\s+/g," ").replace(/\t+/g,"").replace(/\n+/g,"")};function Pr(t=""){return {}}function Dr(t){if(!m(t))return String(t);let n="____RAW_PERCENT____",r=t.replace(/%(?![0-9A-Fa-f]{2})/g,n),e=new Set(["22","7B","7D","3A","2C","5B","5D","5C"]);return r.replace(/%([0-9A-Fa-f]{2})/g,(o,s)=>{let a=s.toUpperCase();return e.has(a)?decodeURIComponent(`%${a}`):`%${a}`}).split(n).join("%")}function b(t,n){let r=new Error(n??t);return r.code=t,r}var j=null;async function Ir(t,n,{port:r=4028,timeoutMs:e=0,connectTimeoutMs:i=0,encoding:o="utf8",signal:s,maxBytes:a=0,halfCloseAfterWrite:l=false,lineTerminator:h=""}={}){if(!(typeof process<"u"&&!!process.versions?.node))throw b("ENODEONLY","connectTCP is Node-only");if(!m(n))throw b("EBADHOST","`host` must be a non-empty string");if(!m(t))throw b("EBADMSG","`message` must be a non-empty string");if(!S(r)||r<1||r>65535)throw b("EBADPORT","`port` must be an integer in range 1..65535");let c=o.toLowerCase()==="utf-8"?"utf8":o;if(!j)try{j=await import('net');}catch{}if(!j)throw b("ENETIMPORT","FATAL: node:net import failed");return new Promise((f,d)=>{let p=new j.Socket,P=false,A=0,w=null,C=()=>{p.destroyed||p.destroy(b("EABORT","Operation cancelled")),T(b("EABORT","Operation cancelled"));},T=(g,k)=>{P||(P=true,p.removeAllListeners(),s&&s.removeEventListener("abort",C),p.destroyed||p.destroy(),w&&clearTimeout(w),g?d(g):f(k??""));};if(s){if(s.aborted)return T(b("EABORT","Operation cancelled"));s.addEventListener("abort",C,{once:true});}S(i)&&(w=setTimeout(()=>T(b("ETIMEDOUT","Connect timed out")),i),w&&F(w.unref)&&w.unref()),S(e)&&(p.setTimeout(e),p.once("timeout",()=>T(b("ETIMEDOUT","Idle timeout"))));let I=[];p.on("data",g=>{if(P)return;let k=Buffer.isBuffer(g)?g:Buffer.from(g,c);if(S(a)&&A+k.length>a)return T(b("ERESPONSE_TOO_LARGE","Response exceeds maxBytes"));I.push(k),A+=k.length;}),p.once("end",()=>{if(P)return;let g=Buffer.concat(I,A).toString(c);T(void 0,g);}),p.once("close",g=>{if(P)return;let k=Buffer.concat(I,A).toString(c);g?T(b("ECLOSE","Socket closed with error")):T(void 0,k);}),p.once("error",g=>{P||T(g);}),p.once("connect",()=>{w&&(clearTimeout(w),w=null);let g=h?t+h:t;p.write(g,c)?l&&p.end():p.once("drain",()=>{l&&!P&&p.end();});}),p.connect({host:n,port:r});})}export{it as arrFuncArgs,ft as arrReplaceTemplate,st as arrSplitBatches,at as arrUniqueDeep,M as boolNormalize,ht as dateFloorMin,St as datePartsSec,Nt as dateSecParts,wt as dateStr,yt as env,Et as ipNumStr,Ft as ipStrNum,O as isArr,Bt as isArrFilled,D as isBool,tt as isBoolOrBoolTree,Un as isClass,Zt as isDate,Qt as isEmail,Ht as isExists,F as isFunc,Xt as isIpAddr,nn as isMacAddr,y as isNum,sn as isNumFloat,cn as isNumN,U as isNumNZ,S as isNumP,Z as isNumPZ,_ as isObj,E as isObjFilled,Sn as isObjFlat,Pn as isPassword,Dn as isPhone,u as isStr,Rn as isStrAscDesc,W as isStrBool,m as isStrFilled,Wn as isVar,Ir as netTCP,z as numNormalize,H as strLowerCase,ur as strNormalCase,kr as strNormalize,lr as strNull,dr as strPhone,x as strTrim,wr as strUndefined,Dr as urlDecode,Pr as urlObj,dt as wait};//# sourceMappingURL=node.mjs.map
|
|
2
2
|
//# sourceMappingURL=node.mjs.map
|