@cto.af/utils 1.0.0 → 1.2.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/lib/index.d.ts +26 -1
- package/lib/index.js +1 -1
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -14,5 +14,30 @@ declare function isErrno(e: unknown): e is NodeJS.ErrnoException;
|
|
|
14
14
|
* @throws {TypeError} On invalid code type.
|
|
15
15
|
*/
|
|
16
16
|
declare function errCode(e: unknown, code: string | number): boolean;
|
|
17
|
+
interface CiOptions {
|
|
18
|
+
CI?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Is the current environment CI-like.
|
|
22
|
+
*
|
|
23
|
+
* @param opts Override the environment determination, for testing.
|
|
24
|
+
* @returns True if in CI.
|
|
25
|
+
*/
|
|
26
|
+
declare function isCI(opts?: CiOptions): boolean;
|
|
27
|
+
interface PromiseWithResolvers<T> {
|
|
28
|
+
promise: Promise<T>;
|
|
29
|
+
resolve(value: T | PromiseLike<T>): void;
|
|
30
|
+
reject(reason?: any): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Polyfill for Promise.withResolvers. Once node 22 is the minimum version,
|
|
34
|
+
* this should be removed.
|
|
35
|
+
*
|
|
36
|
+
* @template T Return type for resolve.
|
|
37
|
+
* @returns An object containing a new Promise object and two functions to
|
|
38
|
+
* resolve or reject it, corresponding to the two parameters passed to the
|
|
39
|
+
* executor of the Promise() constructor.
|
|
40
|
+
*/
|
|
41
|
+
declare function promiseWithResolvers<T>(): PromiseWithResolvers<T>;
|
|
17
42
|
|
|
18
|
-
export { errCode, isErrno };
|
|
43
|
+
export { type CiOptions, type PromiseWithResolvers, errCode, isCI, isErrno, promiseWithResolvers };
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e
|
|
1
|
+
function t(e){return e instanceof Error&&Object.prototype.hasOwnProperty.call(e,"code")}function a(e,r){if(!t(e))return!1;switch(typeof r){case"string":return e.code===r;case"number":return e.errno===r}throw new TypeError(`Invalid code: ${JSON.stringify(r)}`)}function c(e){if(e&&"CI"in e)return!!e.CI;let{env:r}=process;return!!(r.CI||r.CONTINUOUS_INTEGRATION||r.BUILD_NUMBER||r.RUN_ID)}var o=()=>{};function l(){let e=o,r=o;return{promise:new Promise((n,i)=>{e=n,r=i}),resolve:e,reject:r}}export{a as errCode,c as isCI,t as isErrno,l as promiseWithResolvers};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cto.af/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"decription": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"bugs": {
|
|
19
19
|
"url": "https://github.com/cto-af/utils/issues"
|
|
20
20
|
},
|
|
21
|
-
"packageManager": "pnpm@10.
|
|
21
|
+
"packageManager": "pnpm@10.11.0",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=20"
|
|
24
24
|
}
|