@socketsecurity/lib 5.14.0 → 5.16.0

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.
Files changed (85) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +2 -2
  3. package/dist/abort.d.ts +13 -0
  4. package/dist/agent.d.ts +81 -0
  5. package/dist/ansi.d.ts +13 -0
  6. package/dist/archives.d.ts +31 -0
  7. package/dist/argv/flags.d.ts +91 -0
  8. package/dist/argv/parse.d.ts +31 -0
  9. package/dist/bin.d.ts +54 -0
  10. package/dist/cacache.d.ts +38 -0
  11. package/dist/cache-with-ttl.d.ts +7 -0
  12. package/dist/colors.d.ts +12 -0
  13. package/dist/cover/formatters.d.ts +18 -0
  14. package/dist/debug.d.ts +6 -0
  15. package/dist/dlx/binary.d.ts +84 -0
  16. package/dist/dlx/cache.d.ts +6 -0
  17. package/dist/dlx/detect.d.ts +33 -0
  18. package/dist/dlx/dir.d.ts +34 -0
  19. package/dist/dlx/manifest.d.ts +16 -0
  20. package/dist/dlx/package.d.ts +43 -0
  21. package/dist/dlx/packages.d.ts +36 -0
  22. package/dist/dlx/paths.d.ts +20 -0
  23. package/dist/dlx/paths.js +1 -1
  24. package/dist/effects/pulse-frames.d.ts +6 -0
  25. package/dist/effects/text-shimmer.d.ts +9 -0
  26. package/dist/effects/ultra.d.ts +6 -0
  27. package/dist/env/ci.d.ts +14 -0
  28. package/dist/env/debug.d.ts +13 -0
  29. package/dist/env/github.d.ts +80 -0
  30. package/dist/env/helpers.d.ts +45 -0
  31. package/dist/env/home.d.ts +13 -0
  32. package/dist/env/locale.d.ts +30 -0
  33. package/dist/env/node-auth-token.d.ts +13 -0
  34. package/dist/env/node-env.d.ts +13 -0
  35. package/dist/env/npm.d.ts +50 -0
  36. package/dist/env/path.d.ts +13 -0
  37. package/dist/env/pre-commit.d.ts +14 -0
  38. package/dist/env/rewire.d.ts +38 -0
  39. package/dist/env/shell.d.ts +13 -0
  40. package/dist/env/socket-cli-shadow.d.ts +43 -0
  41. package/dist/env/socket-cli.d.ts +116 -0
  42. package/dist/env/socket.d.ts +153 -0
  43. package/dist/env/temp-dir.d.ts +30 -0
  44. package/dist/env/term.d.ts +13 -0
  45. package/dist/env/test.d.ts +32 -0
  46. package/dist/env/windows.d.ts +40 -0
  47. package/dist/env/xdg.d.ts +30 -0
  48. package/dist/env.d.ts +40 -0
  49. package/dist/external/npm-pack.js +202 -291
  50. package/dist/external/tar-fs.js +27 -7
  51. package/dist/fs.d.ts +13 -0
  52. package/dist/functions.d.ts +30 -0
  53. package/dist/globs.d.ts +27 -0
  54. package/dist/http-request.d.ts +40 -18
  55. package/dist/http-request.js +84 -129
  56. package/dist/json/format.d.ts +18 -0
  57. package/dist/memoization.d.ts +5 -0
  58. package/dist/packages/edit.d.ts +28 -0
  59. package/dist/packages/exports.d.ts +40 -0
  60. package/dist/packages/licenses.d.ts +59 -0
  61. package/dist/packages/manifest.d.ts +18 -0
  62. package/dist/packages/normalize.d.ts +22 -0
  63. package/dist/packages/operations.d.ts +51 -0
  64. package/dist/packages/provenance.d.ts +11 -0
  65. package/dist/packages/specs.d.ts +30 -0
  66. package/dist/packages/validation.d.ts +18 -0
  67. package/dist/paths/normalize.d.ts +49 -5
  68. package/dist/paths/normalize.js +13 -0
  69. package/dist/paths/rewire.js +12 -3
  70. package/dist/regexps.d.ts +7 -0
  71. package/dist/releases/github.d.ts +63 -0
  72. package/dist/releases/socket-btm.d.ts +31 -0
  73. package/dist/sea.d.ts +15 -0
  74. package/dist/shadow.d.ts +7 -0
  75. package/dist/signal-exit.d.ts +27 -0
  76. package/dist/sorts.d.ts +33 -0
  77. package/dist/spawn.d.ts +9 -0
  78. package/dist/stdio/mask.d.ts +26 -0
  79. package/dist/streams.d.ts +28 -0
  80. package/dist/suppress-warnings.d.ts +7 -0
  81. package/dist/temporary-executor.d.ts +7 -0
  82. package/dist/url.d.ts +59 -0
  83. package/dist/versions.d.ts +119 -0
  84. package/dist/words.d.ts +20 -0
  85. package/package.json +8 -58
@@ -75,6 +75,13 @@ export declare const SOCKET_BTM_REPO: {
75
75
  *
76
76
  * @param pattern - Pattern to match (string glob, prefix/suffix object, or RegExp)
77
77
  * @returns Function that tests if a string matches the pattern
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const isMatch = createAssetMatcher('tool-*-linux-x64')
82
+ * isMatch('tool-v1.0-linux-x64') // true
83
+ * isMatch('tool-v1.0-darwin-arm64') // false
84
+ * ```
78
85
  */
79
86
  export declare function createAssetMatcher(pattern: string | {
80
87
  prefix: string;
@@ -85,6 +92,16 @@ export declare function createAssetMatcher(pattern: string | {
85
92
  *
86
93
  * @param config - Download configuration
87
94
  * @returns Path to the downloaded binary
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const binaryPath = await downloadGitHubRelease({
99
+ * owner: 'SocketDev', repo: 'socket-btm',
100
+ * toolName: 'lief', toolPrefix: 'lief-',
101
+ * assetName: 'lief-linux-x64', binaryName: 'lief',
102
+ * platformArch: 'linux-x64',
103
+ * })
104
+ * ```
88
105
  */
89
106
  export declare function downloadGitHubRelease(config: DownloadGitHubReleaseConfig): Promise<string>;
90
107
  /**
@@ -96,6 +113,14 @@ export declare function downloadGitHubRelease(config: DownloadGitHubReleaseConfi
96
113
  * @param outputPath - Path to write the downloaded file
97
114
  * @param repoConfig - Repository configuration (owner/repo)
98
115
  * @param options - Additional options
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * await downloadReleaseAsset(
120
+ * 'v1.0.0', 'tool-linux-x64', '/tmp/tool',
121
+ * { owner: 'SocketDev', repo: 'socket-btm' },
122
+ * )
123
+ * ```
99
124
  */
100
125
  export declare function downloadReleaseAsset(tag: string, assetPattern: string | AssetPattern, outputPath: string, repoConfig: RepoConfig, options?: {
101
126
  quiet?: boolean;
@@ -105,6 +130,12 @@ export declare function downloadReleaseAsset(tag: string, assetPattern: string |
105
130
  * Checks GH_TOKEN or GITHUB_TOKEN environment variables.
106
131
  *
107
132
  * @returns Headers object with Authorization header if token exists.
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * const headers = getAuthHeaders()
137
+ * // { Accept: 'application/vnd.github+json', Authorization: 'Bearer ...' }
138
+ * ```
108
139
  */
109
140
  export declare function getAuthHeaders(): Record<string, string>;
110
141
  /**
@@ -116,6 +147,14 @@ export declare function getAuthHeaders(): Record<string, string>;
116
147
  * @param options - Additional options
117
148
  * @param options.assetPattern - Optional pattern to filter releases by matching asset
118
149
  * @returns Latest release tag or null if not found
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * const tag = await getLatestRelease('lief-', {
154
+ * owner: 'SocketDev', repo: 'socket-btm',
155
+ * })
156
+ * console.log(tag) // 'lief-2025-01-15-abc1234'
157
+ * ```
119
158
  */
120
159
  export declare function getLatestRelease(toolPrefix: string, repoConfig: RepoConfig, options?: {
121
160
  assetPattern?: AssetPattern;
@@ -130,6 +169,14 @@ export declare function getLatestRelease(toolPrefix: string, repoConfig: RepoCon
130
169
  * @param repoConfig - Repository configuration (owner/repo)
131
170
  * @param options - Additional options
132
171
  * @returns Browser download URL for the asset
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * const url = await getReleaseAssetUrl(
176
+ * 'v1.0.0', 'tool-linux-x64',
177
+ * { owner: 'SocketDev', repo: 'socket-btm' },
178
+ * )
179
+ * ```
133
180
  */
134
181
  export declare function getReleaseAssetUrl(tag: string, assetPattern: string | AssetPattern, repoConfig: RepoConfig, options?: {
135
182
  quiet?: boolean;
@@ -146,6 +193,14 @@ export declare function getReleaseAssetUrl(tag: string, assetPattern: string | A
146
193
  * @param options.quiet - Suppress log messages
147
194
  * @param options.cleanup - Remove downloaded zip file after extraction (default: true)
148
195
  * @returns Path to the extraction directory
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * const outputDir = await downloadAndExtractZip(
200
+ * 'v1.0.0', 'models-*.zip', '/tmp/models',
201
+ * { owner: 'SocketDev', repo: 'socket-btm' },
202
+ * )
203
+ * ```
149
204
  */
150
205
  export declare function downloadAndExtractZip(tag: string, assetPattern: string | AssetPattern, outputDir: string, repoConfig: RepoConfig, options?: {
151
206
  cleanup?: boolean;
@@ -166,6 +221,14 @@ export declare function downloadAndExtractZip(tag: string, assetPattern: string
166
221
  * @param options.strip - Strip leading path components (like tar --strip-components)
167
222
  * @param options.format - Archive format (auto-detected if not specified)
168
223
  * @returns Path to the extraction directory
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * const outputDir = await downloadAndExtractArchive(
228
+ * 'v1.0.0', 'data-*.tar.gz', '/tmp/data',
229
+ * { owner: 'SocketDev', repo: 'socket-btm' },
230
+ * )
231
+ * ```
169
232
  */
170
233
  export declare function downloadAndExtractArchive(tag: string, assetPattern: string | AssetPattern, outputDir: string, repoConfig: RepoConfig, options?: {
171
234
  cleanup?: boolean;
@@ -65,6 +65,12 @@ export type SocketBtmReleaseConfig = SocketBtmBinaryConfig | SocketBtmAssetConfi
65
65
  * Returns undefined for non-Linux platforms.
66
66
  *
67
67
  * @returns 'musl', 'glibc', or undefined (for non-Linux)
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const libc = detectLibc()
72
+ * console.log(libc) // 'glibc', 'musl', or undefined
73
+ * ```
68
74
  */
69
75
  export declare function detectLibc(): Libc | undefined;
70
76
  /**
@@ -73,6 +79,13 @@ export declare function detectLibc(): Libc | undefined;
73
79
  * @param tool - Tool/package name for release matching (e.g., 'lief', 'curl')
74
80
  * @param options - Download configuration
75
81
  * @returns Path to the downloaded file
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const binPath = await downloadSocketBtmRelease('lief', {
86
+ * downloadDir: '/tmp/build/downloaded',
87
+ * })
88
+ * ```
76
89
  */
77
90
  export declare function downloadSocketBtmRelease(tool: string, options: SocketBtmReleaseConfig | undefined): Promise<string>;
78
91
  /**
@@ -83,6 +96,12 @@ export declare function downloadSocketBtmRelease(tool: string, options: SocketBt
83
96
  * @param arch - Target architecture
84
97
  * @param libc - Linux libc variant (optional)
85
98
  * @returns Asset name (e.g., 'binject-darwin-arm64', 'node-linux-x64-musl')
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * getBinaryAssetName('lief', 'linux', 'x64', 'musl')
103
+ * // 'lief-linux-x64-musl'
104
+ * ```
86
105
  */
87
106
  export declare function getBinaryAssetName(binaryBaseName: string, platform: Platform, arch: Arch, libc?: Libc | undefined): string;
88
107
  /**
@@ -91,6 +110,12 @@ export declare function getBinaryAssetName(binaryBaseName: string, platform: Pla
91
110
  * @param binaryBaseName - Binary basename (e.g., 'node', 'binject')
92
111
  * @param platform - Target platform
93
112
  * @returns Binary filename (e.g., 'node', 'node.exe')
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * getBinaryName('node', 'win32') // 'node.exe'
117
+ * getBinaryName('node', 'linux') // 'node'
118
+ * ```
94
119
  */
95
120
  export declare function getBinaryName(binaryBaseName: string, platform: Platform): string;
96
121
  /**
@@ -101,5 +126,11 @@ export declare function getBinaryName(binaryBaseName: string, platform: Platform
101
126
  * @param arch - Target architecture
102
127
  * @param libc - Linux libc variant (optional)
103
128
  * @returns Platform-arch identifier (e.g., 'darwin-arm64', 'linux-x64-musl', 'win-x64')
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * getPlatformArch('linux', 'x64', 'musl') // 'linux-x64-musl'
133
+ * getPlatformArch('darwin', 'arm64') // 'darwin-arm64'
134
+ * ```
104
135
  */
105
136
  export declare function getPlatformArch(platform: Platform, arch: Arch, libc?: Libc | undefined): string;
package/dist/sea.d.ts CHANGED
@@ -1,10 +1,25 @@
1
1
  /**
2
2
  * Get the current SEA binary path.
3
3
  * Only valid when running as a SEA binary.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * const binPath = getSeaBinaryPath()
8
+ * if (binPath) {
9
+ * console.log(`Running as SEA binary: ${binPath}`)
10
+ * }
11
+ * ```
4
12
  */
5
13
  export declare function getSeaBinaryPath(): string | undefined;
6
14
  /**
7
15
  * Detect if the current process is running as a SEA binary.
8
16
  * Uses Node.js 24+ native API with caching for performance.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * if (isSeaBinary()) {
21
+ * console.log('Running as a Single Executable Application')
22
+ * }
23
+ * ```
9
24
  */
10
25
  export declare function isSeaBinary(): boolean;
package/dist/shadow.d.ts CHANGED
@@ -13,5 +13,12 @@ export interface ShadowInstallationOptions {
13
13
  * @param options.cwd - Current working directory path to check
14
14
  * @param options.win32 - Whether running on Windows
15
15
  * @returns true if shadow installation should be skipped
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * if (shouldSkipShadow(binPath, { cwd: process.cwd() })) {
20
+ * console.log('Skipping shadow binary installation')
21
+ * }
22
+ * ```
16
23
  */
17
24
  export declare function shouldSkipShadow(binPath: string, options?: ShadowInstallationOptions | undefined): boolean;
@@ -1,5 +1,11 @@
1
1
  /**
2
2
  * Load signal handlers and hook into process exit events.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * load()
7
+ * // Signal handlers are now active
8
+ * ```
3
9
  */
4
10
  /*@__NO_SIDE_EFFECTS__*/
5
11
  export declare function load(): void;
@@ -8,16 +14,37 @@ export interface OnExitOptions {
8
14
  }
9
15
  /**
10
16
  * Register a callback to run on process exit or signal.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const remove = onExit((code, signal) => {
21
+ * console.log(`Exiting with code ${code}, signal ${signal}`)
22
+ * })
23
+ * // Later, to unregister:
24
+ * remove()
25
+ * ```
11
26
  */
12
27
  /*@__NO_SIDE_EFFECTS__*/
13
28
  export declare function onExit(cb: (code: number | null, signal: string | null) => void, options?: OnExitOptions | undefined): () => void;
14
29
  /**
15
30
  * Get the list of signals that are currently being monitored.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const sigs = signals()
35
+ * console.log(sigs) // ['SIGABRT', 'SIGALRM', 'SIGHUP', ...]
36
+ * ```
16
37
  */
17
38
  /*@__NO_SIDE_EFFECTS__*/
18
39
  export declare function signals(): string[];
19
40
  /**
20
41
  * Unload signal handlers and restore original process behavior.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * unload()
46
+ * // Signal handlers are now removed
47
+ * ```
21
48
  */
22
49
  /*@__NO_SIDE_EFFECTS__*/
23
50
  export declare function unload(): void;
package/dist/sorts.d.ts CHANGED
@@ -1,20 +1,47 @@
1
1
  /**
2
2
  * Compare semantic versions.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * compareSemver('1.0.0', '2.0.0') // -1
7
+ * compareSemver('2.0.0', '1.0.0') // 1
8
+ * compareSemver('1.0.0', '1.0.0') // 0
9
+ * ```
3
10
  */
4
11
  /*@__NO_SIDE_EFFECTS__*/
5
12
  export declare function compareSemver(a: string, b: string): number;
6
13
  /**
7
14
  * Simple string comparison.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * compareStr('a', 'b') // -1
19
+ * compareStr('b', 'a') // 1
20
+ * compareStr('a', 'a') // 0
21
+ * ```
8
22
  */
9
23
  /*@__NO_SIDE_EFFECTS__*/
10
24
  export declare function compareStr(a: string, b: string): number;
11
25
  /**
12
26
  * Compare two strings using locale-aware comparison.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * localeCompare('a', 'b') // -1
31
+ * localeCompare('b', 'a') // 1
32
+ * localeCompare('a', 'a') // 0
33
+ * ```
13
34
  */
14
35
  /*@__NO_SIDE_EFFECTS__*/
15
36
  export declare function localeCompare(x: string, y: string): number;
16
37
  /**
17
38
  * Compare two strings using natural sorting (numeric-aware, case-insensitive).
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * naturalCompare('file2', 'file10') // negative (file2 before file10)
43
+ * naturalCompare('img10', 'img2') // positive (img10 after img2)
44
+ * ```
18
45
  */
19
46
  /*@__NO_SIDE_EFFECTS__*/
20
47
  export declare function naturalCompare(x: string, y: string): number;
@@ -22,6 +49,12 @@ export declare function naturalCompare(x: string, y: string): number;
22
49
  type FastSortFunction = ReturnType<typeof import('fast-sort').createNewSortInstance>;
23
50
  /**
24
51
  * Sort an array using natural comparison.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * naturalSorter(['file10', 'file2', 'file1']).asc()
56
+ * // ['file1', 'file2', 'file10']
57
+ * ```
25
58
  */
26
59
  /*@__NO_SIDE_EFFECTS__*/
27
60
  export declare function naturalSorter<T>(arrayToSort: T[]): ReturnType<FastSortFunction>;
package/dist/spawn.d.ts CHANGED
@@ -161,6 +161,15 @@ export interface SpawnSyncReturns<T> {
161
161
  /**
162
162
  * Enhances spawn error with better context.
163
163
  * Converts generic "command failed" to detailed error with command, exit code, and stderr.
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * try {
168
+ * await spawn('git', ['status'])
169
+ * } catch (err) {
170
+ * throw enhanceSpawnError(err)
171
+ * }
172
+ * ```
164
173
  */
165
174
  /*@__NO_SIDE_EFFECTS__*/
166
175
  export declare function enhanceSpawnError(error: unknown): unknown;
@@ -91,6 +91,12 @@ export interface OutputMask {
91
91
  * Create an output mask for controlling command output visibility.
92
92
  * The mask tracks whether output should be shown or hidden (buffered).
93
93
  * When hidden, output is buffered and a spinner is shown instead.
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * const mask = createOutputMask({ showOutput: false })
98
+ * console.log(mask.verbose) // false
99
+ * ```
94
100
  */
95
101
  export declare function createOutputMask(options?: OutputMaskOptions): OutputMask;
96
102
  /**
@@ -99,6 +105,13 @@ export declare function createOutputMask(options?: OutputMaskOptions): OutputMas
99
105
  * - ctrl+o: Toggle between showing and hiding output.
100
106
  * - ctrl+c: Cancel the running process.
101
107
  * The handler manipulates terminal state using ANSI escape sequences.
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * const handler = createKeyboardHandler(mask, childProcess, {
112
+ * message: 'Testing...',
113
+ * })
114
+ * ```
102
115
  */
103
116
  type ReadlineKey = {
104
117
  ctrl?: boolean;
@@ -113,6 +126,12 @@ export declare function createKeyboardHandler(mask: OutputMask, child: ChildProc
113
126
  * - Buffers stdout/stderr when not in verbose mode.
114
127
  * - Shows a spinner when output is masked.
115
128
  * - Allows toggling between masked and unmasked output with ctrl+o.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const child = spawn("pnpm", ["test"], { stdio: ["inherit", "pipe", "pipe"] })
133
+ * const exitCode = await attachOutputMask(child, { message: 'Running tests' })
134
+ * ```
116
135
  */
117
136
  export declare function attachOutputMask(child: ChildProcess, options?: OutputMaskOptions): Promise<number>;
118
137
  /**
@@ -120,6 +139,13 @@ export declare function attachOutputMask(child: ChildProcess, options?: OutputMa
120
139
  * Convenience wrapper around spawn + attachOutputMask.
121
140
  * Spawns a child process and attaches the output masking system to it.
122
141
  * stdin is inherited, stdout and stderr are piped for masking control.
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * const exitCode = await runWithMask('pnpm', ['test'], {
146
+ * message: 'Running tests',
147
+ * })
148
+ * ```
123
149
  */
124
150
  export declare function runWithMask(command: string, args?: string[], options?: OutputMaskOptions & SpawnOptions): Promise<number>;
125
151
  export {};
package/dist/streams.d.ts CHANGED
@@ -1,16 +1,44 @@
1
1
  import type { IterationOptions } from './promises';
2
2
  /**
3
3
  * Execute a function for each item in an iterable in parallel.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * const urls = ['https://a.io', 'https://b.io']
8
+ * await parallelEach(urls, async (url) => {
9
+ * await fetch(url)
10
+ * }, { concurrency: 4 })
11
+ * ```
4
12
  */
5
13
  /*@__NO_SIDE_EFFECTS__*/
6
14
  export declare function parallelEach<T>(iterable: Iterable<T> | AsyncIterable<T>, func: (item: T) => Promise<unknown>, options?: number | IterationOptions): Promise<void>;
7
15
  /**
8
16
  * Map over an iterable in parallel with concurrency control.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const ids = [1, 2, 3]
21
+ * for await (const result of parallelMap(ids, async (id) => {
22
+ * return await fetchData(id)
23
+ * }, 4)) {
24
+ * console.log(result)
25
+ * }
26
+ * ```
9
27
  */
10
28
  /*@__NO_SIDE_EFFECTS__*/
11
29
  export declare function parallelMap<T, U>(iterable: Iterable<T> | AsyncIterable<T>, func: (item: T) => Promise<U>, options?: number | IterationOptions): AsyncIterable<U>;
12
30
  /**
13
31
  * Transform an iterable with a function.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const lines = ['hello', 'world']
36
+ * for await (const upper of transform(lines, async (line) => {
37
+ * return line.toUpperCase()
38
+ * })) {
39
+ * console.log(upper) // 'HELLO', 'WORLD'
40
+ * }
41
+ * ```
14
42
  */
15
43
  /*@__NO_SIDE_EFFECTS__*/
16
44
  export declare function transform<T, U>(iterable: Iterable<T> | AsyncIterable<T>, func: (item: T) => Promise<U>, options?: number | IterationOptions): AsyncIterable<U>;
@@ -37,6 +37,13 @@ export declare function setMaxEventTargetListeners(target: EventTarget | AbortSi
37
37
  /**
38
38
  * Restore the original process.emitWarning function.
39
39
  * Call this to re-enable all warnings after suppressing them.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * suppressMaxListenersWarning()
44
+ * // ... do work ...
45
+ * restoreWarnings() // Re-enable all warnings
46
+ * ```
40
47
  */
41
48
  export declare function restoreWarnings(): void;
42
49
  /**
@@ -5,5 +5,12 @@
5
5
  * When package managers run commands via exec/npx/dlx, they execute in temporary directories
6
6
  * that are cleaned up after execution. Creating persistent shadows or modifying PATH
7
7
  * in these contexts can break subsequent package manager commands.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * if (isRunningInTemporaryExecutor()) {
12
+ * console.log('Running in a temporary executor context')
13
+ * }
14
+ * ```
8
15
  */
9
16
  export declare function isRunningInTemporaryExecutor(cwd?: string): boolean;
package/dist/url.d.ts CHANGED
@@ -1,15 +1,34 @@
1
1
  /**
2
2
  * Check if a value is a valid URL.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * isUrl('https://example.com') // true
7
+ * isUrl('not a url') // false
8
+ * isUrl(null) // false
9
+ * ```
3
10
  */
4
11
  /*@__NO_SIDE_EFFECTS__*/
5
12
  export declare function isUrl(value: string | URL | null | undefined): boolean;
6
13
  /**
7
14
  * Parse a value as a URL.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * parseUrl('https://example.com') // URL { href: 'https://example.com/' }
19
+ * parseUrl('invalid') // undefined
20
+ * ```
8
21
  */
9
22
  /*@__NO_SIDE_EFFECTS__*/
10
23
  export declare function parseUrl(value: string | URL): URL | undefined;
11
24
  /**
12
25
  * Convert a URL search parameter to an array.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * urlSearchParamAsArray('a, b, c') // ['a', 'b', 'c']
30
+ * urlSearchParamAsArray(null) // []
31
+ * ```
13
32
  */
14
33
  /*@__NO_SIDE_EFFECTS__*/
15
34
  export declare function urlSearchParamAsArray(value: string | null | undefined): string[];
@@ -18,11 +37,24 @@ export interface UrlSearchParamAsBooleanOptions {
18
37
  }
19
38
  /**
20
39
  * Convert a URL search parameter to a boolean.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * urlSearchParamAsBoolean('true') // true
44
+ * urlSearchParamAsBoolean('0') // false
45
+ * urlSearchParamAsBoolean(null) // false
46
+ * ```
21
47
  */
22
48
  /*@__NO_SIDE_EFFECTS__*/
23
49
  export declare function urlSearchParamAsBoolean(value: string | null | undefined, options?: UrlSearchParamAsBooleanOptions | undefined): boolean;
24
50
  /**
25
51
  * Helper to get array from URLSearchParams.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const params = new URLSearchParams('tags=a,b,c')
56
+ * urlSearchParamsGetArray(params, 'tags') // ['a', 'b', 'c']
57
+ * ```
26
58
  */
27
59
  /*@__NO_SIDE_EFFECTS__*/
28
60
  export declare function urlSearchParamsGetArray(params: URLSearchParams | null | undefined, key: string): string[];
@@ -31,6 +63,13 @@ export interface UrlSearchParamsGetBooleanOptions {
31
63
  }
32
64
  /**
33
65
  * Helper to get boolean from URLSearchParams.
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * const params = new URLSearchParams('debug=true')
70
+ * urlSearchParamsGetBoolean(params, 'debug') // true
71
+ * urlSearchParamsGetBoolean(params, 'other') // false
72
+ * ```
34
73
  */
35
74
  /*@__NO_SIDE_EFFECTS__*/
36
75
  export declare function urlSearchParamsGetBoolean(params: URLSearchParams | null | undefined, key: string, options?: UrlSearchParamsGetBooleanOptions | undefined): boolean;
@@ -39,6 +78,12 @@ export interface CreateRelativeUrlOptions {
39
78
  }
40
79
  /**
41
80
  * Create a relative URL for testing.
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * createRelativeUrl('/api/test') // 'api/test'
85
+ * createRelativeUrl('/api/test', { base: 'https://example.com' }) // 'https://example.com/api/test'
86
+ * ```
42
87
  */
43
88
  /*@__NO_SIDE_EFFECTS__*/
44
89
  export declare function createRelativeUrl(path: string, options?: CreateRelativeUrlOptions | undefined): string;
@@ -47,6 +92,13 @@ export interface UrlSearchParamAsStringOptions {
47
92
  }
48
93
  /**
49
94
  * Get string value from URLSearchParams with a default.
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const params = new URLSearchParams('name=socket')
99
+ * urlSearchParamAsString(params, 'name') // 'socket'
100
+ * urlSearchParamAsString(params, 'other') // ''
101
+ * ```
50
102
  */
51
103
  /*@__NO_SIDE_EFFECTS__*/
52
104
  export declare function urlSearchParamAsString(params: URLSearchParams | null | undefined, key: string, options?: UrlSearchParamAsStringOptions | undefined): string;
@@ -55,6 +107,13 @@ export interface UrlSearchParamAsNumberOptions {
55
107
  }
56
108
  /**
57
109
  * Get number value from URLSearchParams with a default.
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * const params = new URLSearchParams('limit=10')
114
+ * urlSearchParamAsNumber(params, 'limit') // 10
115
+ * urlSearchParamAsNumber(params, 'other') // 0
116
+ * ```
58
117
  */
59
118
  /*@__NO_SIDE_EFFECTS__*/
60
119
  export declare function urlSearchParamAsNumber(params: URLSearchParams | null | undefined, key: string, options?: UrlSearchParamAsNumberOptions | undefined): number;