@fncts/node 0.0.1

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/fs/api.d.ts ADDED
@@ -0,0 +1,150 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import { HKT } from "@fncts/typelevel/HKT";
5
+ import { Newtype } from "@fncts/base/data/Newtype";
6
+ import { IO, FIO } from "@fncts/io/IO";
7
+ import { Stream } from "@fncts/io/Stream";
8
+ import { Byte } from "@fncts/base/data/Byte";
9
+ import { Sink } from "@fncts/io/Sink/definition";
10
+ import { Maybe } from "@fncts/base/data/Maybe";
11
+ import { Conc } from "@fncts/base/collection/immutable/Conc";
12
+ import { Channel } from "@fncts/io/Channel";
13
+ import * as fs from "fs";
14
+ declare type ErrnoException = NodeJS.ErrnoException;
15
+ interface FileDescriptorN extends HKT {
16
+ readonly [HKT.T]: FileDescriptor;
17
+ }
18
+ export interface FileDescriptor extends Newtype<{
19
+ readonly FileDescriptor: unique symbol;
20
+ }, number> {
21
+ }
22
+ export declare const FileDescriptor: import("@fncts/base/data/Newtype").NewtypeIso<FileDescriptorN>;
23
+ export declare function access(path: fs.PathLike, mode: number | undefined): FIO<ErrnoException, void>;
24
+ export declare function appendFile(path: fs.PathLike | FileDescriptor, data: string | Buffer, options?: fs.WriteFileOptions): FIO<ErrnoException, void>;
25
+ export declare function chmod(path: fs.PathLike, mode: fs.Mode): FIO<ErrnoException, void>;
26
+ export declare function close(fd: FileDescriptor): FIO<ErrnoException, void>;
27
+ export declare function chown(path: fs.PathLike, uid: number, gid: number): FIO<ErrnoException, void>;
28
+ export declare function copyFile(src: fs.PathLike, dest: fs.PathLike, flags: number): FIO<ErrnoException, void>;
29
+ interface CreateReadStreamOptions {
30
+ chunkSize?: number;
31
+ flags?: fs.OpenMode;
32
+ mode?: string | number;
33
+ start?: number;
34
+ end?: number;
35
+ }
36
+ export declare function createReadStream(path: fs.PathLike, options?: CreateReadStreamOptions): Stream<unknown, ErrnoException, Byte>;
37
+ interface CreateWriteSinkOptions {
38
+ flags?: fs.OpenMode;
39
+ mode?: string | number;
40
+ start?: number;
41
+ }
42
+ export declare function createWriteSink<InErr>(path: fs.PathLike, options?: CreateWriteSinkOptions): Sink<unknown, InErr | ErrnoException, Byte, never, void>;
43
+ export declare function fchmod(fd: FileDescriptor, mode: fs.Mode): FIO<ErrnoException, void>;
44
+ export declare function fchown(fd: FileDescriptor, uid: number, gid: number): FIO<ErrnoException, void>;
45
+ export declare function fdatasync(fd: FileDescriptor): FIO<ErrnoException, void>;
46
+ export declare function fstat(fd: FileDescriptor): FIO<ErrnoException, fs.Stats>;
47
+ export declare function fsync(fd: FileDescriptor): FIO<ErrnoException, void>;
48
+ export declare function ftruncate(fd: FileDescriptor, len: number): FIO<ErrnoException, void>;
49
+ export declare function futimes(fd: FileDescriptor, atime: string | number | Date, mtime: string | number | Date): FIO<ErrnoException, void>;
50
+ export declare function lchmod(path: fs.PathLike, mode: fs.Mode): FIO<ErrnoException, void>;
51
+ export declare function lchown(path: fs.PathLike, uid: number, gid: number): FIO<ErrnoException, void>;
52
+ export declare function lutimes(path: fs.PathLike, atime: string | number | Date, mtime: string | number | Date): FIO<ErrnoException, void>;
53
+ export declare function link(path: fs.PathLike, newPath: fs.PathLike): FIO<ErrnoException, void>;
54
+ export declare function lstat(path: fs.PathLike): FIO<ErrnoException, fs.Stats>;
55
+ export declare function mkdir(path: fs.PathLike, options?: {
56
+ recursive?: boolean;
57
+ mode?: fs.Mode;
58
+ }): FIO<ErrnoException, Maybe<string>>;
59
+ export declare function mkdtemp(prefix: string, options?: {
60
+ encoding?: BufferEncoding;
61
+ }): FIO<ErrnoException, string>;
62
+ export declare function open(path: fs.PathLike, flags: fs.OpenMode, mode?: string | number): FIO<NodeJS.ErrnoException, FileDescriptor>;
63
+ export declare class Dir {
64
+ readonly path: string;
65
+ private readonly _dir;
66
+ constructor(dir: fs.Dir);
67
+ close(): FIO<ErrnoException, void>;
68
+ read(): FIO<ErrnoException, Maybe<fs.Dirent>>;
69
+ }
70
+ export declare function opendir(path: fs.PathLike, options?: fs.OpenDirOptions): FIO<ErrnoException, Dir>;
71
+ export declare function read(fd: FileDescriptor, length: number, position?: number): FIO<ErrnoException, readonly [number, Buffer]>;
72
+ export declare function readFile(file: fs.PathOrFileDescriptor, options: {
73
+ flag?: string;
74
+ encoding: BufferEncoding;
75
+ }): FIO<ErrnoException, string>;
76
+ export declare function readFile(file: fs.PathOrFileDescriptor, options?: {
77
+ flag?: string;
78
+ }): FIO<ErrnoException, Buffer>;
79
+ export declare function readdir(path: fs.PathLike, options?: {
80
+ encoding?: BufferEncoding;
81
+ withFileTypes?: false;
82
+ }): FIO<ErrnoException, ReadonlyArray<string>>;
83
+ export declare function readdir(path: fs.PathLike, options: {
84
+ encoding: "buffer";
85
+ withFileTypes?: false;
86
+ }): FIO<ErrnoException, ReadonlyArray<Buffer>>;
87
+ export declare function readdir(path: fs.PathLike, options: {
88
+ encoding?: BufferEncoding;
89
+ withFileTypes: true;
90
+ }): FIO<ErrnoException, ReadonlyArray<Dir>>;
91
+ export declare function realpath(path: fs.PathLike, options?: {
92
+ encoding?: BufferEncoding;
93
+ }): FIO<ErrnoException, string>;
94
+ export declare function realpath(path: fs.PathLike, options: {
95
+ encoding: "buffer";
96
+ }): FIO<ErrnoException, Buffer>;
97
+ export declare function realpathNative(path: fs.PathLike, options?: {
98
+ encoding?: BufferEncoding;
99
+ }): FIO<ErrnoException, string>;
100
+ export declare function realpathNative(path: fs.PathLike, options: {
101
+ encoding: "buffer";
102
+ }): FIO<ErrnoException, Buffer>;
103
+ export declare function rename(oldPath: fs.PathLike, newPath: fs.PathLike): FIO<ErrnoException, void>;
104
+ export declare function rm(path: fs.PathLike, options?: fs.RmOptions): FIO<ErrnoException, void>;
105
+ export declare function rmdir(path: fs.PathLike, options?: fs.RmDirOptions): FIO<ErrnoException, void>;
106
+ export declare function stat(path: fs.PathLike, options?: {
107
+ bigint?: false;
108
+ }): FIO<ErrnoException, fs.Stats>;
109
+ export declare function stat(path: fs.PathLike, options: {
110
+ bigint: true;
111
+ }): FIO<ErrnoException, fs.BigIntStats>;
112
+ export declare function symlink(target: fs.PathLike, path: fs.PathLike): FIO<ErrnoException, void>;
113
+ export declare function truncate(path: fs.PathLike, len?: number): FIO<ErrnoException, void>;
114
+ export declare function unlink(path: fs.PathLike): FIO<ErrnoException, void>;
115
+ export declare function utimes(path: fs.PathLike, atime: string | number | Date, mtime: string | number | Date): FIO<ErrnoException, void>;
116
+ export declare function write(fd: FileDescriptor, buffer: Conc<Byte>, position?: number): FIO<ErrnoException, number>;
117
+ export interface WriteFileOptions {
118
+ readonly encoding?: BufferEncoding;
119
+ readonly mode?: fs.Mode;
120
+ readonly flag?: string;
121
+ }
122
+ export declare function writeFile(file: fs.PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): IO<unknown, ErrnoException, void>;
123
+ export declare function writev(fd: FileDescriptor, buffers: ReadonlyArray<Uint8Array>, position?: number): FIO<ErrnoException, number>;
124
+ export declare function watch(filename: fs.PathLike, options: {
125
+ persistent?: boolean;
126
+ recursive?: boolean;
127
+ encoding: "buffer";
128
+ }): Stream<unknown, Error, {
129
+ eventType: "rename" | "change";
130
+ filename: Buffer;
131
+ }>;
132
+ export declare function watch(filename: fs.PathLike, options?: {
133
+ persistent?: boolean;
134
+ recursive?: boolean;
135
+ encoding?: BufferEncoding;
136
+ }): Stream<unknown, Error, {
137
+ eventType: "rename" | "change";
138
+ filename: string;
139
+ }>;
140
+ export declare function watchFile(filename: fs.PathLike, options: {
141
+ bigint: true;
142
+ persistent?: boolean;
143
+ interval?: number;
144
+ }): Stream<unknown, never, [fs.BigIntStats, fs.BigIntStats]>;
145
+ export declare function watchFile(filename: fs.PathLike, options?: {
146
+ bigint?: false;
147
+ persistent?: boolean;
148
+ interval?: number;
149
+ }): Stream<unknown, never, [fs.Stats, fs.Stats]>;
150
+ export {};
package/fs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./fs/api.js";
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@fncts/node",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "@fncts/io": "0.0.8"
6
+ },
7
+ "exports": {
8
+ "./*": {
9
+ "import": "./_mjs/*.mjs",
10
+ "require": "./_cjs/*.cjs"
11
+ }
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ }
16
+ }