ctx-core 5.32.1 → 5.34.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/all/cancel/index.d.ts +4 -0
- package/all/cancel/index.js +11 -0
- package/all/file_exists/index.browser.js +3 -7
- package/all/file_exists/index.d.ts +1 -1
- package/all/file_exists/index.js +16 -4
- package/all/file_exists/index.test.ts +1 -1
- package/all/import_meta_env/index.d.ts +5 -5
- package/package.json +2 -2
package/all/cancel/index.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ export declare class Cancel<R = unknown> extends Error {
|
|
|
2
2
|
constructor(config?:Cancel_config_T<R>)
|
|
3
3
|
returns:R
|
|
4
4
|
}
|
|
5
|
+
export declare function promise__cancel<P extends Promise<unknown>>(
|
|
6
|
+
promise:P
|
|
7
|
+
):P
|
|
8
|
+
export declare function promise__cancel__throw(promise:Promise<unknown>):void
|
|
5
9
|
export type Cancel_config_T<R = unknown> = {
|
|
6
10
|
message?:string
|
|
7
11
|
returns?:R
|
package/all/cancel/index.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
export class Cancel extends Error {
|
|
2
2
|
constructor(config) {
|
|
3
3
|
super(config?.message ?? 'Cancel')
|
|
4
|
+
this.name = 'Cancel'
|
|
4
5
|
this.returns = config?.returns
|
|
5
6
|
}
|
|
6
7
|
}
|
|
8
|
+
export function promise__cancel(promise) {
|
|
9
|
+
promise.cancel?.()
|
|
10
|
+
promise.catch(()=>{})
|
|
11
|
+
return promise
|
|
12
|
+
}
|
|
13
|
+
export function promise__cancel__throw(promise) {
|
|
14
|
+
promise.cancel?.()
|
|
15
|
+
promise.catch(()=>{})
|
|
16
|
+
throw new Cancel
|
|
17
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { waitfor } from '../waitfor/index.browser.js'
|
|
2
1
|
/**
|
|
3
2
|
* @param {string}path
|
|
4
3
|
* @returns {Promise<boolean>}
|
|
@@ -11,18 +10,15 @@ export {
|
|
|
11
10
|
file_exists_ as path__exists_
|
|
12
11
|
}
|
|
13
12
|
/**
|
|
14
|
-
* @param {string}
|
|
13
|
+
* @param {string|(()=>unknown|Promise<unknown>)}path_OR_op
|
|
15
14
|
* @param {number}[timeout]
|
|
16
15
|
* @param {number|((promise:waitfor_Promise<boolean>)=>Promise<number>)}[period]
|
|
17
16
|
* @returns {Promise<boolean>}
|
|
18
17
|
*/
|
|
19
18
|
export function file_exists__waitfor(
|
|
20
|
-
|
|
19
|
+
path_OR_op,
|
|
21
20
|
timeout,
|
|
22
21
|
period
|
|
23
22
|
) {
|
|
24
|
-
|
|
25
|
-
file_exists_(path),
|
|
26
|
-
timeout ?? 5000,
|
|
27
|
-
period ?? 0)
|
|
23
|
+
throw new Error('no browser support')
|
|
28
24
|
}
|
|
@@ -4,7 +4,7 @@ export {
|
|
|
4
4
|
file_exists_ as path__exists_
|
|
5
5
|
}
|
|
6
6
|
export declare function file_exists__waitfor(
|
|
7
|
-
|
|
7
|
+
path_OR_op:string|(()=>unknown|Promise<unknown>),
|
|
8
8
|
timeout?:number,
|
|
9
9
|
period?:number|((promise:waitfor_Promise<boolean>)=>Promise<number>)
|
|
10
10
|
):waitfor_Promise<boolean>
|
package/all/file_exists/index.js
CHANGED
|
@@ -15,18 +15,30 @@ export {
|
|
|
15
15
|
file_exists_ as path__exists_
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* @param {string}
|
|
18
|
+
* @param {string|(()=>unknown|Promise<unknown>)}path_OR_op
|
|
19
19
|
* @param {number}[timeout]
|
|
20
20
|
* @param {number|((promise:waitfor_Promise<boolean>)=>Promise<number>)}[period]
|
|
21
21
|
* @returns {Promise<boolean>}
|
|
22
22
|
*/
|
|
23
23
|
export function file_exists__waitfor(
|
|
24
|
-
|
|
24
|
+
path_OR_op,
|
|
25
25
|
timeout,
|
|
26
26
|
period
|
|
27
27
|
) {
|
|
28
|
-
return waitfor(()=>
|
|
29
|
-
|
|
28
|
+
return waitfor(async ()=>{
|
|
29
|
+
// eslint-disable-next-line no-constant-condition
|
|
30
|
+
for (; 1;) {
|
|
31
|
+
try {
|
|
32
|
+
return await (
|
|
33
|
+
typeof path_OR_op === 'string'
|
|
34
|
+
? file_exists_(path_OR_op)
|
|
35
|
+
: path_OR_op()
|
|
36
|
+
)
|
|
37
|
+
} catch (err) {
|
|
38
|
+
if (err.code !== 'ENOENT') throw err
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
30
42
|
timeout ?? 5000,
|
|
31
43
|
period ?? 0)
|
|
32
44
|
}
|
|
@@ -46,7 +46,7 @@ test('file_exists_ + file_exists__waitfor|browser', async ()=>{
|
|
|
46
46
|
await unlink(tempfile_path)
|
|
47
47
|
}
|
|
48
48
|
equal(await browser_file_exists_(tempfile_path), false)
|
|
49
|
-
equal(err?.message, '
|
|
49
|
+
equal(err?.message, 'no browser support')
|
|
50
50
|
})
|
|
51
51
|
test('browser|build', async ()=>{
|
|
52
52
|
await build({
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export function import_meta_env_<R extends
|
|
2
|
-
export function import_meta_env__ensure<R extends
|
|
1
|
+
export function import_meta_env_<R extends import_meta_env_T>():R
|
|
2
|
+
export function import_meta_env__ensure<R extends import_meta_env_T>():R
|
|
3
3
|
declare global {
|
|
4
|
-
interface
|
|
5
|
-
readonly env:
|
|
4
|
+
interface import_meta_T {
|
|
5
|
+
readonly env:import_meta_env_T
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
interface
|
|
8
|
+
interface import_meta_env_T {
|
|
9
9
|
[key:string]:string
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ctx-core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.34.0",
|
|
4
4
|
"description": "ctx-core core library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ctx-core",
|
|
@@ -290,7 +290,7 @@
|
|
|
290
290
|
"@arethetypeswrong/cli": "^0.13.6",
|
|
291
291
|
"@ctx-core/preprocess": "^0.1.1",
|
|
292
292
|
"@size-limit/preset-small-lib": "^11.0.2",
|
|
293
|
-
"@types/node": "^20.11.
|
|
293
|
+
"@types/node": "^20.11.10",
|
|
294
294
|
"@types/sinon": "^17.0.3",
|
|
295
295
|
"c8": "^9.1.0",
|
|
296
296
|
"check-dts": "^0.7.2",
|