@ceale/util 1.12.3 → 1.12.4
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/cjs/index.js +19 -1
- package/dist/esm/index.js +6 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
2
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
5
18
|
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
6
19
|
var __toCommonJS = (from) => {
|
|
7
20
|
var entry = __moduleCache.get(from), desc;
|
|
@@ -411,8 +424,9 @@ class CubicBezier {
|
|
|
411
424
|
}
|
|
412
425
|
}
|
|
413
426
|
// src/error.ts
|
|
427
|
+
var import_promises = __toESM(require("node:fs/promises"));
|
|
414
428
|
var tryCatch = (parameter) => {
|
|
415
|
-
if (
|
|
429
|
+
if (typeof parameter === "object") {
|
|
416
430
|
return parameter.then((data) => Object.assign([data, null], { data, error: null })).catch((error) => Object.assign([null, error], { data: null, error }));
|
|
417
431
|
}
|
|
418
432
|
if (typeof parameter === "function") {
|
|
@@ -425,3 +439,7 @@ var tryCatch = (parameter) => {
|
|
|
425
439
|
}
|
|
426
440
|
throw new TypeError("参数类型错误,应为 Promise 或函数");
|
|
427
441
|
};
|
|
442
|
+
(async () => {
|
|
443
|
+
const a = await tryCatch(import_promises.default.stat("a.txt"));
|
|
444
|
+
console.log(typeof a);
|
|
445
|
+
})();
|
package/dist/esm/index.js
CHANGED
|
@@ -364,8 +364,9 @@ class CubicBezier {
|
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
// src/error.ts
|
|
367
|
+
import fs from "node:fs/promises";
|
|
367
368
|
var tryCatch = (parameter) => {
|
|
368
|
-
if (
|
|
369
|
+
if (typeof parameter === "object") {
|
|
369
370
|
return parameter.then((data) => Object.assign([data, null], { data, error: null })).catch((error) => Object.assign([null, error], { data: null, error }));
|
|
370
371
|
}
|
|
371
372
|
if (typeof parameter === "function") {
|
|
@@ -378,6 +379,10 @@ var tryCatch = (parameter) => {
|
|
|
378
379
|
}
|
|
379
380
|
throw new TypeError("参数类型错误,应为 Promise 或函数");
|
|
380
381
|
};
|
|
382
|
+
(async () => {
|
|
383
|
+
const a = await tryCatch(fs.stat("a.txt"));
|
|
384
|
+
console.log(typeof a);
|
|
385
|
+
})();
|
|
381
386
|
export {
|
|
382
387
|
waitSync,
|
|
383
388
|
wait,
|