@isdk/util 0.3.8 → 0.3.10
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/index.d.mts +260 -144
- package/dist/index.d.ts +260 -144
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/docs/classes/BinarySemaphore.md +145 -64
- package/docs/classes/ConfigFile.md +8 -8
- package/docs/classes/Deque.md +109 -105
- package/docs/classes/IntSet.md +12 -12
- package/docs/classes/Semaphore.md +149 -77
- package/docs/classes/SignalGate.md +11 -11
- package/docs/functions/RateLimit.md +30 -7
- package/docs/functions/arrayHasAll.md +1 -1
- package/docs/functions/extNameLevel.md +1 -1
- package/docs/functions/extractCodeBlock.md +3 -3
- package/docs/functions/extractTopLevelCodeBlocks.md +1 -1
- package/docs/functions/filenameReservedRegex.md +1 -1
- package/docs/functions/findPort.md +13 -5
- package/docs/functions/getMultiLevelExtname.md +1 -1
- package/docs/functions/glob.md +1 -1
- package/docs/functions/isStringIn.md +3 -3
- package/docs/functions/isValidFilename.md +1 -1
- package/docs/functions/isValidFilepath.md +1 -1
- package/docs/functions/normalizeIncludeFiles.md +3 -3
- package/docs/functions/omitDeepBy.md +1 -1
- package/docs/functions/omitEmptyDeep.md +1 -1
- package/docs/functions/parseCodeBlockSelector.md +2 -2
- package/docs/functions/parseFrontMatter.md +1 -1
- package/docs/functions/parseYaml.md +1 -1
- package/docs/functions/reControlCharsRegex.md +1 -1
- package/docs/functions/registerYamlTag.md +3 -3
- package/docs/functions/removeLeadingEmptyLines.md +1 -1
- package/docs/functions/sanitizeFilename.md +1 -1
- package/docs/functions/sanitizeFilepath.md +1 -1
- package/docs/functions/sleep.md +1 -1
- package/docs/functions/stringifyYaml.md +1 -1
- package/docs/functions/toCamelCase.md +1 -1
- package/docs/functions/toCapitalCase.md +1 -1
- package/docs/functions/toPascalCase.md +1 -1
- package/docs/functions/traverseFolder.md +1 -1
- package/docs/functions/traverseFolderSync.md +1 -1
- package/docs/functions/yieldExec.md +1 -1
- package/docs/globals.md +1 -0
- package/docs/interfaces/BinarySemaphoreAcquireOptions.md +11 -4
- package/docs/interfaces/BinarySemaphoreOptions.md +29 -12
- package/docs/interfaces/BinarySemaphoreReleaseOptions.md +10 -4
- package/docs/interfaces/BinarySemaphoreReleaserFunc.md +14 -5
- package/docs/interfaces/CodeBlockSelectorPart.md +4 -4
- package/docs/interfaces/CodeString.md +89 -89
- package/docs/interfaces/ExtractCodeBlockOptions.md +9 -9
- package/docs/interfaces/FindPortOptions.md +25 -0
- package/docs/interfaces/IncludeFiles.md +5 -5
- package/docs/interfaces/LoadConfigFileOptions.md +5 -5
- package/docs/interfaces/SanitizeFilenameOptions.md +5 -5
- package/docs/interfaces/SemaphoreOptions.md +39 -16
- package/docs/interfaces/SemaphoreTaskItem.md +23 -10
- package/docs/type-aliases/CodeBlockCombinator.md +1 -1
- package/docs/type-aliases/SemaphoreIsReadyFuncType.md +5 -2
- package/docs/type-aliases/StringifyFunc.md +2 -2
- package/docs/type-aliases/TraverseFolderHandler.md +2 -2
- package/docs/type-aliases/TraverseFolderSyncHandler.md +2 -2
- package/docs/variables/DefaultAllTextFiles.md +1 -1
- package/docs/variables/DefaultAsyncSemaphoreCapacity.md +4 -1
- package/docs/variables/FilenameReservedRegex.md +1 -1
- package/docs/variables/WindowsReservedNameRegex.md +1 -1
- package/package.json +20 -17
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: SignalGate\<T\>
|
|
8
8
|
|
|
9
|
-
Defined in: [src/async-signal-gate.ts:20](https://github.com/isdk/util.js/blob/
|
|
9
|
+
Defined in: [src/async-signal-gate.ts:20](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/async-signal-gate.ts#L20)
|
|
10
10
|
|
|
11
11
|
An asynchronous signal gate that blocks operations until a signal is emitted.
|
|
12
12
|
This class allows multiple awaiters to wait for a signal and resolves all pending promises with the emitted value.
|
|
@@ -46,7 +46,7 @@ valueGate.signal(42); // Must provide a number value
|
|
|
46
46
|
|
|
47
47
|
> `protected` **\_isSignaled**: `boolean` = `false`
|
|
48
48
|
|
|
49
|
-
Defined in: [src/async-signal-gate.ts:21](https://github.com/isdk/util.js/blob/
|
|
49
|
+
Defined in: [src/async-signal-gate.ts:21](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/async-signal-gate.ts#L21)
|
|
50
50
|
|
|
51
51
|
***
|
|
52
52
|
|
|
@@ -54,7 +54,7 @@ Defined in: [src/async-signal-gate.ts:21](https://github.com/isdk/util.js/blob/2
|
|
|
54
54
|
|
|
55
55
|
> `protected` **\_signalValue**: `T` \| `undefined`
|
|
56
56
|
|
|
57
|
-
Defined in: [src/async-signal-gate.ts:22](https://github.com/isdk/util.js/blob/
|
|
57
|
+
Defined in: [src/async-signal-gate.ts:22](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/async-signal-gate.ts#L22)
|
|
58
58
|
|
|
59
59
|
***
|
|
60
60
|
|
|
@@ -62,9 +62,9 @@ Defined in: [src/async-signal-gate.ts:22](https://github.com/isdk/util.js/blob/2
|
|
|
62
62
|
|
|
63
63
|
> `protected` **waitQueue**: `object`[] = `[]`
|
|
64
64
|
|
|
65
|
-
Defined in: [src/async-signal-gate.ts:23](https://github.com/isdk/util.js/blob/
|
|
65
|
+
Defined in: [src/async-signal-gate.ts:23](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/async-signal-gate.ts#L23)
|
|
66
66
|
|
|
67
|
-
#### reject
|
|
67
|
+
#### reject
|
|
68
68
|
|
|
69
69
|
> **reject**: (`error`) => `void`
|
|
70
70
|
|
|
@@ -78,7 +78,7 @@ Defined in: [src/async-signal-gate.ts:23](https://github.com/isdk/util.js/blob/2
|
|
|
78
78
|
|
|
79
79
|
`void`
|
|
80
80
|
|
|
81
|
-
#### resolve
|
|
81
|
+
#### resolve
|
|
82
82
|
|
|
83
83
|
> **resolve**: (`value`) => `void`
|
|
84
84
|
|
|
@@ -100,7 +100,7 @@ Defined in: [src/async-signal-gate.ts:23](https://github.com/isdk/util.js/blob/2
|
|
|
100
100
|
|
|
101
101
|
> **get** **signaled**(): `boolean`
|
|
102
102
|
|
|
103
|
-
Defined in: [src/async-signal-gate.ts:28](https://github.com/isdk/util.js/blob/
|
|
103
|
+
Defined in: [src/async-signal-gate.ts:28](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/async-signal-gate.ts#L28)
|
|
104
104
|
|
|
105
105
|
##### Returns
|
|
106
106
|
|
|
@@ -112,7 +112,7 @@ Defined in: [src/async-signal-gate.ts:28](https://github.com/isdk/util.js/blob/2
|
|
|
112
112
|
|
|
113
113
|
> **abort**(`reason?`): `void`
|
|
114
114
|
|
|
115
|
-
Defined in: [src/async-signal-gate.ts:65](https://github.com/isdk/util.js/blob/
|
|
115
|
+
Defined in: [src/async-signal-gate.ts:65](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/async-signal-gate.ts#L65)
|
|
116
116
|
|
|
117
117
|
Aborts all pending waits, rejecting their promises with an error.
|
|
118
118
|
This does **not** reset the signal state (the gate remains signaled or unsignaled).
|
|
@@ -135,7 +135,7 @@ The reason for aborting the waits.
|
|
|
135
135
|
|
|
136
136
|
> **reset**(): `void`
|
|
137
137
|
|
|
138
|
-
Defined in: [src/async-signal-gate.ts:53](https://github.com/isdk/util.js/blob/
|
|
138
|
+
Defined in: [src/async-signal-gate.ts:53](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/async-signal-gate.ts#L53)
|
|
139
139
|
|
|
140
140
|
Resets the gate to its initial state, allowing a new signal to be emitted.
|
|
141
141
|
|
|
@@ -149,7 +149,7 @@ Resets the gate to its initial state, allowing a new signal to be emitted.
|
|
|
149
149
|
|
|
150
150
|
> **signal**(`value?`): `void`
|
|
151
151
|
|
|
152
|
-
Defined in: [src/async-signal-gate.ts:38](https://github.com/isdk/util.js/blob/
|
|
152
|
+
Defined in: [src/async-signal-gate.ts:38](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/async-signal-gate.ts#L38)
|
|
153
153
|
|
|
154
154
|
Emits the signal with an optional value, resolving all pending [wait](#wait) promises.
|
|
155
155
|
Subsequent calls have no effect until [reset](#reset) is called.
|
|
@@ -172,7 +172,7 @@ The value to emit with the signal (only required if T is not void).
|
|
|
172
172
|
|
|
173
173
|
> **wait**(): `Promise`\<`T`\>
|
|
174
174
|
|
|
175
|
-
Defined in: [src/async-signal-gate.ts:83](https://github.com/isdk/util.js/blob/
|
|
175
|
+
Defined in: [src/async-signal-gate.ts:83](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/async-signal-gate.ts#L83)
|
|
176
176
|
|
|
177
177
|
Returns a promise that resolves with the emitted signal value.
|
|
178
178
|
If called after the signal has been emitted, resolves immediately with the stored value.
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
# Function: RateLimit()
|
|
8
8
|
|
|
9
|
-
> **RateLimit**(`rps`, `
|
|
9
|
+
> **RateLimit**(`rps`, `options?`): () => `Promise`\<`void`\>
|
|
10
10
|
|
|
11
|
-
Defined in: [src/async-semaphore.ts:
|
|
11
|
+
Defined in: [src/async-semaphore.ts:598](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/async-semaphore.ts#L598)
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
创建一个速率限制器函数(Rate Limiter)。
|
|
14
|
+
当调用频率超过设定的 `rps`(每秒请求数)时,该函数会通过 Promise 阻塞调用方,
|
|
15
|
+
并在调用率回到限制范围内时解析。
|
|
14
16
|
|
|
15
17
|
## Parameters
|
|
16
18
|
|
|
@@ -18,20 +20,41 @@ Creates a rate limiter function that blocks with a promise whenever the rate lim
|
|
|
18
20
|
|
|
19
21
|
`number`
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
限制的速率。默认单位时间内允许的请求数。
|
|
24
|
+
|
|
25
|
+
### options?
|
|
26
|
+
|
|
27
|
+
配置项。
|
|
22
28
|
|
|
23
29
|
#### timeUnit?
|
|
24
30
|
|
|
25
31
|
`number` = `1000`
|
|
26
32
|
|
|
33
|
+
时间窗口大小(毫秒)。默认为 1000ms。
|
|
34
|
+
|
|
27
35
|
#### uniformDistribution?
|
|
28
36
|
|
|
29
37
|
`boolean` = `false`
|
|
30
38
|
|
|
39
|
+
是否强制离散均匀分布。
|
|
40
|
+
- 若为 `false`(默认):允许在时间窗口开始时立即耗尽所有配额,然后暂停直到窗口结束。
|
|
41
|
+
- 若为 `true`:将配额均匀分配到时间窗口内(例如 5 rps 会每 200ms 允许一次请求)。
|
|
42
|
+
在流量持续且快速的场景下(如读取文件)建议开启,以避免瞬时突发流量。
|
|
43
|
+
|
|
31
44
|
## Returns
|
|
32
45
|
|
|
33
|
-
|
|
46
|
+
返回一个异步限流函数,调用该函数即可实现限流。
|
|
47
|
+
|
|
48
|
+
示例:
|
|
49
|
+
```ts
|
|
50
|
+
const lim = RateLimit(5); // 限制为 5 次/秒
|
|
34
51
|
|
|
35
|
-
|
|
52
|
+
async function processItems(items) {
|
|
53
|
+
for (const item of items) {
|
|
54
|
+
await lim(); // 可能会在这里阻塞
|
|
55
|
+
await handle(item);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
36
59
|
|
|
37
|
-
`Promise`\<`void`\>
|
|
60
|
+
() => `Promise`\<`void`\>
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **arrayHasAll**\<`T`\>(`array`, `elements`): `boolean`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/array-has-all.ts:15](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/array-has-all.ts:15](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/array-has-all.ts#L15)
|
|
12
12
|
|
|
13
13
|
Checks whether the provided array contains all of the specified elements.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **extNameLevel**(`extName`): `number`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/filename.ts:226](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/filename.ts:226](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/filename.ts#L226)
|
|
12
12
|
|
|
13
13
|
Calculates the level of an extension name.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **extractCodeBlock**(`text`, `langOrOptions?`): `string` \| [`CodeString`](../interfaces/CodeString.md) \| (`string` \| [`CodeString`](../interfaces/CodeString.md))[]
|
|
10
10
|
|
|
11
|
-
Defined in: [src/extract-code-block.ts:
|
|
11
|
+
Defined in: [src/extract-code-block.ts:199](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/extract-code-block.ts#L199)
|
|
12
12
|
|
|
13
13
|
Extracts fenced code block(s) from the input `text`, with support for nested path selectors.
|
|
14
14
|
|
|
@@ -26,9 +26,9 @@ The input string containing Markdown.
|
|
|
26
26
|
|
|
27
27
|
### langOrOptions?
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
`string` \| `string`[] \| [`ExtractCodeBlockOptions`](../interfaces/ExtractCodeBlockOptions.md)
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
Either a language/selector string or a full [ExtractCodeBlockOptions](../interfaces/ExtractCodeBlockOptions.md) object.
|
|
32
32
|
|
|
33
33
|
## Returns
|
|
34
34
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **extractTopLevelCodeBlocks**(`text`, `options?`): [`CodeString`](../interfaces/CodeString.md)[]
|
|
10
10
|
|
|
11
|
-
Defined in: [src/extract-code-block.ts:115](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/extract-code-block.ts:115](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/extract-code-block.ts#L115)
|
|
12
12
|
|
|
13
13
|
Extracts top-level fenced code blocks from the input `text`.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **filenameReservedRegex**(): `RegExp`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/filename.ts:44](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/filename.ts:44](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/filename.ts#L44)
|
|
12
12
|
|
|
13
13
|
Returns a new regular expression instance for reserved filename characters with the 'g' flag.
|
|
14
14
|
use this to reset the with global option
|
|
@@ -6,20 +6,28 @@
|
|
|
6
6
|
|
|
7
7
|
# Function: findPort()
|
|
8
8
|
|
|
9
|
-
> **findPort**(`port`, `
|
|
9
|
+
> **findPort**(`port`, `options?`): `Promise`\<`number`\>
|
|
10
10
|
|
|
11
|
-
Defined in: [src/find-port.ts:
|
|
11
|
+
Defined in: [src/find-port.ts:17](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/find-port.ts#L17)
|
|
12
|
+
|
|
13
|
+
Finds an available port.
|
|
12
14
|
|
|
13
15
|
## Parameters
|
|
14
16
|
|
|
15
17
|
### port
|
|
16
18
|
|
|
17
|
-
`string`
|
|
19
|
+
`string` \| `number` \| `undefined`
|
|
20
|
+
|
|
21
|
+
The starting port number or a string representation of it. Defaults to 0 (random port).
|
|
18
22
|
|
|
19
|
-
###
|
|
23
|
+
### options?
|
|
20
24
|
|
|
21
|
-
`number`
|
|
25
|
+
`number` \| [`FindPortOptions`](../interfaces/FindPortOptions.md)
|
|
26
|
+
|
|
27
|
+
Either the retry count (number) or an options object.
|
|
22
28
|
|
|
23
29
|
## Returns
|
|
24
30
|
|
|
25
31
|
`Promise`\<`number`\>
|
|
32
|
+
|
|
33
|
+
A promise that resolves to the available port number.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **getMultiLevelExtname**(`filename`, `level?`): `string`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/get-multi-level-extname.ts:9](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/get-multi-level-extname.ts:9](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/get-multi-level-extname.ts#L9)
|
|
12
12
|
|
|
13
13
|
Retrieves multi-level file extension
|
|
14
14
|
|
package/docs/functions/glob.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **glob**(`filepath`, `pattern`, `rootDir?`): `boolean` \| `undefined`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/glob.ts:29](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/glob.ts:29](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/glob.ts#L29)
|
|
12
12
|
|
|
13
13
|
Matches a file path against a list of glob patterns.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **isStringIn**(`str`, `arr`): `boolean`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/is-string-in.ts:17](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/is-string-in.ts:17](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/is-string-in.ts#L17)
|
|
12
12
|
|
|
13
13
|
Checks if a given string exists within an array of strings or a single string.
|
|
14
14
|
|
|
@@ -22,9 +22,9 @@ The string to search for.
|
|
|
22
22
|
|
|
23
23
|
### arr
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
`string` \| `string`[]
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
An array of strings or a single string to search within.
|
|
28
28
|
|
|
29
29
|
## Returns
|
|
30
30
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **isValidFilename**(`filename`): `boolean` \| `""`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/filename.ts:65](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/filename.ts:65](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/filename.ts#L65)
|
|
12
12
|
|
|
13
13
|
Validates if a given string is a valid filename.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **isValidFilepath**(`filepath`): `boolean`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/filename.ts:82](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/filename.ts:82](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/filename.ts#L82)
|
|
12
12
|
|
|
13
13
|
Validates whether the given filepath is valid.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **normalizeIncludeFiles**(`files?`, `defaultFiles?`): `string`[]
|
|
10
10
|
|
|
11
|
-
Defined in: [src/include-files.ts:34](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/include-files.ts:34](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/include-files.ts#L34)
|
|
12
12
|
|
|
13
13
|
Normalizes a list of file patterns for glob matching.
|
|
14
14
|
|
|
@@ -20,9 +20,9 @@ all text-based files as defined in `DefaultAllTextFiles`.
|
|
|
20
20
|
|
|
21
21
|
### files?
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
`string`[] \| [`IncludeFiles`](../interfaces/IncludeFiles.md)
|
|
24
24
|
|
|
25
|
-
`
|
|
25
|
+
Either an array of file patterns or an object with `include` and `exclude` properties.
|
|
26
26
|
|
|
27
27
|
### defaultFiles?
|
|
28
28
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **omitDeepBy**\<`T`\>(`value`, `predicate`, `cache?`): `any`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/omit-deep-by.ts:92](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/omit-deep-by.ts:92](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/omit-deep-by.ts#L92)
|
|
12
12
|
|
|
13
13
|
Recursively removes properties from an object or array that satisfy the given predicate condition.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **omitEmptyDeep**\<`T`\>(`value`, `omitFunc?`): `any`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/omit-empty-deep.ts:33](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/omit-empty-deep.ts:33](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/omit-empty-deep.ts#L33)
|
|
12
12
|
|
|
13
13
|
Deeply removes empty values from objects or arrays, supporting both string and Symbol keys.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **parseCodeBlockSelector**(`lang?`): [`CodeBlockSelectorPart`](../interfaces/CodeBlockSelectorPart.md)[]
|
|
10
10
|
|
|
11
|
-
Defined in: [src/extract-code-block.ts:160](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/extract-code-block.ts:160](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/extract-code-block.ts#L160)
|
|
12
12
|
|
|
13
13
|
Parses a selector string into an array of structured [CodeBlockSelectorPart](../interfaces/CodeBlockSelectorPart.md) objects.
|
|
14
14
|
|
|
@@ -16,7 +16,7 @@ Parses a selector string into an array of structured [CodeBlockSelectorPart](../
|
|
|
16
16
|
|
|
17
17
|
### lang?
|
|
18
18
|
|
|
19
|
-
`string`
|
|
19
|
+
`string` \| `string`[]
|
|
20
20
|
|
|
21
21
|
The selector string.
|
|
22
22
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **parseFrontMatter**(`value`, `delimiter?`): `object`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/front-matter.ts:6](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/front-matter.ts:6](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/front-matter.ts#L6)
|
|
12
12
|
|
|
13
13
|
## Parameters
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **parseYaml**(`content`, `options?`): `any`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/yaml.ts:66](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/yaml.ts:66](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/yaml.ts#L66)
|
|
12
12
|
|
|
13
13
|
Parses a YAML string into a JavaScript object with optional custom tags.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **reControlCharsRegex**(): `RegExp`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/filename.ts:52](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/filename.ts:52](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/filename.ts#L52)
|
|
12
12
|
|
|
13
13
|
Returns a new regular expression instance for control characters in a filename with the 'g' flag.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **registerYamlTag**(`tags`): `void`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/yaml.ts:34](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/yaml.ts:34](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/yaml.ts#L34)
|
|
12
12
|
|
|
13
13
|
Registers custom YAML tags to be used in parsing and stringifying YAML content.
|
|
14
14
|
|
|
@@ -16,9 +16,9 @@ Registers custom YAML tags to be used in parsing and stringifying YAML content.
|
|
|
16
16
|
|
|
17
17
|
### tags
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
`"map"` \| `Tags` \| `ScalarTag` \| `CollectionTag` \| `"binary"` \| `"bool"` \| `"float"` \| `"floatExp"` \| `"floatNaN"` \| `"floatTime"` \| `"int"` \| `"intHex"` \| `"intOct"` \| `"intTime"` \| `"merge"` \| `"null"` \| `"omap"` \| `"pairs"` \| `"seq"` \| `"set"` \| `"timestamp"`
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
A single tag or an array of tags to register.
|
|
22
22
|
|
|
23
23
|
## Returns
|
|
24
24
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **removeLeadingEmptyLines**(`text`): `string`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/remove-leading-empty-lines.ts:16](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/remove-leading-empty-lines.ts:16](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/remove-leading-empty-lines.ts#L16)
|
|
12
12
|
|
|
13
13
|
Removes all leading empty lines or "#" comments line from the given string.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **sanitizeFilename**(`filename`, `options?`): `string`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/filename.ts:110](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/filename.ts:110](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/filename.ts#L110)
|
|
12
12
|
|
|
13
13
|
Sanitizes a given filename by replacing invalid characters with a specified replacement character or a default.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **sanitizeFilepath**(`filepath`, `options?`): `string`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/filename.ts:178](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/filename.ts:178](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/filename.ts#L178)
|
|
12
12
|
|
|
13
13
|
Sanitizes each part of a file path and reassembles it, ensuring the path is valid according to provided options.
|
|
14
14
|
|
package/docs/functions/sleep.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **sleep**(`ms`): `Promise`\<`void`\>
|
|
10
10
|
|
|
11
|
-
Defined in: [src/sleep.ts:12](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/sleep.ts:12](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/sleep.ts#L12)
|
|
12
12
|
|
|
13
13
|
Suspends execution for a specified number of milliseconds
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **stringifyYaml**(`content`, `options?`): `string`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/yaml.ts:103](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/yaml.ts:103](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/yaml.ts#L103)
|
|
12
12
|
|
|
13
13
|
Converts a JavaScript object into a YAML string with optional custom tags.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **toCamelCase**(`str`): `string`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/to-camel-case.ts:17](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/to-camel-case.ts:17](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/to-camel-case.ts#L17)
|
|
12
12
|
|
|
13
13
|
Converts a string to camelCase.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **toCapitalCase**(`str`): `string`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/to-capital-case.ts:17](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/to-capital-case.ts:17](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/to-capital-case.ts#L17)
|
|
12
12
|
|
|
13
13
|
Converts a string to capital case, where the first letter of each word is capitalized
|
|
14
14
|
and the rest are in lowercase. Words are separated by spaces, hyphens, or underscores.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **toPascalCase**(`str`): `string`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/to-pascal-case.ts:16](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/to-pascal-case.ts:16](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/to-pascal-case.ts#L16)
|
|
12
12
|
|
|
13
13
|
Converts a string to PascalCase.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **traverseFolder**(`directoryPath`, `fileHandler`): `Promise`\<`void`\>
|
|
10
10
|
|
|
11
|
-
Defined in: [src/traverse-folder.ts:44](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/traverse-folder.ts:44](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/traverse-folder.ts#L44)
|
|
12
12
|
|
|
13
13
|
Traverses a folder asynchronously and applies a handler to each file or directory.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **traverseFolderSync**(`directoryPath`, `fileHandler`): `void`
|
|
10
10
|
|
|
11
|
-
Defined in: [src/traverse-folder.ts:89](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/traverse-folder.ts:89](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/traverse-folder.ts#L89)
|
|
12
12
|
|
|
13
13
|
Traverses a folder synchronously and applies a handler to each file or directory.
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **yieldExec**(): `Promise`\<`void`\>
|
|
10
10
|
|
|
11
|
-
Defined in: [src/sleep.ts:28](https://github.com/isdk/util.js/blob/
|
|
11
|
+
Defined in: [src/sleep.ts:28](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/sleep.ts#L28)
|
|
12
12
|
|
|
13
13
|
Yields execution control to the event loop, allowing pending I/O operations
|
|
14
14
|
and scheduled tasks to run before continuing.
|
package/docs/globals.md
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
- [CodeBlockSelectorPart](interfaces/CodeBlockSelectorPart.md)
|
|
23
23
|
- [CodeString](interfaces/CodeString.md)
|
|
24
24
|
- [ExtractCodeBlockOptions](interfaces/ExtractCodeBlockOptions.md)
|
|
25
|
+
- [FindPortOptions](interfaces/FindPortOptions.md)
|
|
25
26
|
- [IncludeFiles](interfaces/IncludeFiles.md)
|
|
26
27
|
- [LoadConfigFileOptions](interfaces/LoadConfigFileOptions.md)
|
|
27
28
|
- [SanitizeFilenameOptions](interfaces/SanitizeFilenameOptions.md)
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: BinarySemaphoreAcquireOptions
|
|
8
8
|
|
|
9
|
-
Defined in: [src/async-semaphore.ts:
|
|
9
|
+
Defined in: [src/async-semaphore.ts:70](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/async-semaphore.ts#L70)
|
|
10
|
+
|
|
11
|
+
获取信号量时的选项。
|
|
10
12
|
|
|
11
13
|
## Extended by
|
|
12
14
|
|
|
@@ -14,12 +16,17 @@ Defined in: [src/async-semaphore.ts:28](https://github.com/isdk/util.js/blob/227
|
|
|
14
16
|
|
|
15
17
|
## Indexable
|
|
16
18
|
|
|
17
|
-
\[`n`: `string`\]: `any`
|
|
19
|
+
> \[`n`: `string`\]: `any`
|
|
20
|
+
|
|
21
|
+
允许扩展其他自定义选项。
|
|
18
22
|
|
|
19
23
|
## Properties
|
|
20
24
|
|
|
21
25
|
### signal?
|
|
22
26
|
|
|
23
|
-
> `optional` **signal
|
|
27
|
+
> `optional` **signal?**: `AbortSignal`
|
|
28
|
+
|
|
29
|
+
Defined in: [src/async-semaphore.ts:75](https://github.com/isdk/util.js/blob/c98bd1bf94d1b1dc8d01c6b9a6fc50b4beec5c62/src/async-semaphore.ts#L75)
|
|
24
30
|
|
|
25
|
-
|
|
31
|
+
可选的 AbortSignal,用于取消获取操作。
|
|
32
|
+
如果在获取到令牌前信号被中止,`acquire` 返回的 Promise 将被拒绝并抛出 `AbortError`。
|