@catbee/utils 0.0.8-rc.1 → 0.0.8-rc.3
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/build/{esnext → cjs}/config.d.ts +0 -1
- package/build/{src → cjs}/config.js +0 -1
- package/build/{esnext → cjs}/index.d.ts +0 -1
- package/build/{src → cjs}/index.js +0 -1
- package/build/{esnext → cjs}/servers/server.builder.d.ts +0 -1
- package/build/{src → cjs}/servers/server.builder.js +10 -13
- package/build/{src → cjs}/servers/server.d.ts +0 -1
- package/build/{src → cjs}/servers/server.js +83 -75
- package/build/{src → cjs}/types/api-response.d.ts +0 -1
- package/build/{src → cjs}/types/api-response.js +0 -1
- package/build/{src → cjs}/types/index.d.ts +0 -1
- package/build/{src → cjs}/types/index.js +0 -1
- package/build/{src → cjs}/types/server.d.ts +0 -1
- package/build/{src → cjs}/types/server.js +0 -1
- package/build/{src → cjs}/utils/array.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/array.utils.js +0 -1
- package/build/{src → cjs}/utils/async.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/async.utils.js +2 -3
- package/build/{esnext → cjs}/utils/cache.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/cache.utils.js +7 -6
- package/build/{esnext → cjs}/utils/context-store.utils.d.ts +1 -2
- package/build/{src → cjs}/utils/context-store.utils.js +10 -9
- package/build/{esnext → cjs}/utils/crypto.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/crypto.utils.js +5 -3
- package/build/{src → cjs}/utils/date.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/date.utils.js +1 -2
- package/build/{src → cjs}/utils/decorators.utils.d.ts +30 -27
- package/build/{src → cjs}/utils/decorators.utils.js +169 -30
- package/build/{esnext → cjs}/utils/dir.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/dir.utils.js +6 -7
- package/build/{esnext → cjs}/utils/env.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/env.utils.js +5 -8
- package/build/{src → cjs}/utils/exception.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/exception.utils.js +2 -1
- package/build/{src → cjs}/utils/fs.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/fs.utils.js +12 -13
- package/build/{esnext → cjs}/utils/http-status-codes.d.ts +0 -1
- package/build/{src → cjs}/utils/http-status-codes.js +0 -1
- package/build/{esnext → cjs}/utils/id.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/id.utils.js +0 -1
- package/build/{src → cjs}/utils/logger.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/logger.utils.js +10 -6
- package/build/{esnext → cjs}/utils/middleware.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/middleware.utils.js +16 -17
- package/build/{esnext → cjs}/utils/obj.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/obj.utils.js +1 -2
- package/build/{src → cjs}/utils/performance.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/performance.utils.js +6 -4
- package/build/{esnext → cjs}/utils/request.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/request.utils.js +7 -3
- package/build/{esnext → cjs}/utils/response.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/response.utils.js +42 -28
- package/build/{esnext → cjs}/utils/stream.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/stream.utils.js +0 -1
- package/build/{esnext → cjs}/utils/string.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/string.utils.js +0 -1
- package/build/{src → cjs}/utils/type.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/type.utils.js +2 -3
- package/build/{src → cjs}/utils/url.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/url.utils.js +8 -9
- package/build/{src → cjs}/utils/validate.utils.d.ts +0 -1
- package/build/{src → cjs}/utils/validate.utils.js +2 -3
- package/build/esm/config.d.ts +0 -1
- package/build/esm/config.js +6 -7
- package/build/esm/index.d.ts +0 -1
- package/build/esm/index.js +0 -1
- package/build/esm/servers/server.builder.d.ts +0 -1
- package/build/esm/servers/server.builder.js +99 -147
- package/build/esm/servers/server.d.ts +0 -1
- package/build/esm/servers/server.js +591 -876
- package/build/esm/types/api-response.d.ts +0 -1
- package/build/esm/types/api-response.js +0 -1
- package/build/esm/types/index.d.ts +0 -1
- package/build/esm/types/index.js +0 -1
- package/build/esm/types/server.d.ts +0 -1
- package/build/esm/types/server.js +0 -1
- package/build/esm/utils/array.utils.d.ts +0 -1
- package/build/esm/utils/array.utils.js +48 -86
- package/build/esm/utils/async.utils.d.ts +0 -1
- package/build/esm/utils/async.utils.js +247 -524
- package/build/esm/utils/cache.utils.d.ts +0 -1
- package/build/esm/utils/cache.utils.js +96 -301
- package/build/esm/utils/context-store.utils.d.ts +1 -2
- package/build/esm/utils/context-store.utils.js +62 -79
- package/build/esm/utils/crypto.utils.d.ts +0 -1
- package/build/esm/utils/crypto.utils.js +78 -175
- package/build/esm/utils/date.utils.d.ts +0 -1
- package/build/esm/utils/date.utils.js +47 -53
- package/build/esm/utils/decorators.utils.d.ts +30 -27
- package/build/esm/utils/decorators.utils.js +417 -461
- package/build/esm/utils/dir.utils.d.ts +0 -1
- package/build/esm/utils/dir.utils.js +264 -786
- package/build/esm/utils/env.utils.d.ts +0 -1
- package/build/esm/utils/env.utils.js +180 -271
- package/build/esm/utils/exception.utils.d.ts +0 -1
- package/build/esm/utils/exception.utils.js +112 -289
- package/build/esm/utils/fs.utils.d.ts +0 -1
- package/build/esm/utils/fs.utils.js +169 -401
- package/build/esm/utils/http-status-codes.d.ts +0 -1
- package/build/esm/utils/http-status-codes.js +0 -1
- package/build/esm/utils/id.utils.d.ts +0 -1
- package/build/esm/utils/id.utils.js +5 -9
- package/build/esm/utils/logger.utils.d.ts +0 -1
- package/build/esm/utils/logger.utils.js +34 -71
- package/build/esm/utils/middleware.utils.d.ts +0 -1
- package/build/esm/utils/middleware.utils.js +65 -155
- package/build/esm/utils/obj.utils.d.ts +0 -1
- package/build/esm/utils/obj.utils.js +69 -176
- package/build/esm/utils/performance.utils.d.ts +0 -1
- package/build/esm/utils/performance.utils.js +92 -195
- package/build/esm/utils/request.utils.d.ts +0 -1
- package/build/esm/utils/request.utils.js +41 -74
- package/build/esm/utils/response.utils.d.ts +0 -1
- package/build/esm/utils/response.utils.js +84 -107
- package/build/esm/utils/stream.utils.d.ts +0 -1
- package/build/esm/utils/stream.utils.js +38 -113
- package/build/esm/utils/string.utils.d.ts +0 -1
- package/build/esm/utils/string.utils.js +6 -11
- package/build/esm/utils/type.utils.d.ts +0 -1
- package/build/esm/utils/type.utils.js +8 -12
- package/build/esm/utils/url.utils.d.ts +0 -1
- package/build/esm/utils/url.utils.js +49 -127
- package/build/esm/utils/validate.utils.d.ts +0 -1
- package/build/esm/utils/validate.utils.js +23 -40
- package/package.json +288 -63
- package/build/esm/config.js.map +0 -1
- package/build/esm/index.js.map +0 -1
- package/build/esm/servers/server.builder.js.map +0 -1
- package/build/esm/servers/server.js.map +0 -1
- package/build/esm/types/api-response.js.map +0 -1
- package/build/esm/types/index.js.map +0 -1
- package/build/esm/types/server.js.map +0 -1
- package/build/esm/utils/array.utils.js.map +0 -1
- package/build/esm/utils/async.utils.js.map +0 -1
- package/build/esm/utils/cache.utils.js.map +0 -1
- package/build/esm/utils/context-store.utils.js.map +0 -1
- package/build/esm/utils/crypto.utils.js.map +0 -1
- package/build/esm/utils/date.utils.js.map +0 -1
- package/build/esm/utils/decorators.utils.js.map +0 -1
- package/build/esm/utils/dir.utils.js.map +0 -1
- package/build/esm/utils/env.utils.js.map +0 -1
- package/build/esm/utils/exception.utils.js.map +0 -1
- package/build/esm/utils/fs.utils.js.map +0 -1
- package/build/esm/utils/http-status-codes.js.map +0 -1
- package/build/esm/utils/id.utils.js.map +0 -1
- package/build/esm/utils/logger.utils.js.map +0 -1
- package/build/esm/utils/middleware.utils.js.map +0 -1
- package/build/esm/utils/obj.utils.js.map +0 -1
- package/build/esm/utils/performance.utils.js.map +0 -1
- package/build/esm/utils/request.utils.js.map +0 -1
- package/build/esm/utils/response.utils.js.map +0 -1
- package/build/esm/utils/stream.utils.js.map +0 -1
- package/build/esm/utils/string.utils.js.map +0 -1
- package/build/esm/utils/type.utils.js.map +0 -1
- package/build/esm/utils/url.utils.js.map +0 -1
- package/build/esm/utils/validate.utils.js.map +0 -1
- package/build/esnext/config.js +0 -133
- package/build/esnext/config.js.map +0 -1
- package/build/esnext/index.js +0 -50
- package/build/esnext/index.js.map +0 -1
- package/build/esnext/servers/server.builder.js +0 -657
- package/build/esnext/servers/server.builder.js.map +0 -1
- package/build/esnext/servers/server.d.ts +0 -256
- package/build/esnext/servers/server.js +0 -955
- package/build/esnext/servers/server.js.map +0 -1
- package/build/esnext/types/api-response.d.ts +0 -152
- package/build/esnext/types/api-response.js +0 -34
- package/build/esnext/types/api-response.js.map +0 -1
- package/build/esnext/types/index.d.ts +0 -125
- package/build/esnext/types/index.js +0 -25
- package/build/esnext/types/index.js.map +0 -1
- package/build/esnext/types/server.d.ts +0 -268
- package/build/esnext/types/server.js +0 -25
- package/build/esnext/types/server.js.map +0 -1
- package/build/esnext/utils/array.utils.d.ts +0 -168
- package/build/esnext/utils/array.utils.js +0 -345
- package/build/esnext/utils/array.utils.js.map +0 -1
- package/build/esnext/utils/async.utils.d.ts +0 -265
- package/build/esnext/utils/async.utils.js +0 -620
- package/build/esnext/utils/async.utils.js.map +0 -1
- package/build/esnext/utils/cache.utils.js +0 -293
- package/build/esnext/utils/cache.utils.js.map +0 -1
- package/build/esnext/utils/context-store.utils.js +0 -289
- package/build/esnext/utils/context-store.utils.js.map +0 -1
- package/build/esnext/utils/crypto.utils.js +0 -276
- package/build/esnext/utils/crypto.utils.js.map +0 -1
- package/build/esnext/utils/date.utils.d.ts +0 -159
- package/build/esnext/utils/date.utils.js +0 -384
- package/build/esnext/utils/date.utils.js.map +0 -1
- package/build/esnext/utils/decorators.utils.d.ts +0 -508
- package/build/esnext/utils/decorators.utils.js +0 -877
- package/build/esnext/utils/decorators.utils.js.map +0 -1
- package/build/esnext/utils/dir.utils.js +0 -477
- package/build/esnext/utils/dir.utils.js.map +0 -1
- package/build/esnext/utils/env.utils.js +0 -785
- package/build/esnext/utils/env.utils.js.map +0 -1
- package/build/esnext/utils/exception.utils.d.ts +0 -230
- package/build/esnext/utils/exception.utils.js +0 -381
- package/build/esnext/utils/exception.utils.js.map +0 -1
- package/build/esnext/utils/fs.utils.d.ts +0 -164
- package/build/esnext/utils/fs.utils.js +0 -349
- package/build/esnext/utils/fs.utils.js.map +0 -1
- package/build/esnext/utils/http-status-codes.js +0 -295
- package/build/esnext/utils/http-status-codes.js.map +0 -1
- package/build/esnext/utils/id.utils.js +0 -84
- package/build/esnext/utils/id.utils.js.map +0 -1
- package/build/esnext/utils/logger.utils.d.ts +0 -160
- package/build/esnext/utils/logger.utils.js +0 -300
- package/build/esnext/utils/logger.utils.js.map +0 -1
- package/build/esnext/utils/middleware.utils.js +0 -236
- package/build/esnext/utils/middleware.utils.js.map +0 -1
- package/build/esnext/utils/obj.utils.js +0 -413
- package/build/esnext/utils/obj.utils.js.map +0 -1
- package/build/esnext/utils/performance.utils.d.ts +0 -136
- package/build/esnext/utils/performance.utils.js +0 -271
- package/build/esnext/utils/performance.utils.js.map +0 -1
- package/build/esnext/utils/request.utils.js +0 -186
- package/build/esnext/utils/request.utils.js.map +0 -1
- package/build/esnext/utils/response.utils.js +0 -247
- package/build/esnext/utils/response.utils.js.map +0 -1
- package/build/esnext/utils/stream.utils.js +0 -210
- package/build/esnext/utils/stream.utils.js.map +0 -1
- package/build/esnext/utils/string.utils.js +0 -165
- package/build/esnext/utils/string.utils.js.map +0 -1
- package/build/esnext/utils/type.utils.d.ts +0 -90
- package/build/esnext/utils/type.utils.js +0 -187
- package/build/esnext/utils/type.utils.js.map +0 -1
- package/build/esnext/utils/url.utils.d.ts +0 -141
- package/build/esnext/utils/url.utils.js +0 -304
- package/build/esnext/utils/url.utils.js.map +0 -1
- package/build/esnext/utils/validate.utils.d.ts +0 -177
- package/build/esnext/utils/validate.utils.js +0 -320
- package/build/esnext/utils/validate.utils.js.map +0 -1
- package/build/src/config.d.ts +0 -122
- package/build/src/config.js.map +0 -1
- package/build/src/index.d.ts +0 -27
- package/build/src/index.js.map +0 -1
- package/build/src/servers/server.builder.d.ts +0 -508
- package/build/src/servers/server.builder.js.map +0 -1
- package/build/src/servers/server.js.map +0 -1
- package/build/src/types/api-response.js.map +0 -1
- package/build/src/types/index.js.map +0 -1
- package/build/src/types/server.js.map +0 -1
- package/build/src/utils/array.utils.js.map +0 -1
- package/build/src/utils/async.utils.js.map +0 -1
- package/build/src/utils/cache.utils.d.ts +0 -153
- package/build/src/utils/cache.utils.js.map +0 -1
- package/build/src/utils/context-store.utils.d.ts +0 -189
- package/build/src/utils/context-store.utils.js.map +0 -1
- package/build/src/utils/crypto.utils.d.ts +0 -160
- package/build/src/utils/crypto.utils.js.map +0 -1
- package/build/src/utils/date.utils.js.map +0 -1
- package/build/src/utils/decorators.utils.js.map +0 -1
- package/build/src/utils/dir.utils.d.ts +0 -196
- package/build/src/utils/dir.utils.js.map +0 -1
- package/build/src/utils/env.utils.d.ts +0 -377
- package/build/src/utils/env.utils.js.map +0 -1
- package/build/src/utils/exception.utils.js.map +0 -1
- package/build/src/utils/fs.utils.js.map +0 -1
- package/build/src/utils/http-status-codes.d.ts +0 -266
- package/build/src/utils/http-status-codes.js.map +0 -1
- package/build/src/utils/id.utils.d.ts +0 -36
- package/build/src/utils/id.utils.js.map +0 -1
- package/build/src/utils/logger.utils.js.map +0 -1
- package/build/src/utils/middleware.utils.d.ts +0 -100
- package/build/src/utils/middleware.utils.js.map +0 -1
- package/build/src/utils/obj.utils.d.ts +0 -124
- package/build/src/utils/obj.utils.js.map +0 -1
- package/build/src/utils/performance.utils.js.map +0 -1
- package/build/src/utils/request.utils.d.ts +0 -86
- package/build/src/utils/request.utils.js.map +0 -1
- package/build/src/utils/response.utils.d.ts +0 -163
- package/build/src/utils/response.utils.js.map +0 -1
- package/build/src/utils/stream.utils.d.ts +0 -88
- package/build/src/utils/stream.utils.js.map +0 -1
- package/build/src/utils/string.utils.d.ts +0 -93
- package/build/src/utils/string.utils.js.map +0 -1
- package/build/src/utils/type.utils.js.map +0 -1
- package/build/src/utils/url.utils.js.map +0 -1
- package/build/src/utils/validate.utils.js.map +0 -1
|
@@ -21,42 +21,6 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
25
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
26
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
27
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
28
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
29
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
30
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
34
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
35
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
36
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
37
|
-
function step(op) {
|
|
38
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
39
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
40
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
41
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
42
|
-
switch (op[0]) {
|
|
43
|
-
case 0: case 1: t = op; break;
|
|
44
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
45
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
46
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
47
|
-
default:
|
|
48
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
49
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
50
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
51
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
52
|
-
if (t[2]) _.ops.pop();
|
|
53
|
-
_.trys.pop(); continue;
|
|
54
|
-
}
|
|
55
|
-
op = body.call(thisArg, _);
|
|
56
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
57
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
24
|
import fs from 'fs/promises';
|
|
61
25
|
import { createReadStream, createWriteStream } from 'fs';
|
|
62
26
|
import { tmpdir } from 'os';
|
|
@@ -69,24 +33,14 @@ import { randomUUID } from 'crypto';
|
|
|
69
33
|
* @param {string} path - The file or directory path to check.
|
|
70
34
|
* @returns {Promise<boolean>} Resolves to `true` if the path exists, `false` otherwise.
|
|
71
35
|
*/
|
|
72
|
-
export function fileExists(path) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
case 1:
|
|
81
|
-
_b.sent();
|
|
82
|
-
return [2 /*return*/, true];
|
|
83
|
-
case 2:
|
|
84
|
-
_a = _b.sent();
|
|
85
|
-
return [2 /*return*/, false];
|
|
86
|
-
case 3: return [2 /*return*/];
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
});
|
|
36
|
+
export async function fileExists(path) {
|
|
37
|
+
try {
|
|
38
|
+
await fs.access(path);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
90
44
|
}
|
|
91
45
|
/**
|
|
92
46
|
* Reads and parses a JSON file from the specified path.
|
|
@@ -95,24 +49,14 @@ export function fileExists(path) {
|
|
|
95
49
|
* @param {string} path - The path to the JSON file.
|
|
96
50
|
* @returns {Promise<T | null>} The parsed object, or `null` if reading or parsing fails.
|
|
97
51
|
*/
|
|
98
|
-
export function readJsonFile(path) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
case 1:
|
|
107
|
-
data = _b.sent();
|
|
108
|
-
return [2 /*return*/, JSON.parse(data)];
|
|
109
|
-
case 2:
|
|
110
|
-
_a = _b.sent();
|
|
111
|
-
return [2 /*return*/, null];
|
|
112
|
-
case 3: return [2 /*return*/];
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
52
|
+
export async function readJsonFile(path) {
|
|
53
|
+
try {
|
|
54
|
+
const data = await fs.readFile(path, 'utf-8');
|
|
55
|
+
return JSON.parse(data);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
116
60
|
}
|
|
117
61
|
/**
|
|
118
62
|
* Writes a JavaScript object to a file as formatted JSON.
|
|
@@ -122,21 +66,9 @@ export function readJsonFile(path) {
|
|
|
122
66
|
* @param {number} [space=2] - Number of spaces for JSON formatting.
|
|
123
67
|
* @returns {Promise<void>} Resolves when writing is complete.
|
|
124
68
|
*/
|
|
125
|
-
export function writeJsonFile(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (space === void 0) { space = 2; }
|
|
129
|
-
return __generator(this, function (_a) {
|
|
130
|
-
switch (_a.label) {
|
|
131
|
-
case 0:
|
|
132
|
-
json = JSON.stringify(data, null, space);
|
|
133
|
-
return [4 /*yield*/, fs.writeFile(path, json, 'utf-8')];
|
|
134
|
-
case 1:
|
|
135
|
-
_a.sent();
|
|
136
|
-
return [2 /*return*/];
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
});
|
|
69
|
+
export async function writeJsonFile(path, data, space = 2) {
|
|
70
|
+
const json = JSON.stringify(data, null, space);
|
|
71
|
+
await fs.writeFile(path, json, 'utf-8');
|
|
140
72
|
}
|
|
141
73
|
/**
|
|
142
74
|
* Deletes a file if it exists.
|
|
@@ -144,26 +76,16 @@ export function writeJsonFile(path_1, data_1) {
|
|
|
144
76
|
* @param {string} path - The file path to delete.
|
|
145
77
|
* @returns {Promise<boolean>} Resolves to `true` if the file was deleted or didn't exist, `false` if deletion failed.
|
|
146
78
|
*/
|
|
147
|
-
export function deleteFileIfExists(path) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return [2 /*return*/, true];
|
|
158
|
-
case 2:
|
|
159
|
-
err_1 = _a.sent();
|
|
160
|
-
if (err_1.code === 'ENOENT')
|
|
161
|
-
return [2 /*return*/, true];
|
|
162
|
-
return [2 /*return*/, false];
|
|
163
|
-
case 3: return [2 /*return*/];
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
});
|
|
79
|
+
export async function deleteFileIfExists(path) {
|
|
80
|
+
try {
|
|
81
|
+
await fs.unlink(path);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
if (err.code === 'ENOENT')
|
|
86
|
+
return true;
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
167
89
|
}
|
|
168
90
|
/**
|
|
169
91
|
* Reads a text file from the specified path.
|
|
@@ -172,23 +94,13 @@ export function deleteFileIfExists(path) {
|
|
|
172
94
|
* @param {BufferEncoding} [encoding="utf-8"] - The encoding to use.
|
|
173
95
|
* @returns {Promise<string | null>} The file contents, or `null` if reading fails.
|
|
174
96
|
*/
|
|
175
|
-
export function readTextFile(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
_b.trys.push([0, 2, , 3]);
|
|
183
|
-
return [4 /*yield*/, fs.readFile(path, encoding)];
|
|
184
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
185
|
-
case 2:
|
|
186
|
-
_a = _b.sent();
|
|
187
|
-
return [2 /*return*/, null];
|
|
188
|
-
case 3: return [2 /*return*/];
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
});
|
|
97
|
+
export async function readTextFile(path, encoding = 'utf-8') {
|
|
98
|
+
try {
|
|
99
|
+
return await fs.readFile(path, encoding);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
192
104
|
}
|
|
193
105
|
/**
|
|
194
106
|
* Writes text content to a file.
|
|
@@ -198,25 +110,14 @@ export function readTextFile(path_1) {
|
|
|
198
110
|
* @param {BufferEncoding} [encoding="utf-8"] - The encoding to use.
|
|
199
111
|
* @returns {Promise<boolean>} Resolves to `true` if successful, `false` otherwise.
|
|
200
112
|
*/
|
|
201
|
-
export function writeTextFile(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return [4 /*yield*/, fs.writeFile(path, content, encoding)];
|
|
210
|
-
case 1:
|
|
211
|
-
_b.sent();
|
|
212
|
-
return [2 /*return*/, true];
|
|
213
|
-
case 2:
|
|
214
|
-
_a = _b.sent();
|
|
215
|
-
return [2 /*return*/, false];
|
|
216
|
-
case 3: return [2 /*return*/];
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
});
|
|
113
|
+
export async function writeTextFile(path, content, encoding = 'utf-8') {
|
|
114
|
+
try {
|
|
115
|
+
await fs.writeFile(path, content, encoding);
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
220
121
|
}
|
|
221
122
|
/**
|
|
222
123
|
* Appends text content to a file.
|
|
@@ -226,25 +127,14 @@ export function writeTextFile(path_1, content_1) {
|
|
|
226
127
|
* @param {BufferEncoding} [encoding="utf-8"] - The encoding to use.
|
|
227
128
|
* @returns {Promise<boolean>} Resolves to `true` if successful, `false` otherwise.
|
|
228
129
|
*/
|
|
229
|
-
export function appendTextFile(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
return [4 /*yield*/, fs.appendFile(path, content, encoding)];
|
|
238
|
-
case 1:
|
|
239
|
-
_b.sent();
|
|
240
|
-
return [2 /*return*/, true];
|
|
241
|
-
case 2:
|
|
242
|
-
_a = _b.sent();
|
|
243
|
-
return [2 /*return*/, false];
|
|
244
|
-
case 3: return [2 /*return*/];
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
});
|
|
130
|
+
export async function appendTextFile(path, content, encoding = 'utf-8') {
|
|
131
|
+
try {
|
|
132
|
+
await fs.appendFile(path, content, encoding);
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
248
138
|
}
|
|
249
139
|
/**
|
|
250
140
|
* Copies a file from source to destination.
|
|
@@ -254,26 +144,15 @@ export function appendTextFile(path_1, content_1) {
|
|
|
254
144
|
* @param {boolean} [overwrite=false] - Whether to overwrite if destination exists.
|
|
255
145
|
* @returns {Promise<boolean>} Resolves to `true` if successful, `false` otherwise.
|
|
256
146
|
*/
|
|
257
|
-
export function copyFile(
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
return
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
return [4 /*yield*/, fs.copyFile(source, destination, flags)];
|
|
267
|
-
case 1:
|
|
268
|
-
_b.sent();
|
|
269
|
-
return [2 /*return*/, true];
|
|
270
|
-
case 2:
|
|
271
|
-
_a = _b.sent();
|
|
272
|
-
return [2 /*return*/, false];
|
|
273
|
-
case 3: return [2 /*return*/];
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
});
|
|
147
|
+
export async function copyFile(source, destination, overwrite = false) {
|
|
148
|
+
try {
|
|
149
|
+
const flags = overwrite ? 0 : fs.constants.COPYFILE_EXCL;
|
|
150
|
+
await fs.copyFile(source, destination, flags);
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
277
156
|
}
|
|
278
157
|
/**
|
|
279
158
|
* Renames/moves a file.
|
|
@@ -282,37 +161,22 @@ export function copyFile(source_1, destination_1) {
|
|
|
282
161
|
* @param {string} newPath - New file path.
|
|
283
162
|
* @returns {Promise<boolean>} Resolves to `true` if successful, `false` otherwise.
|
|
284
163
|
*/
|
|
285
|
-
export function moveFile(oldPath, newPath) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
return
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
return [4 /*yield*/, fs.copyFile(oldPath, newPath)];
|
|
302
|
-
case 4:
|
|
303
|
-
_c.sent();
|
|
304
|
-
return [4 /*yield*/, fs.unlink(oldPath)];
|
|
305
|
-
case 5:
|
|
306
|
-
_c.sent();
|
|
307
|
-
return [2 /*return*/, true];
|
|
308
|
-
case 6:
|
|
309
|
-
_b = _c.sent();
|
|
310
|
-
return [2 /*return*/, false];
|
|
311
|
-
case 7: return [3 /*break*/, 8];
|
|
312
|
-
case 8: return [2 /*return*/];
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
});
|
|
164
|
+
export async function moveFile(oldPath, newPath) {
|
|
165
|
+
try {
|
|
166
|
+
await fs.rename(oldPath, newPath);
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
// If rename fails (e.g., across devices), try copy+delete
|
|
171
|
+
try {
|
|
172
|
+
await fs.copyFile(oldPath, newPath);
|
|
173
|
+
await fs.unlink(oldPath);
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
316
180
|
}
|
|
317
181
|
/**
|
|
318
182
|
* Gets file stats if the file exists.
|
|
@@ -320,22 +184,13 @@ export function moveFile(oldPath, newPath) {
|
|
|
320
184
|
* @param {string} path - Path to the file.
|
|
321
185
|
* @returns {Promise<fs.Stats | null>} File stats object or null if file doesn't exist.
|
|
322
186
|
*/
|
|
323
|
-
export function getFileStats(path) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
return [4 /*yield*/, fs.stat(path)];
|
|
331
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
332
|
-
case 2:
|
|
333
|
-
_a = _b.sent();
|
|
334
|
-
return [2 /*return*/, null];
|
|
335
|
-
case 3: return [2 /*return*/];
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
});
|
|
187
|
+
export async function getFileStats(path) {
|
|
188
|
+
try {
|
|
189
|
+
return await fs.stat(path);
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
339
194
|
}
|
|
340
195
|
/**
|
|
341
196
|
* Creates a temporary file with optional content.
|
|
@@ -347,29 +202,17 @@ export function getFileStats(path) {
|
|
|
347
202
|
* @param {string | Buffer} [options.content] - Optional content to write to the file.
|
|
348
203
|
* @returns {Promise<string>} Path to the created temporary file.
|
|
349
204
|
*/
|
|
350
|
-
export function createTempFile() {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
return [4 /*yield*/, fs.writeFile(filepath, content)];
|
|
362
|
-
case 1:
|
|
363
|
-
_f.sent();
|
|
364
|
-
return [3 /*break*/, 4];
|
|
365
|
-
case 2: return [4 /*yield*/, fs.writeFile(filepath, '')];
|
|
366
|
-
case 3:
|
|
367
|
-
_f.sent();
|
|
368
|
-
_f.label = 4;
|
|
369
|
-
case 4: return [2 /*return*/, filepath];
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
});
|
|
205
|
+
export async function createTempFile({ prefix = 'tmp-', extension = '', dir = tmpdir(), content } = {}) {
|
|
206
|
+
const ext = extension ? (extension.startsWith('.') ? extension : `.${extension}`) : '';
|
|
207
|
+
const filename = `${prefix}${randomUUID()}${ext}`;
|
|
208
|
+
const filepath = path.join(dir, filename);
|
|
209
|
+
if (content) {
|
|
210
|
+
await fs.writeFile(filepath, content);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
await fs.writeFile(filepath, '');
|
|
214
|
+
}
|
|
215
|
+
return filepath;
|
|
373
216
|
}
|
|
374
217
|
/**
|
|
375
218
|
* Streams a file from source to destination.
|
|
@@ -380,31 +223,18 @@ export function createTempFile() {
|
|
|
380
223
|
* @returns {Promise<void>} Resolves when streaming completes.
|
|
381
224
|
* @throws {Error} If streaming fails.
|
|
382
225
|
*/
|
|
383
|
-
export function streamFile(source, destination) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
case 2:
|
|
396
|
-
_a.sent();
|
|
397
|
-
return [3 /*break*/, 4];
|
|
398
|
-
case 3:
|
|
399
|
-
error_1 = _a.sent();
|
|
400
|
-
// Ensure both streams are closed in case of error
|
|
401
|
-
readStream.destroy();
|
|
402
|
-
writeStream.destroy();
|
|
403
|
-
throw error_1;
|
|
404
|
-
case 4: return [2 /*return*/];
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
});
|
|
226
|
+
export async function streamFile(source, destination) {
|
|
227
|
+
const readStream = createReadStream(source);
|
|
228
|
+
const writeStream = createWriteStream(destination);
|
|
229
|
+
try {
|
|
230
|
+
await pipeline(readStream, writeStream);
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
// Ensure both streams are closed in case of error
|
|
234
|
+
readStream.destroy();
|
|
235
|
+
writeStream.destroy();
|
|
236
|
+
throw error;
|
|
237
|
+
}
|
|
408
238
|
}
|
|
409
239
|
/**
|
|
410
240
|
* Reads a directory and returns file names.
|
|
@@ -416,26 +246,16 @@ export function streamFile(source, destination) {
|
|
|
416
246
|
* @returns {Promise<string[]>} Array of file names or paths.
|
|
417
247
|
* @throws {Error} If directory cannot be read.
|
|
418
248
|
*/
|
|
419
|
-
export function readDirectory(
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
if (options.filter) {
|
|
430
|
-
result = result.filter(function (file) { return options.filter.test(file); });
|
|
431
|
-
}
|
|
432
|
-
if (options.fullPaths) {
|
|
433
|
-
result = result.map(function (file) { return path.join(dirPath, file); });
|
|
434
|
-
}
|
|
435
|
-
return [2 /*return*/, result];
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
});
|
|
249
|
+
export async function readDirectory(dirPath, options = {}) {
|
|
250
|
+
const files = await fs.readdir(dirPath);
|
|
251
|
+
let result = files;
|
|
252
|
+
if (options.filter) {
|
|
253
|
+
result = result.filter(file => options.filter.test(file));
|
|
254
|
+
}
|
|
255
|
+
if (options.fullPaths) {
|
|
256
|
+
result = result.map(file => path.join(dirPath, file));
|
|
257
|
+
}
|
|
258
|
+
return result;
|
|
439
259
|
}
|
|
440
260
|
/**
|
|
441
261
|
* Creates a directory if it doesn't exist.
|
|
@@ -444,26 +264,15 @@ export function readDirectory(dirPath_1) {
|
|
|
444
264
|
* @param {boolean} [recursive=true] - Whether to create parent directories.
|
|
445
265
|
* @returns {Promise<boolean>} Resolves to `true` if successful, `false` otherwise.
|
|
446
266
|
*/
|
|
447
|
-
export function createDirectory(
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
case 1:
|
|
457
|
-
_a.sent();
|
|
458
|
-
return [2 /*return*/, true];
|
|
459
|
-
case 2:
|
|
460
|
-
err_2 = _a.sent();
|
|
461
|
-
// Consider it success if directory already exists
|
|
462
|
-
return [2 /*return*/, err_2.code === 'EEXIST'];
|
|
463
|
-
case 3: return [2 /*return*/];
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
});
|
|
267
|
+
export async function createDirectory(dirPath, recursive = true) {
|
|
268
|
+
try {
|
|
269
|
+
await fs.mkdir(dirPath, { recursive });
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
catch (err) {
|
|
273
|
+
// Consider it success if directory already exists
|
|
274
|
+
return err.code === 'EEXIST';
|
|
275
|
+
}
|
|
467
276
|
}
|
|
468
277
|
/**
|
|
469
278
|
* Safely reads and parses a JSON file with error details.
|
|
@@ -472,37 +281,26 @@ export function createDirectory(dirPath_1) {
|
|
|
472
281
|
* @param {string} path - The path to the JSON file.
|
|
473
282
|
* @returns {Promise<{ data: T | null; error: Error | null }>} Object with data and error properties.
|
|
474
283
|
*/
|
|
475
|
-
export function safeReadJsonFile(path) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
return [3 /*break*/, 3];
|
|
496
|
-
case 2:
|
|
497
|
-
error_2 = _a.sent();
|
|
498
|
-
return [2 /*return*/, {
|
|
499
|
-
data: null,
|
|
500
|
-
error: new Error("Failed to read file ".concat(path, ": ").concat(error_2.message))
|
|
501
|
-
}];
|
|
502
|
-
case 3: return [2 /*return*/];
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
});
|
|
284
|
+
export async function safeReadJsonFile(path) {
|
|
285
|
+
try {
|
|
286
|
+
const content = await fs.readFile(path, 'utf-8');
|
|
287
|
+
try {
|
|
288
|
+
const data = JSON.parse(content);
|
|
289
|
+
return { data, error: null };
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
return {
|
|
293
|
+
data: null,
|
|
294
|
+
error: new Error(`Invalid JSON in file ${path}: ${error.message}`)
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
return {
|
|
300
|
+
data: null,
|
|
301
|
+
error: new Error(`Failed to read file ${path}: ${error.message}`)
|
|
302
|
+
};
|
|
303
|
+
}
|
|
506
304
|
}
|
|
507
305
|
/**
|
|
508
306
|
* Checks if a path points to a file (not a directory).
|
|
@@ -510,24 +308,14 @@ export function safeReadJsonFile(path) {
|
|
|
510
308
|
* @param {string} path - Path to check.
|
|
511
309
|
* @returns {Promise<boolean>} True if the path is a file, false otherwise.
|
|
512
310
|
*/
|
|
513
|
-
export function isFile(path) {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
return
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
case 1:
|
|
522
|
-
stat = _b.sent();
|
|
523
|
-
return [2 /*return*/, stat.isFile()];
|
|
524
|
-
case 2:
|
|
525
|
-
_a = _b.sent();
|
|
526
|
-
return [2 /*return*/, false];
|
|
527
|
-
case 3: return [2 /*return*/];
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
});
|
|
311
|
+
export async function isFile(path) {
|
|
312
|
+
try {
|
|
313
|
+
const stat = await fs.stat(path);
|
|
314
|
+
return stat.isFile();
|
|
315
|
+
}
|
|
316
|
+
catch {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
531
319
|
}
|
|
532
320
|
/**
|
|
533
321
|
* Gets the size of a file in bytes.
|
|
@@ -535,24 +323,14 @@ export function isFile(path) {
|
|
|
535
323
|
* @param {string} path - Path to the file.
|
|
536
324
|
* @returns {Promise<number>} Size in bytes or -1 if file doesn't exist.
|
|
537
325
|
*/
|
|
538
|
-
export function getFileSize(path) {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
return
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
case 1:
|
|
547
|
-
stat = _b.sent();
|
|
548
|
-
return [2 /*return*/, stat.size];
|
|
549
|
-
case 2:
|
|
550
|
-
_a = _b.sent();
|
|
551
|
-
return [2 /*return*/, -1];
|
|
552
|
-
case 3: return [2 /*return*/];
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
});
|
|
326
|
+
export async function getFileSize(path) {
|
|
327
|
+
try {
|
|
328
|
+
const stat = await fs.stat(path);
|
|
329
|
+
return stat.size;
|
|
330
|
+
}
|
|
331
|
+
catch {
|
|
332
|
+
return -1;
|
|
333
|
+
}
|
|
556
334
|
}
|
|
557
335
|
/**
|
|
558
336
|
* Reads a file as a Buffer.
|
|
@@ -560,21 +338,11 @@ export function getFileSize(path) {
|
|
|
560
338
|
* @param {string} path - Path to the file.
|
|
561
339
|
* @returns {Promise<Buffer | null>} File contents as Buffer or null if reading fails.
|
|
562
340
|
*/
|
|
563
|
-
export function readFileBuffer(path) {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
return [4 /*yield*/, fs.readFile(path)];
|
|
571
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
572
|
-
case 2:
|
|
573
|
-
_a = _b.sent();
|
|
574
|
-
return [2 /*return*/, null];
|
|
575
|
-
case 3: return [2 /*return*/];
|
|
576
|
-
}
|
|
577
|
-
});
|
|
578
|
-
});
|
|
341
|
+
export async function readFileBuffer(path) {
|
|
342
|
+
try {
|
|
343
|
+
return await fs.readFile(path);
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
579
348
|
}
|
|
580
|
-
//# sourceMappingURL=fs.utils.js.map
|