@fncts/node 0.0.44 → 0.0.46
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/LICENSE +26 -0
- package/_cjs/fs/api.cjs +286 -276
- package/_cjs/fs/api.cjs.map +1 -1
- package/_cjs/fs.cjs +46 -17
- package/_cjs/global.cjs +0 -2
- package/_cjs/http/IncomingMessage.cjs +59 -60
- package/_cjs/http/IncomingMessage.cjs.map +1 -1
- package/_cjs/http/Server.cjs +179 -195
- package/_cjs/http/Server.cjs.map +1 -1
- package/_cjs/http/ServerRequest.cjs +40 -43
- package/_cjs/http/ServerRequest.cjs.map +1 -1
- package/_cjs/index.cjs +0 -2
- package/_cjs/rolldown-runtime.cjs +27 -0
- package/_cjs/stream/api.cjs +214 -238
- package/_cjs/stream/api.cjs.map +1 -1
- package/_cjs/stream.cjs +10 -17
- package/_mjs/fs/api.mjs +295 -302
- package/_mjs/fs/api.mjs.map +1 -1
- package/_mjs/fs.mjs +1 -3
- package/_mjs/global.mjs +0 -2
- package/_mjs/http/IncomingMessage.mjs +48 -50
- package/_mjs/http/IncomingMessage.mjs.map +1 -1
- package/_mjs/http/Server.mjs +138 -169
- package/_mjs/http/Server.mjs.map +1 -1
- package/_mjs/http/ServerRequest.mjs +34 -32
- package/_mjs/http/ServerRequest.mjs.map +1 -1
- package/_mjs/index.mjs +0 -2
- package/_mjs/stream/api.mjs +163 -205
- package/_mjs/stream/api.mjs.map +1 -1
- package/_mjs/stream.mjs +1 -3
- package/_src/fs/api.ts +6 -7
- package/package.json +7 -3
- package/_cjs/fs.cjs.map +0 -1
- package/_cjs/global.cjs.map +0 -1
- package/_cjs/index.cjs.map +0 -1
- package/_cjs/stream.cjs.map +0 -1
- package/_mjs/fs.mjs.map +0 -1
- package/_mjs/global.mjs.map +0 -1
- package/_mjs/index.mjs.map +0 -1
- package/_mjs/stream.mjs.map +0 -1
package/_cjs/fs/api.cjs
CHANGED
|
@@ -1,363 +1,373 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
exports.writev = writev;
|
|
49
|
-
var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/Newtype"));
|
|
50
|
-
var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/IO/api"));
|
|
51
|
-
var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/collection/immutable/Conc/constructors"));
|
|
52
|
-
var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/Ref/api/set"));
|
|
53
|
-
var tsplus_module_5 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/Maybe/constructors"));
|
|
54
|
-
var tsplus_module_6 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/Ref/api/get"));
|
|
55
|
-
var tsplus_module_7 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/Stream/api"));
|
|
56
|
-
var tsplus_module_8 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/Ref/constructors"));
|
|
57
|
-
var tsplus_module_9 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/Sink/definition"));
|
|
58
|
-
var tsplus_module_10 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/Maybe/definition"));
|
|
59
|
-
var tsplus_module_11 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/Channel/api"));
|
|
60
|
-
var tsplus_module_12 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/Channel/core-api"));
|
|
61
|
-
var tsplus_module_13 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/Cause/api"));
|
|
62
|
-
var tsplus_module_14 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/Ref/api/modify"));
|
|
63
|
-
var tsplus_module_15 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/IO/api/acquireRelease"));
|
|
64
|
-
var tsplus_module_16 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/Either/constructors"));
|
|
65
|
-
var tsplus_module_17 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/IO/api/asyncInterrupt"));
|
|
66
|
-
var tsplus_module_18 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/collection/immutable/Conc/api"));
|
|
67
|
-
var tsplus_module_19 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/Queue/api/operations"));
|
|
68
|
-
var tsplus_module_20 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/IO/runtime"));
|
|
69
|
-
var tsplus_module_21 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/Queue/constructors"));
|
|
70
|
-
var fs = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("fs"));
|
|
71
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("../rolldown-runtime.cjs");
|
|
3
|
+
let _fncts_io_Queue_constructors = require("@fncts/io/Queue/constructors");
|
|
4
|
+
_fncts_io_Queue_constructors = require_rolldown_runtime.__toESM(_fncts_io_Queue_constructors, 1);
|
|
5
|
+
let _fncts_io_IO_api = require("@fncts/io/IO/api");
|
|
6
|
+
_fncts_io_IO_api = require_rolldown_runtime.__toESM(_fncts_io_IO_api, 1);
|
|
7
|
+
let _fncts_io_Queue_api_operations = require("@fncts/io/Queue/api/operations");
|
|
8
|
+
_fncts_io_Queue_api_operations = require_rolldown_runtime.__toESM(_fncts_io_Queue_api_operations, 1);
|
|
9
|
+
let _fncts_io_Channel_api = require("@fncts/io/Channel/api");
|
|
10
|
+
_fncts_io_Channel_api = require_rolldown_runtime.__toESM(_fncts_io_Channel_api, 1);
|
|
11
|
+
let _fncts_base_data_Maybe_definition = require("@fncts/base/data/Maybe/definition");
|
|
12
|
+
_fncts_base_data_Maybe_definition = require_rolldown_runtime.__toESM(_fncts_base_data_Maybe_definition, 1);
|
|
13
|
+
let _fncts_base_data_Either_constructors = require("@fncts/base/data/Either/constructors");
|
|
14
|
+
_fncts_base_data_Either_constructors = require_rolldown_runtime.__toESM(_fncts_base_data_Either_constructors, 1);
|
|
15
|
+
let _fncts_io_IO_runtime = require("@fncts/io/IO/runtime");
|
|
16
|
+
_fncts_io_IO_runtime = require_rolldown_runtime.__toESM(_fncts_io_IO_runtime, 1);
|
|
17
|
+
let _fncts_io_Channel_core_api = require("@fncts/io/Channel/core-api");
|
|
18
|
+
_fncts_io_Channel_core_api = require_rolldown_runtime.__toESM(_fncts_io_Channel_core_api, 1);
|
|
19
|
+
let _fncts_base_collection_immutable_Conc_api = require("@fncts/base/collection/immutable/Conc/api");
|
|
20
|
+
_fncts_base_collection_immutable_Conc_api = require_rolldown_runtime.__toESM(_fncts_base_collection_immutable_Conc_api, 1);
|
|
21
|
+
let _fncts_io_Sink_definition = require("@fncts/io/Sink/definition");
|
|
22
|
+
_fncts_io_Sink_definition = require_rolldown_runtime.__toESM(_fncts_io_Sink_definition, 1);
|
|
23
|
+
let _fncts_io_IO_api_acquireRelease = require("@fncts/io/IO/api/acquireRelease");
|
|
24
|
+
_fncts_io_IO_api_acquireRelease = require_rolldown_runtime.__toESM(_fncts_io_IO_api_acquireRelease, 1);
|
|
25
|
+
let _fncts_io_Stream_api = require("@fncts/io/Stream/api");
|
|
26
|
+
_fncts_io_Stream_api = require_rolldown_runtime.__toESM(_fncts_io_Stream_api, 1);
|
|
27
|
+
let _fncts_base_collection_immutable_Conc_constructors = require("@fncts/base/collection/immutable/Conc/constructors");
|
|
28
|
+
_fncts_base_collection_immutable_Conc_constructors = require_rolldown_runtime.__toESM(_fncts_base_collection_immutable_Conc_constructors, 1);
|
|
29
|
+
let _fncts_base_data_Maybe_constructors = require("@fncts/base/data/Maybe/constructors");
|
|
30
|
+
_fncts_base_data_Maybe_constructors = require_rolldown_runtime.__toESM(_fncts_base_data_Maybe_constructors, 1);
|
|
31
|
+
let _fncts_base_data_Newtype = require("@fncts/base/data/Newtype");
|
|
32
|
+
_fncts_base_data_Newtype = require_rolldown_runtime.__toESM(_fncts_base_data_Newtype, 1);
|
|
33
|
+
let _fncts_io_Ref_api_set = require("@fncts/io/Ref/api/set");
|
|
34
|
+
_fncts_io_Ref_api_set = require_rolldown_runtime.__toESM(_fncts_io_Ref_api_set, 1);
|
|
35
|
+
let _fncts_io_Ref_api_get = require("@fncts/io/Ref/api/get");
|
|
36
|
+
_fncts_io_Ref_api_get = require_rolldown_runtime.__toESM(_fncts_io_Ref_api_get, 1);
|
|
37
|
+
let _fncts_io_Ref_constructors = require("@fncts/io/Ref/constructors");
|
|
38
|
+
_fncts_io_Ref_constructors = require_rolldown_runtime.__toESM(_fncts_io_Ref_constructors, 1);
|
|
39
|
+
let _fncts_base_data_Cause_api = require("@fncts/base/data/Cause/api");
|
|
40
|
+
_fncts_base_data_Cause_api = require_rolldown_runtime.__toESM(_fncts_base_data_Cause_api, 1);
|
|
41
|
+
let _fncts_io_Ref_api_modify = require("@fncts/io/Ref/api/modify");
|
|
42
|
+
_fncts_io_Ref_api_modify = require_rolldown_runtime.__toESM(_fncts_io_Ref_api_modify, 1);
|
|
43
|
+
let _fncts_io_IO_api_asyncInterrupt = require("@fncts/io/IO/api/asyncInterrupt");
|
|
44
|
+
_fncts_io_IO_api_asyncInterrupt = require_rolldown_runtime.__toESM(_fncts_io_IO_api_asyncInterrupt, 1);
|
|
45
|
+
let fs = require("fs");
|
|
46
|
+
fs = require_rolldown_runtime.__toESM(fs, 1);
|
|
47
|
+
// build/esm/fs/api.js
|
|
72
48
|
const fileName_1 = "(@fncts/node) src/fs/api.ts";
|
|
73
|
-
const FileDescriptor =
|
|
49
|
+
const FileDescriptor = _fncts_base_data_Newtype.newtype();
|
|
74
50
|
function unitErrorCallback(cb) {
|
|
75
|
-
|
|
51
|
+
return (err) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":17:36")) : cb(_fncts_io_IO_api.unit);
|
|
76
52
|
}
|
|
77
53
|
function access(path, mode) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
54
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
55
|
+
fs.access(path, mode, (err) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":22:53")) : cb(_fncts_io_IO_api.unit));
|
|
56
|
+
});
|
|
81
57
|
}
|
|
82
58
|
function appendFile(path, data, options) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
59
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
60
|
+
fs.appendFile(path, data, options ?? {}, (err) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":32:79")) : cb(_fncts_io_IO_api.unit));
|
|
61
|
+
});
|
|
86
62
|
}
|
|
87
63
|
function chmod(path, mode) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
64
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
65
|
+
fs.chmod(path, mode, (err) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":38:52")) : cb(_fncts_io_IO_api.unit));
|
|
66
|
+
});
|
|
91
67
|
}
|
|
92
68
|
function close(fd) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
69
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
70
|
+
fs.close(FileDescriptor.reverseGet(fd), (err) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":44:71")) : cb(_fncts_io_IO_api.unit));
|
|
71
|
+
});
|
|
96
72
|
}
|
|
97
73
|
function chown(path, uid, gid) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
74
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
75
|
+
fs.chown(path, uid, gid, (err) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":50:56")) : cb(_fncts_io_IO_api.unit));
|
|
76
|
+
});
|
|
101
77
|
}
|
|
102
78
|
function copyFile(src, dest, flags) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
79
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
80
|
+
fs.copyFile(src, dest, flags, (err) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":56:61")) : cb(_fncts_io_IO_api.unit));
|
|
81
|
+
});
|
|
106
82
|
}
|
|
107
83
|
function createReadStream(path, options) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return tsplus_module_2.fail(() => new RangeError(`start (${start}) must be <= end (${end})`), fileName_1 + ":80:25");
|
|
125
|
-
} else {
|
|
126
|
-
return tsplus_module_8.make(() => [start, end], fileName_1 + ":82:26");
|
|
127
|
-
}
|
|
128
|
-
}, fileName_1 + ":76:15"), fileName_1 + ":75:75")(open(path, options?.flags ?? fs.constants.O_RDONLY, options?.mode)), ([fd, _]) => tsplus_module_2.orHalt(close(fd), fileName_1 + ":86:27"), fileName_1 + ":74:31"));
|
|
84
|
+
const chunkSize = options?.chunkSize ?? 65536;
|
|
85
|
+
return _fncts_io_Stream_api.flatMap(([fd, state]) => _fncts_io_Stream_api.repeatIOChunkMaybe(_fncts_io_IO_api.flatMap(([pos, end]) => {
|
|
86
|
+
const n = Math.min(end - pos + 1, chunkSize);
|
|
87
|
+
return _fncts_io_IO_api.flatMap(([bytes, chunk]) => _fncts_io_IO_api.flatMap(() => _fncts_io_IO_api.map(() => {
|
|
88
|
+
if (bytes !== chunk.length) {
|
|
89
|
+
const dst = Buffer.allocUnsafeSlow(bytes);
|
|
90
|
+
chunk.copy(dst, 0, 0, bytes);
|
|
91
|
+
return _fncts_base_collection_immutable_Conc_constructors.fromBuffer(dst);
|
|
92
|
+
} else return _fncts_base_collection_immutable_Conc_constructors.fromBuffer(chunk);
|
|
93
|
+
}, fileName_1 + ":94:10")(_fncts_io_Ref_api_set.set([pos + n, end], fileName_1 + ":94:20")(state)), fileName_1 + ":93:10")(_fncts_io_IO_api.when(() => bytes === 0, fileName_1 + ":93:34")(_fncts_io_IO_api.fail(() => _fncts_base_data_Maybe_constructors.nothing(fileName_1 + ":93:26"), fileName_1 + ":93:18"))), fileName_1 + ":91:33")(_fncts_io_IO_api.mapError(_fncts_base_data_Maybe_constructors.just, fileName_1 + ":91:59")(read(fd, n, pos)));
|
|
94
|
+
}, fileName_1 + ":89:33")(_fncts_io_Ref_api_get.get(state, fileName_1 + ":89:39")), fileName_1 + ":87:30"), fileName_1 + ":86:12")(_fncts_io_Stream_api.acquireRelease(_fncts_io_IO_api.zip(_fncts_io_IO_api.defer(() => {
|
|
95
|
+
const start = options?.start ?? 0;
|
|
96
|
+
const end = options?.end ?? Infinity;
|
|
97
|
+
if (end < start) return _fncts_io_IO_api.fail(() => /* @__PURE__ */ new RangeError(`start (${start}) must be <= end (${end})`), fileName_1 + ":79:25");
|
|
98
|
+
else return _fncts_io_Ref_constructors.make(() => [start, end], fileName_1 + ":81:26");
|
|
99
|
+
}, fileName_1 + ":75:15"), fileName_1 + ":74:75")(open(path, options?.flags ?? fs.constants.O_RDONLY, options?.mode)), ([fd, _]) => _fncts_io_IO_api.orHalt(close(fd), fileName_1 + ":85:27"), fileName_1 + ":73:31"));
|
|
129
100
|
}
|
|
130
101
|
function createWriteSink(path, options) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
}, fileName_1 + ":129:29")(tsplus_module_6.get(errorRef, fileName_1 + ":129:38")), fileName_1 + ":122:27")(tsplus_module_2.catchAll(err => tsplus_module_4.set(tsplus_module_5.just(err, fileName_1 + ":126:49"), fileName_1 + ":126:44")(errorRef), fileName_1 + ":126:22")(tsplus_module_15.acquireRelease(() => tsplus_module_2.zip(tsplus_module_8.make(() => options?.start ?? undefined, fileName_1 + ":124:26"), fileName_1 + ":124:17")(open(path, options?.flags ?? fs.constants.O_CREAT | fs.constants.O_WRONLY, options?.mode)), ([fd, _]) => tsplus_module_2.orHalt(close(fd), fileName_1 + ":125:51"), fileName_1 + ":125:28"))), fileName_1 + ":121:27")(tsplus_module_8.make(() => tsplus_module_5.nothing(fileName_1 + ":121:67"), fileName_1 + ":121:36"))));
|
|
102
|
+
return new _fncts_io_Sink_definition.Sink(_fncts_io_Channel_api.unwrapScoped(() => _fncts_io_IO_api.flatMap((errorRef) => _fncts_io_IO_api.flatMap((st) => _fncts_io_IO_api.map((maybeError) => {
|
|
103
|
+
if (!st && _fncts_base_data_Maybe_definition.isJust(maybeError)) return _fncts_io_Channel_api.readWith((_) => _fncts_io_Channel_core_api.zipRight(_fncts_io_Channel_core_api.end(() => void 0))(_fncts_io_Channel_api.fail(() => maybeError.value)), (err) => _fncts_io_Channel_core_api.failCause(() => _fncts_base_data_Cause_api.sequential(_fncts_base_data_Cause_api.fail(maybeError.value), _fncts_base_data_Cause_api.fail(err))), (_) => _fncts_io_Channel_api.fail(() => maybeError.value));
|
|
104
|
+
else {
|
|
105
|
+
const reader = _fncts_io_Channel_api.readWith((inp) => _fncts_io_Channel_api.unwrap(() => _fncts_io_IO_api.map(() => reader, fileName_1 + ":151:23")(_fncts_io_IO_api.flatMap(() => _fncts_io_Ref_api_modify.update((n) => n !== void 0 ? n + inp.length : void 0, fileName_1 + ":150:47")(st[1]), fileName_1 + ":150:27")(_fncts_io_IO_api.flatMap((pos) => write(st[0], inp, pos), fileName_1 + ":149:27")(_fncts_io_Ref_api_get.get(st[1], fileName_1 + ":148:23"))))), (err) => _fncts_io_Channel_api.fail(() => err), (_) => _fncts_io_Channel_core_api.end(() => void 0));
|
|
106
|
+
return reader;
|
|
107
|
+
}
|
|
108
|
+
}, fileName_1 + ":128:29")(_fncts_io_Ref_api_get.get(errorRef, fileName_1 + ":128:38")), fileName_1 + ":121:27")(_fncts_io_IO_api.catchAll((err) => _fncts_io_Ref_api_set.set(_fncts_base_data_Maybe_constructors.just(err, fileName_1 + ":125:49"), fileName_1 + ":125:44")(errorRef), fileName_1 + ":125:22")(_fncts_io_IO_api_acquireRelease.acquireRelease(() => _fncts_io_IO_api.zip(_fncts_io_Ref_constructors.make(() => options?.start ?? void 0, fileName_1 + ":123:26"), fileName_1 + ":123:17")(open(path, options?.flags ?? fs.constants.O_CREAT | fs.constants.O_WRONLY, options?.mode)), ([fd, _]) => _fncts_io_IO_api.orHalt(close(fd), fileName_1 + ":124:51"), fileName_1 + ":124:28"))), fileName_1 + ":120:27")(_fncts_io_Ref_constructors.make(() => _fncts_base_data_Maybe_constructors.nothing(fileName_1 + ":120:67"), fileName_1 + ":120:36"))));
|
|
140
109
|
}
|
|
141
110
|
function fchmod(fd, mode) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
111
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
112
|
+
fs.fchmod(FileDescriptor.reverseGet(fd), mode, unitErrorCallback(cb));
|
|
113
|
+
});
|
|
145
114
|
}
|
|
146
115
|
function fchown(fd, uid, gid) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
116
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
117
|
+
fs.fchown(FileDescriptor.reverseGet(fd), uid, gid, unitErrorCallback(cb));
|
|
118
|
+
});
|
|
150
119
|
}
|
|
151
120
|
function fdatasync(fd) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
121
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
122
|
+
fs.fdatasync(FileDescriptor.reverseGet(fd), unitErrorCallback(cb));
|
|
123
|
+
});
|
|
155
124
|
}
|
|
156
125
|
function fstat(fd) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
126
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
127
|
+
fs.fstat(FileDescriptor.reverseGet(fd), (err, stats) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":183:78")) : cb(_fncts_io_IO_api.succeedNow(stats, fileName_1 + ":183:103")));
|
|
128
|
+
});
|
|
160
129
|
}
|
|
161
130
|
function fsync(fd) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
131
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
132
|
+
fs.fsync(FileDescriptor.reverseGet(fd), unitErrorCallback(cb));
|
|
133
|
+
});
|
|
165
134
|
}
|
|
166
135
|
function ftruncate(fd, len) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
136
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
137
|
+
fs.ftruncate(FileDescriptor.reverseGet(fd), len, unitErrorCallback(cb));
|
|
138
|
+
});
|
|
170
139
|
}
|
|
171
140
|
function futimes(fd, atime, mtime) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
141
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
142
|
+
fs.futimes(FileDescriptor.reverseGet(fd), atime, mtime, unitErrorCallback(cb));
|
|
143
|
+
});
|
|
175
144
|
}
|
|
176
145
|
function lchmod(path, mode) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
146
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
147
|
+
fs.lchmod(path, mode, unitErrorCallback(cb));
|
|
148
|
+
});
|
|
180
149
|
}
|
|
181
150
|
function lchown(path, uid, gid) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
151
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
152
|
+
fs.lchown(path, uid, gid, unitErrorCallback(cb));
|
|
153
|
+
});
|
|
185
154
|
}
|
|
186
155
|
function lutimes(path, atime, mtime) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
156
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
157
|
+
fs.lutimes(path, atime, mtime, unitErrorCallback(cb));
|
|
158
|
+
});
|
|
190
159
|
}
|
|
191
160
|
function link(path, newPath) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
161
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
162
|
+
fs.link(path, newPath, (err) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":233:54")) : cb(_fncts_io_IO_api.unit));
|
|
163
|
+
});
|
|
195
164
|
}
|
|
196
165
|
function lstat(path) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
166
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
167
|
+
fs.lstat(path, (err, stats) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":239:53")) : cb(_fncts_io_IO_api.succeedNow(stats, fileName_1 + ":239:78")));
|
|
168
|
+
});
|
|
200
169
|
}
|
|
201
170
|
function mkdir(path, options) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
171
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
172
|
+
fs.mkdir(path, options, (err, path) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":248:61")) : cb(_fncts_io_IO_api.succeed(() => _fncts_base_data_Maybe_constructors.fromNullable(path), fileName_1 + ":248:83")));
|
|
173
|
+
});
|
|
205
174
|
}
|
|
206
175
|
function mkdtemp(prefix, options) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
176
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
177
|
+
fs.mkdtemp(prefix, options, (err, folder) => err ? cb(_fncts_io_IO_api.failNow(err, fileName_1 + ":254:70")) : cb(_fncts_io_IO_api.succeedNow(folder, fileName_1 + ":254:95")));
|
|
178
|
+
});
|
|
210
179
|
}
|
|
211
180
|
function open(path, flags, mode) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
exports.Dir = Dir;
|
|
181
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
182
|
+
fs.open(path, flags, mode ?? null, (err, fd) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":264:70")) : cb(_fncts_io_IO_api.succeed(() => FileDescriptor.get(fd), fileName_1 + ":264:92")));
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
var Dir = class {
|
|
186
|
+
path;
|
|
187
|
+
_dir;
|
|
188
|
+
constructor(dir) {
|
|
189
|
+
this.path = dir.path;
|
|
190
|
+
this._dir = dir;
|
|
191
|
+
}
|
|
192
|
+
close() {
|
|
193
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
194
|
+
this._dir.close(unitErrorCallback(cb));
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
read() {
|
|
198
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
199
|
+
this._dir.read((err, dirEnt) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":284:56")) : cb(_fncts_io_IO_api.succeedNow(_fncts_base_data_Maybe_constructors.fromNullable(dirEnt), fileName_1 + ":284:81")));
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
};
|
|
235
203
|
function opendir(path, options) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
204
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
205
|
+
fs.opendir(path, options ?? {}, (err, dir) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":291:75")) : cb(_fncts_io_IO_api.succeedNow(new Dir(dir), fileName_1 + ":291:100")));
|
|
206
|
+
});
|
|
239
207
|
}
|
|
240
208
|
function read(fd, length, position) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
209
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
210
|
+
const buf = Buffer.alloc(length);
|
|
211
|
+
fs.read(FileDescriptor.reverseGet(fd), buf, 0, length, position ?? null, (err, bytesRead, buffer) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":303:23")) : cb(_fncts_io_IO_api.succeed(() => [bytesRead, buffer], fileName_1 + ":303:45")));
|
|
212
|
+
});
|
|
245
213
|
}
|
|
246
214
|
function readFile(file, options = {}) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
215
|
+
return _fncts_io_IO_api_asyncInterrupt.asyncInterrupt((cb) => {
|
|
216
|
+
const abortController = new AbortController();
|
|
217
|
+
fs.readFile(file, {
|
|
218
|
+
...options,
|
|
219
|
+
signal: abortController.signal
|
|
220
|
+
}, (err, data) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":320:23")) : cb(_fncts_io_IO_api.succeedNow(data, fileName_1 + ":320:48")));
|
|
221
|
+
return _fncts_base_data_Either_constructors.left(_fncts_io_IO_api.succeed(() => abortController.abort(), fileName_1 + ":322:34"), fileName_1 + ":322:23");
|
|
222
|
+
});
|
|
255
223
|
}
|
|
256
224
|
function readdir(path, options) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
225
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
226
|
+
fs.readdir(path, options ?? {}, (err, files) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":356:23")) : files[0] && files[0] instanceof fs.Dir ? files.map((a) => new Dir(a)) : files);
|
|
227
|
+
});
|
|
260
228
|
}
|
|
261
229
|
function realpath(path, options) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
230
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
231
|
+
fs.realpath(path, options ?? {}, (err, resolvedPath) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":375:78")) : cb(_fncts_io_IO_api.succeedNow(resolvedPath, fileName_1 + ":375:103")));
|
|
232
|
+
});
|
|
265
233
|
}
|
|
266
234
|
function realpathNative(path, options) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
235
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
236
|
+
fs.realpath.native(path, options ?? {}, (err, resolvedPath) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":394:23")) : cb(_fncts_io_IO_api.succeed(() => resolvedPath, fileName_1 + ":394:45")));
|
|
237
|
+
});
|
|
270
238
|
}
|
|
271
239
|
function rename(oldPath, newPath) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
240
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
241
|
+
fs.rename(oldPath, newPath, unitErrorCallback(cb));
|
|
242
|
+
});
|
|
275
243
|
}
|
|
276
244
|
function rm(path, options) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
245
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
246
|
+
fs.rm(path, options ?? {}, unitErrorCallback(cb));
|
|
247
|
+
});
|
|
280
248
|
}
|
|
281
249
|
function rmdir(path) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
250
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
251
|
+
fs.rmdir(path, unitErrorCallback(cb));
|
|
252
|
+
});
|
|
285
253
|
}
|
|
286
254
|
function stat(path, options) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
255
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
256
|
+
fs.stat(path, options ?? {}, (err, stats) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":424:76")) : cb(_fncts_io_IO_api.succeedNow(stats, fileName_1 + ":424:101")));
|
|
257
|
+
});
|
|
290
258
|
}
|
|
291
259
|
function symlink(target, path) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
260
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
261
|
+
fs.symlink(target, path, unitErrorCallback(cb));
|
|
262
|
+
});
|
|
295
263
|
}
|
|
296
264
|
function truncate(path, len) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
265
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
266
|
+
fs.truncate(path, len, unitErrorCallback(cb));
|
|
267
|
+
});
|
|
300
268
|
}
|
|
301
269
|
function unlink(path) {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
270
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
271
|
+
fs.unlink(path, unitErrorCallback(cb));
|
|
272
|
+
});
|
|
305
273
|
}
|
|
306
274
|
function utimes(path, atime, mtime) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
275
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
276
|
+
fs.utimes(path, atime, mtime, unitErrorCallback(cb));
|
|
277
|
+
});
|
|
310
278
|
}
|
|
311
279
|
function write(fd, buffer, position) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
280
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
281
|
+
const b = _fncts_base_collection_immutable_Conc_api.toBuffer(buffer);
|
|
282
|
+
fs.write(FileDescriptor.reverseGet(fd), b, position ?? null, b.byteLength, (err, bytesWritten) => err ? cb(_fncts_io_IO_api.failNow(err, fileName_1 + ":460:26")) : cb(_fncts_io_IO_api.succeedNow(bytesWritten, fileName_1 + ":460:51")));
|
|
283
|
+
});
|
|
316
284
|
}
|
|
317
285
|
function writeFile(file, data, options = {}) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
286
|
+
return _fncts_io_IO_api_asyncInterrupt.asyncInterrupt((cb) => {
|
|
287
|
+
const abortController = new AbortController();
|
|
288
|
+
fs.writeFile(file, data, {
|
|
289
|
+
...options,
|
|
290
|
+
signal: abortController.signal
|
|
291
|
+
}, (err) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":479:23")) : _fncts_io_IO_api.unit);
|
|
292
|
+
return _fncts_base_data_Either_constructors.left(_fncts_io_IO_api.succeed(() => abortController.abort(), fileName_1 + ":481:34"), fileName_1 + ":481:23");
|
|
293
|
+
});
|
|
326
294
|
}
|
|
327
295
|
function writev(fd, buffers, position) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
fs.writev(FileDescriptor.reverseGet(fd), buffers, (err, bytesWritten) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":498:25")) : cb(tsplus_module_2.succeedNow(bytesWritten, fileName_1 + ":498:50")));
|
|
333
|
-
}
|
|
334
|
-
});
|
|
296
|
+
return _fncts_io_IO_api.async((cb) => {
|
|
297
|
+
if (position) fs.writev(FileDescriptor.reverseGet(fd), buffers, position, (err, bytesWritten) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":493:25")) : cb(_fncts_io_IO_api.succeedNow(bytesWritten, fileName_1 + ":493:50")));
|
|
298
|
+
else fs.writev(FileDescriptor.reverseGet(fd), buffers, (err, bytesWritten) => err ? cb(_fncts_io_IO_api.fail(() => err, fileName_1 + ":497:25")) : cb(_fncts_io_IO_api.succeedNow(bytesWritten, fileName_1 + ":497:50")));
|
|
299
|
+
});
|
|
335
300
|
}
|
|
336
301
|
function watch(filename, options) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
302
|
+
return _fncts_io_Stream_api.flatMap((watcher) => _fncts_io_Stream_api.repeatIOMaybe(_fncts_io_IO_api.async((cb) => {
|
|
303
|
+
watcher.once("change", (eventType, filename) => {
|
|
304
|
+
watcher.removeAllListeners();
|
|
305
|
+
cb(_fncts_io_IO_api.succeedNow({
|
|
306
|
+
eventType,
|
|
307
|
+
filename
|
|
308
|
+
}, fileName_1 + ":533:27"));
|
|
309
|
+
});
|
|
310
|
+
watcher.once("error", (error) => {
|
|
311
|
+
watcher.removeAllListeners();
|
|
312
|
+
cb(_fncts_io_IO_api.failNow(_fncts_base_data_Maybe_constructors.just(error, fileName_1 + ":537:29"), fileName_1 + ":537:24"));
|
|
313
|
+
});
|
|
314
|
+
watcher.once("close", () => {
|
|
315
|
+
watcher.removeAllListeners();
|
|
316
|
+
cb(_fncts_io_IO_api.failNow(_fncts_base_data_Maybe_constructors.nothing(fileName_1 + ":541:32"), fileName_1 + ":541:24"));
|
|
317
|
+
});
|
|
318
|
+
}), fileName_1 + ":529:25"), fileName_1 + ":528:12")(_fncts_io_Stream_api.fromIO(_fncts_io_IO_api.tryCatch(() => fs.watch(filename, options ?? {}), (err) => err, fileName_1 + ":524:16"), fileName_1 + ":523:23"));
|
|
354
319
|
}
|
|
355
320
|
function watchFile(filename, options) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
321
|
+
return _fncts_io_Stream_api.flatMap((queue) => _fncts_io_Stream_api.repeatIOMaybe(_fncts_io_Queue_api_operations.take(queue, fileName_1 + ":578:50"), fileName_1 + ":578:44"), fileName_1 + ":578:12")(_fncts_io_Stream_api.acquireRelease(_fncts_io_IO_api.flatMap((queue) => _fncts_io_IO_api.map((runtime) => {
|
|
322
|
+
fs.watchFile(filename, options ?? {}, (curr, prev) => {
|
|
323
|
+
runtime.unsafeRunFiber(_fncts_io_Queue_api_operations.offer([curr, prev], fileName_1 + ":573:43")(queue), fileName_1 + ":573:31");
|
|
324
|
+
});
|
|
325
|
+
return queue;
|
|
326
|
+
}, fileName_1 + ":571:24")(_fncts_io_IO_runtime.runtime(fileName_1 + ":571:35")), fileName_1 + ":570:24")(_fncts_io_Queue_constructors.makeUnbounded(fileName_1 + ":570:44")), (queue) => _fncts_io_Queue_api_operations.shutdown(queue, fileName_1 + ":577:21"), fileName_1 + ":568:31"));
|
|
362
327
|
}
|
|
328
|
+
exports.Dir = Dir;
|
|
329
|
+
exports.FileDescriptor = FileDescriptor;
|
|
330
|
+
exports.access = access;
|
|
331
|
+
exports.appendFile = appendFile;
|
|
332
|
+
exports.chmod = chmod;
|
|
333
|
+
exports.chown = chown;
|
|
334
|
+
exports.close = close;
|
|
335
|
+
exports.copyFile = copyFile;
|
|
336
|
+
exports.createReadStream = createReadStream;
|
|
337
|
+
exports.createWriteSink = createWriteSink;
|
|
338
|
+
exports.fchmod = fchmod;
|
|
339
|
+
exports.fchown = fchown;
|
|
340
|
+
exports.fdatasync = fdatasync;
|
|
341
|
+
exports.fstat = fstat;
|
|
342
|
+
exports.fsync = fsync;
|
|
343
|
+
exports.ftruncate = ftruncate;
|
|
344
|
+
exports.futimes = futimes;
|
|
345
|
+
exports.lchmod = lchmod;
|
|
346
|
+
exports.lchown = lchown;
|
|
347
|
+
exports.link = link;
|
|
348
|
+
exports.lstat = lstat;
|
|
349
|
+
exports.lutimes = lutimes;
|
|
350
|
+
exports.mkdir = mkdir;
|
|
351
|
+
exports.mkdtemp = mkdtemp;
|
|
352
|
+
exports.open = open;
|
|
353
|
+
exports.opendir = opendir;
|
|
354
|
+
exports.read = read;
|
|
355
|
+
exports.readFile = readFile;
|
|
356
|
+
exports.readdir = readdir;
|
|
357
|
+
exports.realpath = realpath;
|
|
358
|
+
exports.realpathNative = realpathNative;
|
|
359
|
+
exports.rename = rename;
|
|
360
|
+
exports.rm = rm;
|
|
361
|
+
exports.rmdir = rmdir;
|
|
362
|
+
exports.stat = stat;
|
|
363
|
+
exports.symlink = symlink;
|
|
364
|
+
exports.truncate = truncate;
|
|
365
|
+
exports.unlink = unlink;
|
|
366
|
+
exports.utimes = utimes;
|
|
367
|
+
exports.watch = watch;
|
|
368
|
+
exports.watchFile = watchFile;
|
|
369
|
+
exports.write = write;
|
|
370
|
+
exports.writeFile = writeFile;
|
|
371
|
+
exports.writev = writev;
|
|
372
|
+
|
|
363
373
|
//# sourceMappingURL=api.cjs.map
|