@fuzdev/fuz_util 0.45.2 → 0.46.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.
- package/dist/array.d.ts +1 -1
- package/dist/array.js +1 -1
- package/dist/async.d.ts +18 -0
- package/dist/async.d.ts.map +1 -1
- package/dist/async.js +63 -3
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +2 -2
- package/dist/fetch.d.ts +1 -1
- package/dist/fetch.js +1 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/git.js +10 -10
- package/dist/path.d.ts +1 -1
- package/dist/path.js +2 -2
- package/dist/print.d.ts +1 -1
- package/dist/print.js +1 -1
- package/dist/process.d.ts +303 -43
- package/dist/process.d.ts.map +1 -1
- package/dist/process.js +475 -108
- package/dist/random.d.ts +1 -1
- package/dist/random.js +1 -1
- package/dist/regexp.d.ts +1 -1
- package/dist/regexp.js +1 -1
- package/package.json +6 -5
- package/src/lib/array.ts +1 -1
- package/src/lib/async.ts +72 -3
- package/src/lib/dom.ts +2 -2
- package/src/lib/fetch.ts +1 -1
- package/src/lib/git.ts +20 -10
- package/src/lib/path.ts +2 -2
- package/src/lib/print.ts +1 -1
- package/src/lib/process.ts +681 -135
- package/src/lib/random.ts +1 -1
- package/src/lib/regexp.ts +1 -1
package/dist/array.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const EMPTY_ARRAY: Array<any>;
|
|
|
4
4
|
export declare const to_array: <T>(value: T) => T extends ReadonlyArray<any> ? T : Array<T>;
|
|
5
5
|
/**
|
|
6
6
|
* Removes an element from `array` at `index` in an unordered manner.
|
|
7
|
-
* @mutates array swaps element at index with last element, then removes last element
|
|
7
|
+
* @mutates array - swaps element at index with last element, then removes last element
|
|
8
8
|
*/
|
|
9
9
|
export declare const remove_unordered: (array: Array<any>, index: number) => void;
|
|
10
10
|
/**
|
package/dist/array.js
CHANGED
|
@@ -4,7 +4,7 @@ export const EMPTY_ARRAY = Object.freeze([]);
|
|
|
4
4
|
export const to_array = (value) => Array.isArray(value) ? value : [value];
|
|
5
5
|
/**
|
|
6
6
|
* Removes an element from `array` at `index` in an unordered manner.
|
|
7
|
-
* @mutates array swaps element at index with last element, then removes last element
|
|
7
|
+
* @mutates array - swaps element at index with last element, then removes last element
|
|
8
8
|
*/
|
|
9
9
|
export const remove_unordered = (array, index) => {
|
|
10
10
|
array[index] = array[array.length - 1];
|
package/dist/async.d.ts
CHANGED
|
@@ -19,6 +19,24 @@ export interface Deferred<T> {
|
|
|
19
19
|
* Creates a object with a `promise` and its `resolve`/`reject` handlers.
|
|
20
20
|
*/
|
|
21
21
|
export declare const create_deferred: <T>() => Deferred<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Runs an async function on each item with controlled concurrency.
|
|
24
|
+
* Like `map_concurrent` but doesn't collect results (more efficient for side effects).
|
|
25
|
+
*
|
|
26
|
+
* @param items array of items to process
|
|
27
|
+
* @param fn async function to apply to each item
|
|
28
|
+
* @param concurrency maximum number of concurrent operations
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* await each_concurrent(
|
|
33
|
+
* file_paths,
|
|
34
|
+
* async (path) => { await unlink(path); },
|
|
35
|
+
* 5, // max 5 concurrent deletions
|
|
36
|
+
* );
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare const each_concurrent: <T>(items: Array<T>, fn: (item: T, index: number) => Promise<void>, concurrency: number) => Promise<void>;
|
|
22
40
|
/**
|
|
23
41
|
* Maps over items with controlled concurrency, preserving input order.
|
|
24
42
|
*
|
package/dist/async.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/async.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,IAAI,GAAI,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AC;IAC5B,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;CAC9B;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,OAAK,QAAQ,CAAC,CAAC,CAQ/C,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,eAAe,GAAU,CAAC,EACtC,OAAO,KAAK,CAAC,CAAC,CAAC,EACf,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,EAC7C,aAAa,MAAM,KACjB,OAAO,CAAC,IAAI,CAgDd,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc,GAAU,CAAC,EAAE,CAAC,EACxC,OAAO,KAAK,CAAC,CAAC,CAAC,EACf,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EAC1C,aAAa,MAAM,KACjB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAkDlB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,sBAAsB,GAAU,CAAC,EAAE,CAAC,EAChD,OAAO,KAAK,CAAC,CAAC,CAAC,EACf,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EAC1C,aAAa,MAAM,KACjB,OAAO,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CA6CxC,CAAC"}
|
package/dist/async.js
CHANGED
|
@@ -18,6 +18,68 @@ export const create_deferred = () => {
|
|
|
18
18
|
});
|
|
19
19
|
return { promise, resolve, reject };
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Runs an async function on each item with controlled concurrency.
|
|
23
|
+
* Like `map_concurrent` but doesn't collect results (more efficient for side effects).
|
|
24
|
+
*
|
|
25
|
+
* @param items array of items to process
|
|
26
|
+
* @param fn async function to apply to each item
|
|
27
|
+
* @param concurrency maximum number of concurrent operations
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* await each_concurrent(
|
|
32
|
+
* file_paths,
|
|
33
|
+
* async (path) => { await unlink(path); },
|
|
34
|
+
* 5, // max 5 concurrent deletions
|
|
35
|
+
* );
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export const each_concurrent = async (items, fn, concurrency) => {
|
|
39
|
+
if (concurrency < 1) {
|
|
40
|
+
throw new Error('concurrency must be at least 1');
|
|
41
|
+
}
|
|
42
|
+
let next_index = 0;
|
|
43
|
+
let active_count = 0;
|
|
44
|
+
let rejected = false;
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
const run_next = () => {
|
|
47
|
+
// Stop spawning if we've rejected
|
|
48
|
+
if (rejected)
|
|
49
|
+
return;
|
|
50
|
+
// Check if we're done
|
|
51
|
+
if (next_index >= items.length && active_count === 0) {
|
|
52
|
+
resolve();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// Spawn workers up to concurrency limit
|
|
56
|
+
while (active_count < concurrency && next_index < items.length) {
|
|
57
|
+
const index = next_index++;
|
|
58
|
+
const item = items[index];
|
|
59
|
+
active_count++;
|
|
60
|
+
fn(item, index)
|
|
61
|
+
.then(() => {
|
|
62
|
+
if (rejected)
|
|
63
|
+
return;
|
|
64
|
+
active_count--;
|
|
65
|
+
run_next();
|
|
66
|
+
})
|
|
67
|
+
.catch((error) => {
|
|
68
|
+
if (rejected)
|
|
69
|
+
return;
|
|
70
|
+
rejected = true;
|
|
71
|
+
reject(error); // eslint-disable-line @typescript-eslint/prefer-promise-reject-errors
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
// Handle empty array
|
|
76
|
+
if (items.length === 0) {
|
|
77
|
+
resolve();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
run_next();
|
|
81
|
+
});
|
|
82
|
+
};
|
|
21
83
|
/**
|
|
22
84
|
* Maps over items with controlled concurrency, preserving input order.
|
|
23
85
|
*
|
|
@@ -43,7 +105,6 @@ export const map_concurrent = async (items, fn, concurrency) => {
|
|
|
43
105
|
let next_index = 0;
|
|
44
106
|
let active_count = 0;
|
|
45
107
|
let rejected = false;
|
|
46
|
-
let reject_error;
|
|
47
108
|
return new Promise((resolve, reject) => {
|
|
48
109
|
const run_next = () => {
|
|
49
110
|
// Stop spawning if we've rejected
|
|
@@ -71,8 +132,7 @@ export const map_concurrent = async (items, fn, concurrency) => {
|
|
|
71
132
|
if (rejected)
|
|
72
133
|
return;
|
|
73
134
|
rejected = true;
|
|
74
|
-
|
|
75
|
-
reject(reject_error); // eslint-disable-line @typescript-eslint/prefer-promise-reject-errors
|
|
135
|
+
reject(error); // eslint-disable-line @typescript-eslint/prefer-promise-reject-errors
|
|
76
136
|
});
|
|
77
137
|
}
|
|
78
138
|
};
|
package/dist/dom.d.ts
CHANGED
|
@@ -18,14 +18,14 @@ export declare const is_interactive: (el: any) => boolean;
|
|
|
18
18
|
* @param event
|
|
19
19
|
* @param immediate defaults to `true` to use `stopImmediatePropagation` over `stopPropagation`
|
|
20
20
|
* @param preventDefault defaults to `true`
|
|
21
|
-
* @mutates event calls preventDefault(), stopPropagation(), or stopImmediatePropagation()
|
|
21
|
+
* @mutates event - calls preventDefault(), stopPropagation(), or stopImmediatePropagation()
|
|
22
22
|
* @returns
|
|
23
23
|
*/
|
|
24
24
|
export declare const swallow: <T extends Pick<Event, "preventDefault" | "stopPropagation" | "stopImmediatePropagation">>(event: T, immediate?: boolean, preventDefault?: boolean) => T;
|
|
25
25
|
/**
|
|
26
26
|
* Handles the value of an event's target and invokes a callback.
|
|
27
27
|
* Defaults to swallowing the event to prevent default actions and propagation.
|
|
28
|
-
* @mutates event calls `swallow()` which mutates the event if `swallow_event` is true
|
|
28
|
+
* @mutates event - calls `swallow()` which mutates the event if `swallow_event` is true
|
|
29
29
|
*/
|
|
30
30
|
export declare const handle_target_value: (cb: (value: any, event: any) => void, swallow_event?: boolean) => (e: any) => void;
|
|
31
31
|
/**
|
package/dist/dom.js
CHANGED
|
@@ -55,7 +55,7 @@ export const is_interactive = (el) => {
|
|
|
55
55
|
* @param event
|
|
56
56
|
* @param immediate defaults to `true` to use `stopImmediatePropagation` over `stopPropagation`
|
|
57
57
|
* @param preventDefault defaults to `true`
|
|
58
|
-
* @mutates event calls preventDefault(), stopPropagation(), or stopImmediatePropagation()
|
|
58
|
+
* @mutates event - calls preventDefault(), stopPropagation(), or stopImmediatePropagation()
|
|
59
59
|
* @returns
|
|
60
60
|
*/
|
|
61
61
|
export const swallow = (event, immediate = true, preventDefault = true) => {
|
|
@@ -73,7 +73,7 @@ export const swallow = (event, immediate = true, preventDefault = true) => {
|
|
|
73
73
|
/**
|
|
74
74
|
* Handles the value of an event's target and invokes a callback.
|
|
75
75
|
* Defaults to swallowing the event to prevent default actions and propagation.
|
|
76
|
-
* @mutates event calls `swallow()` which mutates the event if `swallow_event` is true
|
|
76
|
+
* @mutates event - calls `swallow()` which mutates the event if `swallow_event` is true
|
|
77
77
|
*/
|
|
78
78
|
export const handle_target_value = (cb, swallow_event = true) => (e) => {
|
|
79
79
|
if (swallow_event)
|
package/dist/fetch.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export interface FetchValueOptions<TValue, TParams = undefined> {
|
|
|
40
40
|
* If the `value` is cached, only the cached safe subset of the `headers` are returned.
|
|
41
41
|
* (currently just `etag` and `last-modified`)
|
|
42
42
|
* Otherwise the full `res.headers` are included.
|
|
43
|
-
* @mutates options.cache calls `cache.set()` to store fetched results if cache is provided
|
|
43
|
+
* @mutates options.cache - calls `cache.set()` to store fetched results if cache is provided
|
|
44
44
|
*/
|
|
45
45
|
export declare const fetch_value: <TValue = any, TParams = undefined>(url: string | URL, options?: FetchValueOptions<TValue, TParams>) => Promise<Result<{
|
|
46
46
|
value: TValue;
|
package/dist/fetch.js
CHANGED
|
@@ -28,7 +28,7 @@ const DEFAULT_GITHUB_API_VERSION_HEADER = '2022-11-28';
|
|
|
28
28
|
* If the `value` is cached, only the cached safe subset of the `headers` are returned.
|
|
29
29
|
* (currently just `etag` and `last-modified`)
|
|
30
30
|
* Otherwise the full `res.headers` are included.
|
|
31
|
-
* @mutates options.cache calls `cache.set()` to store fetched results if cache is provided
|
|
31
|
+
* @mutates options.cache - calls `cache.set()` to store fetched results if cache is provided
|
|
32
32
|
*/
|
|
33
33
|
export const fetch_value = async (url, options) => {
|
|
34
34
|
const { request, params, parse, token, cache, return_early_from_cache, log, fetch = globalThis.fetch, } = options ?? EMPTY_OBJECT;
|
package/dist/git.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/git.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAGtB,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAIzC;;GAEG;AACH,MAAM,WAAW,OAAO;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAU,UAAU,YAAY,KAAG,OAAO,CAAC,OAAO,CAU1E,CAAC;AAEF,eAAO,MAAM,SAAS,aAAa,CAAC;AACpC,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEtD,eAAO,MAAM,SAAS,aAAa,CAAC;AACpC,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAU,UAAU,YAAY,KAAG,OAAO,CA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,MAAM,kBAAkB,GAC9B,SAAQ,SAAiC,EACzC,SAAS,SAAS,EAClB,UAAU,YAAY,KACpB,OAAO,CAAC,IAAI,CAed,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,GACnC,QAAQ,SAAS,EACjB,UAAU,YAAY,KACpB,OAAO,CAAC,IAAI,CAOd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACpC,QAAQ,SAAS,EACjB,QAAQ,SAAS,EACjB,UAAU,YAAY,KACpB,OAAO,CAAC,IAAI,CAOd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gCAAgC,GAC5C,QAAQ,SAAS,EACjB,QAAQ,SAAS,EACjB,UAAU,YAAY,KACpB,OAAO,CAAC,IAAI,CAQd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,GACnC,SAAS,MAAM,EACf,UAAU,YAAY,KACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAKvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oCAAoC,GAChD,UAAU,YAAY,KACpB,OAAO,CAAC,MAAM,CAQhB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,6BAA6B,GAAU,UAAU,YAAY,KAAG,OAAO,CAAC,OAAO,CAG3F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC7B,QAAQ,SAAS,EACjB,QAAQ,SAAS,EACjB,YAAY,MAAM,EAClB,YAAY,MAAM,EAClB,UAAU,YAAY,KACpB,OAAO,CAAC,IAAI,CAOd,CAAC"}
|
package/dist/git.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { spawn, spawn_out } from './process.js';
|
|
2
|
+
import { spawn, spawn_out, spawn_result_to_message } from './process.js';
|
|
3
3
|
import { to_file_path } from './path.js';
|
|
4
4
|
import { fs_exists } from './fs.js';
|
|
5
5
|
/**
|
|
@@ -40,11 +40,11 @@ export const git_remote_branch_exists = async (origin = 'origin', branch, option
|
|
|
40
40
|
if (result.ok) {
|
|
41
41
|
return true;
|
|
42
42
|
}
|
|
43
|
-
else if (result.code === 2) {
|
|
43
|
+
else if ('code' in result && result.code === 2) {
|
|
44
44
|
return false;
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
|
-
throw Error(`git_remote_branch_exists failed for origin '${origin}' and branch '${final_branch}' with
|
|
47
|
+
throw Error(`git_remote_branch_exists failed for origin '${origin}' and branch '${final_branch}' with ${spawn_result_to_message(result)}`);
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
/**
|
|
@@ -173,7 +173,7 @@ export const git_fetch = async (origin = 'origin', branch, options) => {
|
|
|
173
173
|
args.push(branch);
|
|
174
174
|
const result = await spawn('git', args, options);
|
|
175
175
|
if (!result.ok) {
|
|
176
|
-
throw Error(`git_fetch failed for origin '${origin}' and branch '${branch}' with
|
|
176
|
+
throw Error(`git_fetch failed for origin '${origin}' and branch '${branch}' with ${spawn_result_to_message(result)}`);
|
|
177
177
|
}
|
|
178
178
|
};
|
|
179
179
|
/**
|
|
@@ -187,7 +187,7 @@ export const git_checkout = async (branch, options) => {
|
|
|
187
187
|
}
|
|
188
188
|
const result = await spawn('git', ['checkout', branch], options);
|
|
189
189
|
if (!result.ok) {
|
|
190
|
-
throw Error(`git_checkout failed for branch '${branch}' with
|
|
190
|
+
throw Error(`git_checkout failed for branch '${branch}' with ${spawn_result_to_message(result)}`);
|
|
191
191
|
}
|
|
192
192
|
return current_branch;
|
|
193
193
|
};
|
|
@@ -200,7 +200,7 @@ export const git_pull = async (origin = 'origin', branch, options) => {
|
|
|
200
200
|
args.push(branch);
|
|
201
201
|
const result = await spawn('git', args, options);
|
|
202
202
|
if (!result.ok) {
|
|
203
|
-
throw Error(`git_pull failed for branch '${branch}' with
|
|
203
|
+
throw Error(`git_pull failed for branch '${branch}' with ${spawn_result_to_message(result)}`);
|
|
204
204
|
}
|
|
205
205
|
};
|
|
206
206
|
/**
|
|
@@ -213,7 +213,7 @@ export const git_push = async (origin, branch, options, set_upstream = false) =>
|
|
|
213
213
|
args.push('-u');
|
|
214
214
|
const result = await spawn('git', args, options);
|
|
215
215
|
if (!result.ok) {
|
|
216
|
-
throw Error(`git_push failed for branch '${final_branch}' with
|
|
216
|
+
throw Error(`git_push failed for branch '${final_branch}' with ${spawn_result_to_message(result)}`);
|
|
217
217
|
}
|
|
218
218
|
};
|
|
219
219
|
/**
|
|
@@ -231,7 +231,7 @@ export const git_push_to_create = async (origin = 'origin', branch, options) =>
|
|
|
231
231
|
push_args.push(final_branch);
|
|
232
232
|
const result = await spawn('git', push_args, options);
|
|
233
233
|
if (!result.ok) {
|
|
234
|
-
throw Error(`git_push failed for branch '${final_branch}' with
|
|
234
|
+
throw Error(`git_push failed for branch '${final_branch}' with ${spawn_result_to_message(result)}`);
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
237
|
/**
|
|
@@ -240,7 +240,7 @@ export const git_push_to_create = async (origin = 'origin', branch, options) =>
|
|
|
240
240
|
export const git_delete_local_branch = async (branch, options) => {
|
|
241
241
|
const result = await spawn('git', ['branch', '-D', branch], options);
|
|
242
242
|
if (!result.ok) {
|
|
243
|
-
throw Error(`git_delete_local_branch failed for branch '${branch}' with
|
|
243
|
+
throw Error(`git_delete_local_branch failed for branch '${branch}' with ${spawn_result_to_message(result)}`);
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
246
|
/**
|
|
@@ -249,7 +249,7 @@ export const git_delete_local_branch = async (branch, options) => {
|
|
|
249
249
|
export const git_delete_remote_branch = async (origin, branch, options) => {
|
|
250
250
|
const result = await spawn('git', ['push', origin, ':' + branch], options);
|
|
251
251
|
if (!result.ok) {
|
|
252
|
-
throw Error(`git_delete_remote_branch failed for branch '${branch}' with
|
|
252
|
+
throw Error(`git_delete_remote_branch failed for branch '${branch}' with ${spawn_result_to_message(result)}`);
|
|
253
253
|
}
|
|
254
254
|
};
|
|
255
255
|
/**
|
package/dist/path.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export declare const parse_path_pieces: (raw_path: string) => Array<PathPiece>;
|
|
|
57
57
|
* Converts a string into a URL-compatible slug.
|
|
58
58
|
* @param str the string to convert
|
|
59
59
|
* @param map_special_characters if `true`, characters like `ñ` are converted to their ASCII equivalents, runs around 5x faster when disabled
|
|
60
|
-
* @mutates special_char_mappers calls `get_special_char_mappers()` which lazily initializes the module-level array if `map_special_characters` is true
|
|
60
|
+
* @mutates special_char_mappers - calls `get_special_char_mappers()` which lazily initializes the module-level array if `map_special_characters` is true
|
|
61
61
|
*/
|
|
62
62
|
export declare const slugify: (str: string, map_special_characters?: boolean) => string;
|
|
63
63
|
//# sourceMappingURL=path.d.ts.map
|
package/dist/path.js
CHANGED
|
@@ -46,7 +46,7 @@ export const parse_path_pieces = (raw_path) => {
|
|
|
46
46
|
* Converts a string into a URL-compatible slug.
|
|
47
47
|
* @param str the string to convert
|
|
48
48
|
* @param map_special_characters if `true`, characters like `ñ` are converted to their ASCII equivalents, runs around 5x faster when disabled
|
|
49
|
-
* @mutates special_char_mappers calls `get_special_char_mappers()` which lazily initializes the module-level array if `map_special_characters` is true
|
|
49
|
+
* @mutates special_char_mappers - calls `get_special_char_mappers()` which lazily initializes the module-level array if `map_special_characters` is true
|
|
50
50
|
*/
|
|
51
51
|
export const slugify = (str, map_special_characters = true) => {
|
|
52
52
|
let s = str.toLowerCase();
|
|
@@ -70,7 +70,7 @@ let special_char_mappers;
|
|
|
70
70
|
/**
|
|
71
71
|
* Lazily constructs `special_char_mappers` which
|
|
72
72
|
* converts special characters to their ASCII equivalents.
|
|
73
|
-
* @mutates special_char_mappers pushes mapper functions into module-level array on first call
|
|
73
|
+
* @mutates special_char_mappers - pushes mapper functions into module-level array on first call
|
|
74
74
|
*/
|
|
75
75
|
const get_special_char_mappers = () => {
|
|
76
76
|
if (special_char_mappers)
|
package/dist/print.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Logger } from './log.js';
|
|
|
4
4
|
export declare let st: typeof styleText;
|
|
5
5
|
/**
|
|
6
6
|
* Configures the module-level styling function for colored output.
|
|
7
|
-
* @mutates st assigns the module-level `st` variable
|
|
7
|
+
* @mutates st - assigns the module-level `st` variable
|
|
8
8
|
*/
|
|
9
9
|
export declare const configure_print_colors: (s: typeof styleText | null | undefined) => typeof styleText;
|
|
10
10
|
/**
|
package/dist/print.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export let st = (_, v) => v;
|
|
2
2
|
/**
|
|
3
3
|
* Configures the module-level styling function for colored output.
|
|
4
|
-
* @mutates st assigns the module-level `st` variable
|
|
4
|
+
* @mutates st - assigns the module-level `st` variable
|
|
5
5
|
*/
|
|
6
6
|
export const configure_print_colors = (s) => {
|
|
7
7
|
st = s ?? ((_, v) => v);
|