@effect/platform 0.0.0 → 0.1.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.
Files changed (48) hide show
  1. package/Console.d.ts +114 -12
  2. package/Console.d.ts.map +1 -1
  3. package/Console.js +109 -1
  4. package/Console.js.map +1 -1
  5. package/Error.d.ts +1 -1
  6. package/Error.d.ts.map +1 -1
  7. package/FileSystem.d.ts +246 -47
  8. package/FileSystem.d.ts.map +1 -1
  9. package/FileSystem.js +24 -1
  10. package/FileSystem.js.map +1 -1
  11. package/Path.d.ts +59 -0
  12. package/Path.d.ts.map +1 -0
  13. package/{FileSystem/File.js → Path.js} +14 -24
  14. package/Path.js.map +1 -0
  15. package/internal/console.js +63 -3
  16. package/internal/console.js.map +1 -1
  17. package/internal/fileSystem.js +2 -2
  18. package/internal/fileSystem.js.map +1 -1
  19. package/internal/path.d.ts +2 -0
  20. package/internal/path.d.ts.map +1 -0
  21. package/internal/path.js +97 -0
  22. package/internal/path.js.map +1 -0
  23. package/mjs/Console.mjs +90 -0
  24. package/mjs/Console.mjs.map +1 -1
  25. package/mjs/FileSystem.mjs +19 -0
  26. package/mjs/FileSystem.mjs.map +1 -1
  27. package/mjs/Path.mjs +20 -0
  28. package/mjs/Path.mjs.map +1 -0
  29. package/mjs/internal/console.mjs +44 -2
  30. package/mjs/internal/console.mjs.map +1 -1
  31. package/mjs/internal/fileSystem.mjs +2 -2
  32. package/mjs/internal/fileSystem.mjs.map +1 -1
  33. package/mjs/internal/path.mjs +87 -0
  34. package/mjs/internal/path.mjs.map +1 -0
  35. package/package.json +5 -4
  36. package/src/Console.ts +132 -12
  37. package/src/Error.ts +1 -1
  38. package/src/FileSystem.ts +356 -119
  39. package/src/Path.ts +64 -0
  40. package/src/internal/console.ts +92 -14
  41. package/src/internal/fileSystem.ts +3 -4
  42. package/src/internal/path.ts +101 -0
  43. package/FileSystem/File.d.ts +0 -91
  44. package/FileSystem/File.d.ts.map +0 -1
  45. package/FileSystem/File.js.map +0 -1
  46. package/mjs/FileSystem/File.mjs +0 -28
  47. package/mjs/FileSystem/File.mjs.map +0 -1
  48. package/src/FileSystem/File.ts +0 -125
@@ -52,14 +52,12 @@ const consoleImpl = Console.of({
52
52
  })
53
53
  },
54
54
  group(options) {
55
- return (self) =>
56
- Effect.acquireUseRelease(
57
- options?.collapsed ?
58
- Effect.sync(() => console.groupCollapsed(options?.label)) :
59
- Effect.sync(() => console.group(options?.label)),
60
- () => self,
61
- () => Effect.sync(() => console.groupEnd())
62
- )
55
+ return Effect.acquireRelease(
56
+ options?.collapsed ?
57
+ Effect.sync(() => console.groupCollapsed(options?.label)) :
58
+ Effect.sync(() => console.group(options?.label)),
59
+ () => Effect.sync(() => console.groupEnd())
60
+ )
63
61
  },
64
62
  info(...args) {
65
63
  return Effect.sync(() => {
@@ -77,12 +75,10 @@ const consoleImpl = Console.of({
77
75
  })
78
76
  },
79
77
  time(label) {
80
- return (self) =>
81
- Effect.acquireUseRelease(
82
- Effect.sync(() => console.time(label)),
83
- () => self,
84
- () => Effect.sync(() => console.timeEnd(label))
85
- )
78
+ return Effect.acquireRelease(
79
+ Effect.sync(() => console.time(label)),
80
+ () => Effect.sync(() => console.timeEnd(label))
81
+ )
86
82
  },
87
83
  timeLog(label, ...args) {
88
84
  return Effect.sync(() => {
@@ -98,8 +94,90 @@ const consoleImpl = Console.of({
98
94
  return Effect.sync(() => {
99
95
  console.warn(...args)
100
96
  })
97
+ },
98
+ withGroup(options) {
99
+ return (self) =>
100
+ Effect.acquireUseRelease(
101
+ options?.collapsed ?
102
+ Effect.sync(() => console.groupCollapsed(options?.label)) :
103
+ Effect.sync(() => console.group(options?.label)),
104
+ () => self,
105
+ () => Effect.sync(() => console.groupEnd())
106
+ )
107
+ },
108
+ withTime(label) {
109
+ return (self) =>
110
+ Effect.acquireUseRelease(
111
+ Effect.sync(() => console.time(label)),
112
+ () => self,
113
+ () => Effect.sync(() => console.timeEnd(label))
114
+ )
101
115
  }
102
116
  })
103
117
 
104
118
  /** @internal */
105
119
  export const layer = Layer.succeed(Console, consoleImpl)
120
+
121
+ /** @internal */
122
+ export const assert = (condition: boolean, ...args: ReadonlyArray<any>) =>
123
+ Effect.flatMap(Console, (_) => _.assert(condition, ...args))
124
+
125
+ /** @internal */
126
+ export const clear = () => Effect.flatMap(Console, (_) => _.clear())
127
+
128
+ /** @internal */
129
+ export const count = (label?: string) => Effect.flatMap(Console, (_) => _.count(label))
130
+
131
+ /** @internal */
132
+ export const countReset = (label?: string) => Effect.flatMap(Console, (_) => _.countReset(label))
133
+
134
+ /** @internal */
135
+ export const debug = (...args: ReadonlyArray<any>) => Effect.flatMap(Console, (_) => _.debug(...args))
136
+
137
+ /** @internal */
138
+ export const dir = (...args: ReadonlyArray<any>) => Effect.flatMap(Console, (_) => _.dir(...args))
139
+
140
+ /** @internal */
141
+ export const dirxml = (...args: ReadonlyArray<any>) => Effect.flatMap(Console, (_) => _.dirxml(...args))
142
+
143
+ /** @internal */
144
+ export const error = (...args: ReadonlyArray<any>) => Effect.flatMap(Console, (_) => _.error(...args))
145
+
146
+ /** @internal */
147
+ export const group = (options?: { label?: string; collapsed?: boolean }) =>
148
+ Effect.flatMap(Console, (_) => _.group(options))
149
+
150
+ /** @internal */
151
+ export const info = (...args: ReadonlyArray<any>) => Effect.flatMap(Console, (_) => _.info(...args))
152
+
153
+ /** @internal */
154
+ export const log = (...args: ReadonlyArray<any>) => Effect.flatMap(Console, (_) => _.log(...args))
155
+
156
+ /** @internal */
157
+ export const table = (tabularData: any, properties?: ReadonlyArray<string>) =>
158
+ Effect.flatMap(Console, (_) => _.table(tabularData, properties))
159
+
160
+ /** @internal */
161
+ export const time = (label?: string) => Effect.flatMap(Console, (_) => _.time(label))
162
+
163
+ /** @internal */
164
+ export const timeLog = (label?: string, ...args: ReadonlyArray<any>) =>
165
+ Effect.flatMap(Console, (_) => _.timeLog(label, ...args))
166
+
167
+ /** @internal */
168
+ export const trace = (...args: ReadonlyArray<any>) => Effect.flatMap(Console, (_) => _.trace(...args))
169
+
170
+ /** @internal */
171
+ export const warn = (...args: ReadonlyArray<any>) => Effect.flatMap(Console, (_) => _.warn(...args))
172
+
173
+ /** @internal */
174
+ export const withGroup = (options?: { label?: string; collapsed?: boolean }) =>
175
+ <R, E, A>(
176
+ self: Effect.Effect<R, E, A>
177
+ ) => Effect.flatMap(Console, (_) => _.withGroup(options)(self))
178
+
179
+ /** @internal */
180
+ export const withTime = (label?: string) =>
181
+ <R, E, A>(
182
+ self: Effect.Effect<R, E, A>
183
+ ) => Effect.flatMap(Console, (_) => _.withTime(label)(self))
@@ -2,8 +2,7 @@ import { Tag } from "@effect/data/Context"
2
2
  import { pipe } from "@effect/data/Function"
3
3
  import * as Option from "@effect/data/Option"
4
4
  import * as Effect from "@effect/io/Effect"
5
- import type { FileSystem, Size as Size_, StreamOptions } from "@effect/platform/FileSystem"
6
- import type { File } from "@effect/platform/FileSystem/File"
5
+ import type { File, FileSystem, Size as Size_, StreamOptions } from "@effect/platform/FileSystem"
7
6
  import * as Sink from "@effect/stream/Sink"
8
7
  import * as Stream from "@effect/stream/Stream"
9
8
 
@@ -36,8 +35,8 @@ export const make = (impl: Omit<FileSystem, "stream" | "sink">): FileSystem => {
36
35
  const stream = (file: File, {
37
36
  bufferSize = 4,
38
37
  bytesToRead,
39
- chunkSize = Size(16n * 1024n),
40
- offset = Size(0n)
38
+ chunkSize = Size(64 * 1024),
39
+ offset = Size(0)
41
40
  }: StreamOptions = {}) =>
42
41
  Stream.bufferChunks(
43
42
  Stream.unfoldEffect(offset, (position) => {
@@ -0,0 +1,101 @@
1
+ import { Tag } from "@effect/data/Context"
2
+ import { identity } from "@effect/data/Function"
3
+ import * as Effect from "@effect/io/Effect"
4
+ import * as Layer from "@effect/io/Layer"
5
+ import { BadArgument } from "@effect/platform/Error"
6
+ import type { Path as _Path } from "@effect/platform/Path"
7
+ import * as PathB from "path-browserify"
8
+
9
+ /** @internal */
10
+ export const Path = Tag<_Path>()
11
+
12
+ /** @internal */
13
+ export const layer = Layer.succeed(
14
+ Path,
15
+ Path.of({
16
+ ...PathB,
17
+ fromFileUrl,
18
+ toFileUrl,
19
+ toNamespacedPath: identity
20
+ })
21
+ )
22
+
23
+ /**
24
+ * The following functions are adapted from the Node.js source code:
25
+ * https://github.com/nodejs/node/blob/main/lib/internal/url.js
26
+ *
27
+ * The following license applies to these functions:
28
+ * - MIT
29
+ */
30
+
31
+ function fromFileUrl(url: URL): Effect.Effect<never, BadArgument, string> {
32
+ if (url.protocol !== "file:") {
33
+ return Effect.fail(BadArgument({
34
+ module: "Path",
35
+ method: "fromFileUrl",
36
+ message: "URL must be of scheme file"
37
+ }))
38
+ } else if (url.hostname !== "") {
39
+ return Effect.fail(BadArgument({
40
+ module: "Path",
41
+ method: "fromFileUrl",
42
+ message: "Invalid file URL host"
43
+ }))
44
+ }
45
+ const pathname = url.pathname
46
+ for (let n = 0; n < pathname.length; n++) {
47
+ if (pathname[n] === "%") {
48
+ const third = pathname.codePointAt(n + 2)! | 0x20
49
+ if (pathname[n + 1] === "2" && third === 102) {
50
+ return Effect.fail(BadArgument({
51
+ module: "Path",
52
+ method: "fromFileUrl",
53
+ message: "must not include encoded / characters"
54
+ }))
55
+ }
56
+ }
57
+ }
58
+ return Effect.succeed(decodeURIComponent(pathname))
59
+ }
60
+
61
+ const CHAR_FORWARD_SLASH = 47
62
+
63
+ function toFileUrl(filepath: string) {
64
+ const outURL = new URL("file://")
65
+ let resolved = PathB.resolve(filepath)
66
+ // path.resolve strips trailing slashes so we must add them back
67
+ const filePathLast = filepath.charCodeAt(filepath.length - 1)
68
+ if (
69
+ (filePathLast === CHAR_FORWARD_SLASH) &&
70
+ resolved[resolved.length - 1] !== "/"
71
+ ) {
72
+ resolved += "/"
73
+ }
74
+ outURL.pathname = encodePathChars(resolved)
75
+ return Effect.succeed(outURL)
76
+ }
77
+
78
+ const percentRegEx = /%/g
79
+ const backslashRegEx = /\\/g
80
+ const newlineRegEx = /\n/g
81
+ const carriageReturnRegEx = /\r/g
82
+ const tabRegEx = /\t/g
83
+
84
+ function encodePathChars(filepath: string) {
85
+ if (filepath.includes("%")) {
86
+ filepath = filepath.replace(percentRegEx, "%25")
87
+ }
88
+ if (filepath.includes("\\")) {
89
+ filepath = filepath.replace(backslashRegEx, "%5C")
90
+ }
91
+ if (filepath.includes("\n")) {
92
+ filepath = filepath.replace(newlineRegEx, "%0A")
93
+ }
94
+ if (filepath.includes("\r")) {
95
+ filepath = filepath.replace(carriageReturnRegEx, "%0D")
96
+ }
97
+ if (filepath.includes("\t")) {
98
+ filepath = filepath.replace(tabRegEx, "%09")
99
+ }
100
+ return filepath
101
+ }
@@ -1,91 +0,0 @@
1
- /**
2
- * @since 1.0.0
3
- */
4
- import * as Brand from "@effect/data/Brand";
5
- import type { Option } from "@effect/data/Option";
6
- import type * as Effect from "@effect/io/Effect";
7
- import type { PlatformError } from "@effect/platform/Error";
8
- import type { Size } from "@effect/platform/FileSystem";
9
- /**
10
- * @since 1.0.0
11
- * @category type id
12
- */
13
- export declare const FileTypeId: unique symbol;
14
- /**
15
- * @since 1.0.0
16
- * @category type id
17
- */
18
- export type FileTypeId = typeof FileTypeId;
19
- /**
20
- * @since 1.0.0
21
- * @category guard
22
- */
23
- export declare const isFile: (u: unknown) => u is File;
24
- /**
25
- * @since 1.0.0
26
- * @category model
27
- */
28
- export interface File {
29
- readonly [FileTypeId]: FileTypeId;
30
- readonly fd: File.Descriptor;
31
- readonly stat: Effect.Effect<never, PlatformError, File.Info>;
32
- readonly read: (buffer: Uint8Array, options?: FileReadOptions) => Effect.Effect<never, PlatformError, Size>;
33
- readonly readAlloc: (size: Size, options?: FileReadOptions) => Effect.Effect<never, PlatformError, Option<Uint8Array>>;
34
- readonly truncate: (length?: Size) => Effect.Effect<never, PlatformError, void>;
35
- readonly write: (buffer: Uint8Array) => Effect.Effect<never, PlatformError, Size>;
36
- readonly writeAll: (buffer: Uint8Array) => Effect.Effect<never, PlatformError, void>;
37
- }
38
- /**
39
- * @since 1.0.0
40
- * @category constructor
41
- */
42
- export declare const make: (impl: Omit<File, FileTypeId>) => File;
43
- /**
44
- * @since 1.0.0
45
- */
46
- export declare namespace File {
47
- /**
48
- * @since 1.0.0
49
- * @category model
50
- */
51
- type Descriptor = Brand.Branded<number, "FileDescriptor">;
52
- /**
53
- * @since 1.0.0
54
- * @category model
55
- */
56
- type Type = "File" | "Directory" | "SymbolicLink" | "BlockDevice" | "CharacterDevice" | "FIFO" | "Socket" | "Unknown";
57
- /**
58
- * @since 1.0.0
59
- * @category model
60
- */
61
- interface Info {
62
- readonly type: Type;
63
- readonly mtime: Option<Date>;
64
- readonly atime: Option<Date>;
65
- readonly birthtime: Option<Date>;
66
- readonly dev: number;
67
- readonly ino: Option<number>;
68
- readonly mode: number;
69
- readonly nlink: Option<number>;
70
- readonly uid: Option<number>;
71
- readonly gid: Option<number>;
72
- readonly rdev: Option<number>;
73
- readonly size: Size;
74
- readonly blksize: Option<Size>;
75
- readonly blocks: Option<number>;
76
- }
77
- }
78
- /**
79
- * @since 1.0.0
80
- * @category constructor
81
- */
82
- export declare const Descriptor: Brand.Brand.Constructor<File.Descriptor>;
83
- /**
84
- * @since 1.0.0
85
- * @category model
86
- */
87
- export interface FileReadOptions {
88
- readonly offset?: Size;
89
- readonly length?: Size;
90
- }
91
- //# sourceMappingURL=File.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"File.d.ts","sourceRoot":"","sources":["../src/FileSystem/File.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAEvD;;;GAGG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AC,MAAM,CAAC,EAAE,IAAI,CAAA;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAA;CACvB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"File.js","names":["Brand","_interopRequireWildcard","require","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","FileTypeId","Symbol","for","exports","isFile","u","make","impl","Descriptor","nominal"],"sources":["../src/FileSystem/File.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,KAAA,gBAAAC,uBAAA,eAAAC,OAAA;AAA2C,SAAAC,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA;AAH3C;;;;AASA;;;;AAIO,MAAMW,UAAU,gBAAkBC,MAAM,CAACC,GAAG,CACjD,kCAAkC,CACnC;AAQD;;;;AAAAC,OAAA,CAAAH,UAAA,GAAAA,UAAA;AAIO,MAAMI,MAAM,GAAIC,CAAU,IAAgB,OAAOA,CAAC,KAAK,QAAQ,IAAIA,CAAC,KAAK,IAAI,IAAIL,UAAU,IAAIK,CAAC;AA6BvG;;;;AAAAF,OAAA,CAAAC,MAAA,GAAAA,MAAA;AAIO,MAAME,IAAI,GAAIC,IAA4B,KAAY;EAC3D,CAACP,UAAU,GAAGA,UAAU;EACxB,GAAGO;CACJ,CAAC;AAgDF;;;;AAAAJ,OAAA,CAAAG,IAAA,GAAAA,IAAA;AAIO,MAAME,UAAU,gBAAGjC,KAAK,CAACkC,OAAO,EAAmB;AAAAN,OAAA,CAAAK,UAAA,GAAAA,UAAA"}
@@ -1,28 +0,0 @@
1
- /**
2
- * @since 1.0.0
3
- */
4
- import * as Brand from "@effect/data/Brand";
5
- /**
6
- * @since 1.0.0
7
- * @category type id
8
- */
9
- export const FileTypeId = /*#__PURE__*/Symbol.for("@effect/platform/FileSystem/File");
10
- /**
11
- * @since 1.0.0
12
- * @category guard
13
- */
14
- export const isFile = u => typeof u === "object" && u !== null && FileTypeId in u;
15
- /**
16
- * @since 1.0.0
17
- * @category constructor
18
- */
19
- export const make = impl => ({
20
- [FileTypeId]: FileTypeId,
21
- ...impl
22
- });
23
- /**
24
- * @since 1.0.0
25
- * @category constructor
26
- */
27
- export const Descriptor = /*#__PURE__*/Brand.nominal();
28
- //# sourceMappingURL=File.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"File.mjs","names":["Brand","FileTypeId","Symbol","for","isFile","u","make","impl","Descriptor","nominal"],"sources":["../../src/FileSystem/File.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,KAAK,MAAM,oBAAoB;AAM3C;;;;AAIA,OAAO,MAAMC,UAAU,gBAAkBC,MAAM,CAACC,GAAG,CACjD,kCAAkC,CACnC;AAQD;;;;AAIA,OAAO,MAAMC,MAAM,GAAIC,CAAU,IAAgB,OAAOA,CAAC,KAAK,QAAQ,IAAIA,CAAC,KAAK,IAAI,IAAIJ,UAAU,IAAII,CAAC;AA6BvG;;;;AAIA,OAAO,MAAMC,IAAI,GAAIC,IAA4B,KAAY;EAC3D,CAACN,UAAU,GAAGA,UAAU;EACxB,GAAGM;CACJ,CAAC;AAgDF;;;;AAIA,OAAO,MAAMC,UAAU,gBAAGR,KAAK,CAACS,OAAO,EAAmB"}
@@ -1,125 +0,0 @@
1
- /**
2
- * @since 1.0.0
3
- */
4
- import * as Brand from "@effect/data/Brand"
5
- import type { Option } from "@effect/data/Option"
6
- import type * as Effect from "@effect/io/Effect"
7
- import type { PlatformError } from "@effect/platform/Error"
8
- import type { Size } from "@effect/platform/FileSystem"
9
-
10
- /**
11
- * @since 1.0.0
12
- * @category type id
13
- */
14
- export const FileTypeId: unique symbol = Symbol.for(
15
- "@effect/platform/FileSystem/File"
16
- )
17
-
18
- /**
19
- * @since 1.0.0
20
- * @category type id
21
- */
22
- export type FileTypeId = typeof FileTypeId
23
-
24
- /**
25
- * @since 1.0.0
26
- * @category guard
27
- */
28
- export const isFile = (u: unknown): u is File => typeof u === "object" && u !== null && FileTypeId in u
29
-
30
- /**
31
- * @since 1.0.0
32
- * @category model
33
- */
34
- export interface File {
35
- readonly [FileTypeId]: FileTypeId
36
- readonly fd: File.Descriptor
37
- readonly stat: Effect.Effect<never, PlatformError, File.Info>
38
- readonly read: (
39
- buffer: Uint8Array,
40
- options?: FileReadOptions
41
- ) => Effect.Effect<never, PlatformError, Size>
42
- readonly readAlloc: (
43
- size: Size,
44
- options?: FileReadOptions
45
- ) => Effect.Effect<never, PlatformError, Option<Uint8Array>>
46
- readonly truncate: (
47
- length?: Size
48
- ) => Effect.Effect<never, PlatformError, void>
49
- readonly write: (
50
- buffer: Uint8Array
51
- ) => Effect.Effect<never, PlatformError, Size>
52
- readonly writeAll: (
53
- buffer: Uint8Array
54
- ) => Effect.Effect<never, PlatformError, void>
55
- }
56
-
57
- /**
58
- * @since 1.0.0
59
- * @category constructor
60
- */
61
- export const make = (impl: Omit<File, FileTypeId>): File => ({
62
- [FileTypeId]: FileTypeId,
63
- ...impl
64
- })
65
-
66
- /**
67
- * @since 1.0.0
68
- */
69
- export namespace File {
70
- /**
71
- * @since 1.0.0
72
- * @category model
73
- */
74
- export type Descriptor = Brand.Branded<number, "FileDescriptor">
75
-
76
- /**
77
- * @since 1.0.0
78
- * @category model
79
- */
80
- export type Type =
81
- | "File"
82
- | "Directory"
83
- | "SymbolicLink"
84
- | "BlockDevice"
85
- | "CharacterDevice"
86
- | "FIFO"
87
- | "Socket"
88
- | "Unknown"
89
-
90
- /**
91
- * @since 1.0.0
92
- * @category model
93
- */
94
- export interface Info {
95
- readonly type: Type
96
- readonly mtime: Option<Date>
97
- readonly atime: Option<Date>
98
- readonly birthtime: Option<Date>
99
- readonly dev: number
100
- readonly ino: Option<number>
101
- readonly mode: number
102
- readonly nlink: Option<number>
103
- readonly uid: Option<number>
104
- readonly gid: Option<number>
105
- readonly rdev: Option<number>
106
- readonly size: Size
107
- readonly blksize: Option<Size>
108
- readonly blocks: Option<number>
109
- }
110
- }
111
-
112
- /**
113
- * @since 1.0.0
114
- * @category constructor
115
- */
116
- export const Descriptor = Brand.nominal<File.Descriptor>()
117
-
118
- /**
119
- * @since 1.0.0
120
- * @category model
121
- */
122
- export interface FileReadOptions {
123
- readonly offset?: Size
124
- readonly length?: Size
125
- }