@effect/platform 0.0.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 (76) hide show
  1. package/Console.d.ts +42 -0
  2. package/Console.d.ts.map +1 -0
  3. package/Console.js +22 -0
  4. package/Console.js.map +1 -0
  5. package/Effectify.d.ts +225 -0
  6. package/Effectify.d.ts.map +1 -0
  7. package/Effectify.js +15 -0
  8. package/Effectify.js.map +1 -0
  9. package/Error.d.ts +72 -0
  10. package/Error.d.ts.map +1 -0
  11. package/Error.js +28 -0
  12. package/Error.js.map +1 -0
  13. package/FileSystem/File.d.ts +91 -0
  14. package/FileSystem/File.d.ts.map +1 -0
  15. package/FileSystem/File.js +41 -0
  16. package/FileSystem/File.js.map +1 -0
  17. package/FileSystem.d.ts +147 -0
  18. package/FileSystem.d.ts.map +1 -0
  19. package/FileSystem.js +28 -0
  20. package/FileSystem.js.map +1 -0
  21. package/LICENSE +21 -0
  22. package/Runtime.d.ts +22 -0
  23. package/Runtime.d.ts.map +1 -0
  24. package/Runtime.js +23 -0
  25. package/Runtime.js.map +1 -0
  26. package/internal/console.d.ts +8 -0
  27. package/internal/console.d.ts.map +1 -0
  28. package/internal/console.js +100 -0
  29. package/internal/console.js.map +1 -0
  30. package/internal/effectify.d.ts +2 -0
  31. package/internal/effectify.d.ts.map +1 -0
  32. package/internal/effectify.js +25 -0
  33. package/internal/effectify.js.map +1 -0
  34. package/internal/error.d.ts +2 -0
  35. package/internal/error.d.ts.map +1 -0
  36. package/internal/error.js +24 -0
  37. package/internal/error.js.map +1 -0
  38. package/internal/fileSystem.d.ts +2 -0
  39. package/internal/fileSystem.d.ts.map +1 -0
  40. package/internal/fileSystem.js +49 -0
  41. package/internal/fileSystem.js.map +1 -0
  42. package/mjs/Console.mjs +12 -0
  43. package/mjs/Console.mjs.map +1 -0
  44. package/mjs/Effectify.mjs +6 -0
  45. package/mjs/Effectify.mjs.map +1 -0
  46. package/mjs/Error.mjs +17 -0
  47. package/mjs/Error.mjs.map +1 -0
  48. package/mjs/FileSystem/File.mjs +28 -0
  49. package/mjs/FileSystem/File.mjs.map +1 -0
  50. package/mjs/FileSystem.mjs +17 -0
  51. package/mjs/FileSystem.mjs.map +1 -0
  52. package/mjs/Runtime.mjs +13 -0
  53. package/mjs/Runtime.mjs.map +1 -0
  54. package/mjs/internal/console.mjs +90 -0
  55. package/mjs/internal/console.mjs.map +1 -0
  56. package/mjs/internal/effectify.mjs +16 -0
  57. package/mjs/internal/effectify.mjs.map +1 -0
  58. package/mjs/internal/error.mjs +13 -0
  59. package/mjs/internal/error.mjs.map +1 -0
  60. package/mjs/internal/fileSystem.mjs +38 -0
  61. package/mjs/internal/fileSystem.mjs.map +1 -0
  62. package/package.json +30 -0
  63. package/src/Console.ts +45 -0
  64. package/src/Effectify.ts +257 -0
  65. package/src/Error.ts +93 -0
  66. package/src/FileSystem/File.ts +125 -0
  67. package/src/FileSystem.ts +237 -0
  68. package/src/Runtime.ts +36 -0
  69. package/src/internal/console.ts +105 -0
  70. package/src/internal/effectify.ts +31 -0
  71. package/src/internal/error.ts +21 -0
  72. package/src/internal/fileSystem.ts +60 -0
  73. package/tsconfig.build.json +10 -0
  74. package/tsconfig.examples.json +11 -0
  75. package/tsconfig.json +11 -0
  76. package/tsconfig.test.json +17 -0
@@ -0,0 +1,125 @@
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
+ }
@@ -0,0 +1,237 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import type * as Brand from "@effect/data/Brand"
5
+ import type { Tag } from "@effect/data/Context"
6
+ import type * as Effect from "@effect/io/Effect"
7
+ import type { Scope } from "@effect/io/Scope"
8
+ import type { PlatformError } from "@effect/platform/Error"
9
+ import type { File } from "@effect/platform/FileSystem/File"
10
+ import * as internal from "@effect/platform/internal/fileSystem"
11
+ import type { Sink } from "@effect/stream/Sink"
12
+ import type { Stream } from "@effect/stream/Stream"
13
+
14
+ /**
15
+ * Represents a size in bytes.
16
+ *
17
+ * @since 1.0.0
18
+ * @category model
19
+ */
20
+ export type Size = Brand.Branded<bigint, "Size">
21
+
22
+ /**
23
+ * @since 1.0.0
24
+ * @category constructor
25
+ */
26
+ export const Size: (bytes: number | bigint) => Size = internal.Size
27
+
28
+ /**
29
+ * @since 1.0.0
30
+ * @category model
31
+ */
32
+ export interface AccessFileOptions {
33
+ readonly ok?: boolean
34
+ readonly readable?: boolean
35
+ readonly writable?: boolean
36
+ }
37
+
38
+ /**
39
+ * @since 1.0.0
40
+ * @category model
41
+ */
42
+ export interface MakeDirectoryOptions {
43
+ readonly recursive?: boolean
44
+ readonly mode?: number
45
+ }
46
+
47
+ /**
48
+ * @since 1.0.0
49
+ * @category model
50
+ */
51
+ export interface MakeTempDirectoryOptions {
52
+ readonly directory?: string
53
+ readonly prefix?: string
54
+ }
55
+
56
+ /**
57
+ * @since 1.0.0
58
+ * @category model
59
+ */
60
+ export interface MakeTempFileOptions {
61
+ readonly directory?: string
62
+ readonly prefix?: string
63
+ }
64
+
65
+ /**
66
+ * @since 1.0.0
67
+ * @category model
68
+ */
69
+ export type OpenFlag =
70
+ | "r"
71
+ | "r+"
72
+ | "w"
73
+ | "wx"
74
+ | "w+"
75
+ | "wx+"
76
+ | "a"
77
+ | "ax"
78
+ | "a+"
79
+ | "ax+"
80
+
81
+ /**
82
+ * @since 1.0.0
83
+ * @category model
84
+ */
85
+ export interface OpenFileOptions {
86
+ readonly flag?: OpenFlag
87
+ readonly mode?: number
88
+ }
89
+
90
+ /**
91
+ * @since 1.0.0
92
+ * @category model
93
+ */
94
+ export interface ReadDirectoryOptions {
95
+ readonly recursive?: boolean
96
+ }
97
+
98
+ /**
99
+ * @since 1.0.0
100
+ * @category model
101
+ */
102
+ export interface RemoveOptions {
103
+ readonly recursive?: boolean
104
+ }
105
+
106
+ /**
107
+ * @since 1.0.0
108
+ * @category model
109
+ */
110
+ export interface SinkOptions extends OpenFileOptions {}
111
+
112
+ /**
113
+ * @since 1.0.0
114
+ * @category model
115
+ */
116
+ export interface StreamOptions {
117
+ bufferSize?: number
118
+ bytesToRead?: Size
119
+ chunkSize?: Size
120
+ offset?: Size
121
+ }
122
+
123
+ /**
124
+ * @since 1.0.0
125
+ * @category model
126
+ */
127
+ export interface WriteFileOptions {
128
+ readonly flag?: OpenFlag
129
+ readonly mode?: number
130
+ }
131
+
132
+ /**
133
+ * @since 1.0.0
134
+ * @category model
135
+ */
136
+ export interface FileSystem {
137
+ readonly access: (
138
+ path: string,
139
+ options?: AccessFileOptions
140
+ ) => Effect.Effect<never, PlatformError, void>
141
+ readonly copyFile: (
142
+ fromPath: string,
143
+ toPath: string
144
+ ) => Effect.Effect<never, PlatformError, void>
145
+ readonly chmod: (
146
+ path: string,
147
+ mode: number
148
+ ) => Effect.Effect<never, PlatformError, void>
149
+ readonly chown: (
150
+ path: string,
151
+ uid: number,
152
+ gid: number
153
+ ) => Effect.Effect<never, PlatformError, void>
154
+ readonly link: (
155
+ fromPath: string,
156
+ toPath: string
157
+ ) => Effect.Effect<never, PlatformError, void>
158
+ readonly makeDirectory: (
159
+ path: string,
160
+ options?: MakeDirectoryOptions
161
+ ) => Effect.Effect<never, PlatformError, void>
162
+ readonly makeTempDirectory: (
163
+ options?: MakeTempDirectoryOptions
164
+ ) => Effect.Effect<never, PlatformError, string>
165
+ readonly makeTempDirectoryScoped: (
166
+ options?: MakeTempDirectoryOptions
167
+ ) => Effect.Effect<Scope, PlatformError, string>
168
+ readonly makeTempFile: (
169
+ options?: MakeTempFileOptions
170
+ ) => Effect.Effect<Scope, PlatformError, File>
171
+ readonly open: (
172
+ path: string,
173
+ options?: OpenFileOptions
174
+ ) => Effect.Effect<Scope, PlatformError, File>
175
+ readonly readDirectory: (
176
+ path: string,
177
+ options?: ReadDirectoryOptions
178
+ ) => Effect.Effect<never, PlatformError, ReadonlyArray<string>>
179
+ readonly readFile: (
180
+ path: string
181
+ ) => Effect.Effect<never, PlatformError, Uint8Array>
182
+ readonly readLink: (
183
+ path: string
184
+ ) => Effect.Effect<never, PlatformError, string>
185
+ readonly realPath: (
186
+ path: string
187
+ ) => Effect.Effect<never, PlatformError, string>
188
+ readonly remove: (
189
+ path: string,
190
+ options?: RemoveOptions
191
+ ) => Effect.Effect<never, PlatformError, void>
192
+ readonly rename: (
193
+ oldPath: string,
194
+ newPath: string
195
+ ) => Effect.Effect<never, PlatformError, void>
196
+ readonly sink: (
197
+ path: string,
198
+ options?: SinkOptions
199
+ ) => Sink<never, PlatformError, Uint8Array, never, void>
200
+ readonly stat: (
201
+ path: string
202
+ ) => Effect.Effect<never, PlatformError, File.Info>
203
+ readonly stream: (
204
+ path: string,
205
+ options?: StreamOptions
206
+ ) => Stream<never, PlatformError, Uint8Array>
207
+ readonly symlink: (
208
+ fromPath: string,
209
+ toPath: string
210
+ ) => Effect.Effect<never, PlatformError, void>
211
+ readonly truncate: (
212
+ path: string,
213
+ length?: Size
214
+ ) => Effect.Effect<never, PlatformError, void>
215
+ readonly utime: (
216
+ path: string,
217
+ atime: Date | number,
218
+ mtime: Date | number
219
+ ) => Effect.Effect<never, PlatformError, void>
220
+ readonly writeFile: (
221
+ path: string,
222
+ data: Uint8Array,
223
+ options?: WriteFileOptions
224
+ ) => Effect.Effect<never, PlatformError, void>
225
+ }
226
+
227
+ /**
228
+ * @since 1.0.0
229
+ * @category tag
230
+ */
231
+ export const FileSystem: Tag<FileSystem, FileSystem> = internal.tag
232
+
233
+ /**
234
+ * @since 1.0.0
235
+ * @category constructor
236
+ */
237
+ export const make: (impl: Omit<FileSystem, "stream" | "sink">) => FileSystem = internal.make
package/src/Runtime.ts ADDED
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Cause from "@effect/io/Cause"
5
+ import type { Effect } from "@effect/io/Effect"
6
+ import * as Exit from "@effect/io/Exit"
7
+
8
+ /**
9
+ * @category model
10
+ * @since 1.0.0
11
+ */
12
+ export interface Teardown {
13
+ <E, A>(exit: Exit.Exit<E, A>, onExit: (code: number) => void): void
14
+ }
15
+
16
+ /**
17
+ * @category teardown
18
+ * @since 1.0.0
19
+ */
20
+ export const defaultTeardown: Teardown = <E, A>(
21
+ exit: Exit.Exit<E, A>,
22
+ onExit: (code: number) => void
23
+ ) => {
24
+ onExit(Exit.isFailure(exit) && !Cause.isInterruptedOnly(exit.cause) ? 1 : 0)
25
+ }
26
+
27
+ /**
28
+ * @category model
29
+ * @since 1.0.0
30
+ */
31
+ export interface RunMain {
32
+ <E, A>(
33
+ effect: Effect<never, E, A>,
34
+ teardown?: Teardown
35
+ ): void
36
+ }
@@ -0,0 +1,105 @@
1
+ import { Tag } from "@effect/data/Context"
2
+ import * as Effect from "@effect/io/Effect"
3
+ import * as Layer from "@effect/io/Layer"
4
+ import type { Console as Console_ } from "@effect/platform/Console"
5
+
6
+ /**
7
+ * @since 1.0.0
8
+ * @category tag
9
+ */
10
+ export const Console = Tag<Console_>()
11
+
12
+ /** @internal */
13
+ const consoleImpl = Console.of({
14
+ assert(condition, ...args) {
15
+ return Effect.sync(() => {
16
+ console.assert(condition, ...args)
17
+ })
18
+ },
19
+ clear() {
20
+ return Effect.sync(() => {
21
+ console.clear()
22
+ })
23
+ },
24
+ count(label) {
25
+ return Effect.sync(() => {
26
+ console.count(label)
27
+ })
28
+ },
29
+ countReset(label) {
30
+ return Effect.sync(() => {
31
+ console.countReset(label)
32
+ })
33
+ },
34
+ debug(...args) {
35
+ return Effect.sync(() => {
36
+ console.debug(...args)
37
+ })
38
+ },
39
+ dir(...args) {
40
+ return Effect.sync(() => {
41
+ console.dir(...args)
42
+ })
43
+ },
44
+ dirxml(...args) {
45
+ return Effect.sync(() => {
46
+ console.dirxml(...args)
47
+ })
48
+ },
49
+ error(...args) {
50
+ return Effect.sync(() => {
51
+ console.error(...args)
52
+ })
53
+ },
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
+ )
63
+ },
64
+ info(...args) {
65
+ return Effect.sync(() => {
66
+ console.info(...args)
67
+ })
68
+ },
69
+ log(...args) {
70
+ return Effect.sync(() => {
71
+ console.log(...args)
72
+ })
73
+ },
74
+ table(tabularData, properties) {
75
+ return Effect.sync(() => {
76
+ console.table(tabularData, properties)
77
+ })
78
+ },
79
+ time(label) {
80
+ return (self) =>
81
+ Effect.acquireUseRelease(
82
+ Effect.sync(() => console.time(label)),
83
+ () => self,
84
+ () => Effect.sync(() => console.timeEnd(label))
85
+ )
86
+ },
87
+ timeLog(label, ...args) {
88
+ return Effect.sync(() => {
89
+ console.timeLog(label, ...args)
90
+ })
91
+ },
92
+ trace(...args) {
93
+ return Effect.sync(() => {
94
+ console.trace(...args)
95
+ })
96
+ },
97
+ warn(...args) {
98
+ return Effect.sync(() => {
99
+ console.warn(...args)
100
+ })
101
+ }
102
+ })
103
+
104
+ /** @internal */
105
+ export const layer = Layer.succeed(Console, consoleImpl)
@@ -0,0 +1,31 @@
1
+ import * as Effect from "@effect/io/Effect"
2
+ import type { Effectify, EffectifyError } from "@effect/platform/Effectify"
3
+
4
+ /** @internal */
5
+ export const effectify: {
6
+ <F extends (...args: Array<any>) => any>(fn: F): Effectify<F, EffectifyError<F>>
7
+ <F extends (...args: Array<any>) => any, E>(
8
+ fn: F,
9
+ onError: (error: EffectifyError<F>, args: Parameters<F>) => E
10
+ ): Effectify<F, E>
11
+ <F extends (...args: Array<any>) => any, E, E2>(
12
+ fn: F,
13
+ onError: (error: EffectifyError<F>, args: Parameters<F>) => E,
14
+ onSyncError: (error: unknown, args: Parameters<F>) => E2
15
+ ): Effectify<F, E | E2>
16
+ } =
17
+ (<A>(fn: Function, onError?: (e: any, args: any) => any, onSyncError?: (e: any, args: any) => any) =>
18
+ (...args: Array<any>) =>
19
+ Effect.async<never, Error, A>((resume) => {
20
+ try {
21
+ fn(...args, (err: Error | null, result: A) => {
22
+ if (err) {
23
+ resume(Effect.fail(onError ? onError(err, args) : err))
24
+ } else {
25
+ resume(Effect.succeed(result))
26
+ }
27
+ })
28
+ } catch (err) {
29
+ resume(onSyncError ? Effect.fail(onSyncError(err, args)) : Effect.die(err))
30
+ }
31
+ })) as any
@@ -0,0 +1,21 @@
1
+ import * as Data from "@effect/data/Data"
2
+ import type * as Error from "@effect/platform/Error"
3
+
4
+ /** @internal */
5
+ export const PlatformErrorTypeId: Error.PlatformErrorTypeId = Symbol.for(
6
+ "@effect/platform/Error/PlatformErrorTypeId"
7
+ ) as Error.PlatformErrorTypeId
8
+
9
+ const make = <A extends Error.PlatformError>(tag: A["_tag"]) =>
10
+ (props: Omit<A, Error.PlatformError.ProvidedFields>): A =>
11
+ Data.struct({
12
+ [PlatformErrorTypeId]: PlatformErrorTypeId,
13
+ _tag: tag,
14
+ ...props
15
+ } as A)
16
+
17
+ /** @internal */
18
+ export const badArgument = make<Error.BadArgument>("BadArgument")
19
+
20
+ /** @internal */
21
+ export const systemError = make<Error.SystemError>("SystemError")
@@ -0,0 +1,60 @@
1
+ import { Tag } from "@effect/data/Context"
2
+ import { pipe } from "@effect/data/Function"
3
+ import * as Option from "@effect/data/Option"
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"
7
+ import * as Sink from "@effect/stream/Sink"
8
+ import * as Stream from "@effect/stream/Stream"
9
+
10
+ /** @internal */
11
+ export const tag = Tag<FileSystem>()
12
+
13
+ /** @internal */
14
+ export const Size = (bytes: number | bigint) => typeof bytes === "bigint" ? bytes as Size_ : BigInt(bytes) as Size_
15
+
16
+ /** @internal */
17
+ export const make = (impl: Omit<FileSystem, "stream" | "sink">): FileSystem => {
18
+ return tag.of({
19
+ ...impl,
20
+ stream: (path, options) =>
21
+ pipe(
22
+ impl.open(path, { flag: "r" }),
23
+ Effect.map((file) => stream(file, options)),
24
+ Stream.unwrapScoped
25
+ ),
26
+ sink: (path, options) =>
27
+ pipe(
28
+ impl.open(path, { flag: "w", ...options }),
29
+ Effect.map((file) => Sink.forEach((_: Uint8Array) => file.writeAll(_))),
30
+ Sink.unwrapScoped
31
+ )
32
+ })
33
+ }
34
+
35
+ /** @internal */
36
+ const stream = (file: File, {
37
+ bufferSize = 4,
38
+ bytesToRead,
39
+ chunkSize = Size(16n * 1024n),
40
+ offset = Size(0n)
41
+ }: StreamOptions = {}) =>
42
+ Stream.bufferChunks(
43
+ Stream.unfoldEffect(offset, (position) => {
44
+ if (bytesToRead !== undefined && bytesToRead <= position - offset) {
45
+ return Effect.succeedNone()
46
+ }
47
+
48
+ const toRead = bytesToRead !== undefined && bytesToRead - (position - offset) < chunkSize
49
+ ? bytesToRead - (position - offset)
50
+ : chunkSize
51
+
52
+ return pipe(
53
+ file.readAlloc(toRead as Size_, { offset: position }),
54
+ Effect.map(
55
+ Option.map((buf) => [buf, Size(position + BigInt(buf.length))] as const)
56
+ )
57
+ )
58
+ }),
59
+ bufferSize
60
+ )
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "build/esm",
5
+ "declarationDir": "build/dts",
6
+ "tsBuildInfoFile": "build/tsbuildinfo/esm.tsbuildinfo",
7
+ "rootDir": "src"
8
+ },
9
+ "include": ["src/**/*.ts"]
10
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "tsBuildInfoFile": "build/tsbuildinfo/examples.tsbuildinfo",
5
+ "rootDir": "examples",
6
+ "module": "CommonJS",
7
+ "outDir": "build/examples"
8
+ },
9
+ "include": ["examples/**/*.ts"],
10
+ "references": [{ "path": "./tsconfig.build.json" }]
11
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "tsBuildInfoFile": "build/tsbuildinfo/tsconfig.tsbuildinfo"
5
+ },
6
+ "references": [
7
+ { "path": "./tsconfig.build.json" },
8
+ { "path": "./tsconfig.test.json" },
9
+ { "path": "./tsconfig.examples.json" }
10
+ ]
11
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "build/test",
5
+ "declarationDir": "build/test-dts",
6
+ "tsBuildInfoFile": "build/tsbuildinfo/test.tsbuildinfo",
7
+ "rootDir": "test",
8
+ "noEmit": true,
9
+ "types": ["vitest/globals"]
10
+ },
11
+ "include": ["test/**/*.ts"],
12
+ "references": [
13
+ {
14
+ "path": "./tsconfig.build.json"
15
+ }
16
+ ]
17
+ }