-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapi.ts
More file actions
104 lines (96 loc) · 2.33 KB
/
Copy pathapi.ts
File metadata and controls
104 lines (96 loc) · 2.33 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import type {
WriterOptions,
EncoderSettings,
WritableBlockStream,
BlockWriter,
View as FileWriterView,
Writer as FileWriter,
Options as FileWriterOptions,
State as FileWriterSate,
CloseOptions,
Chunker,
LayoutEngine,
Block,
MultihashHasher,
MultihashDigest,
EncodedFile,
} from "./file.js"
import type {
DirectoryEntry,
Writer as DirectoryWriter,
View as DirectoryWriterView,
Options as DirectoryWriterOptions,
State as DirectoryWriterState,
} from "./directory.js"
import { Metadata, FileLink } from "./unixfs.js"
export type {
WriterOptions,
CloseOptions,
EncoderSettings,
FileWriterOptions,
FileWriterView,
FileWriter,
FileWriterSate,
EncodedFile,
BlockWriter,
WritableBlockStream,
DirectoryWriterView,
DirectoryWriter,
DirectoryWriterOptions,
DirectoryWriterState,
DirectoryEntry,
Chunker,
LayoutEngine,
Block,
MultihashHasher,
MultihashDigest,
Metadata,
FileLink,
}
/**
*
*/
export interface Writer {
/**
* Closes this writer and corresponding
*/
close(options?: CloseOptions): Promise<this>
}
/**
* Represents [UnixFS][] DAG writer with a filesystem like API for
* encoding files & directories into a [UnixFS][] DAG.
*
* [block]:https://ipld.io/docs/intro/primer/#blocks-vs-nodes
* [UnixFS]:https://github.com/ipfs/specs/blob/main/UNIXFS.md
*/
export interface View<L extends unknown = unknown> extends Writer {
/**
* Underlaying stream where [UnixFS][] blocks will be written into.
*/
readonly writer: BlockWriter
/**
* Encoder configuration of this writer.
*/
readonly settings: EncoderSettings<L>
/**
* Creates new file writer that will write blocks into the same underlying
* stream. It is mostly convinience function for passing same stream and
* encoder configuration.
*/
createFileWriter<Layout>(
settings?: WriterOptions<Layout>
): FileWriterView<L | Layout>
/**
* Creates new directory writer that will write blocks into the same
* underlying stream as this writer. It is mostly convinienc function for
* passing same stream and encoder configuration.
*
*/
createDirectoryWriter<Layout>(
settings?: WriterOptions<Layout>
): DirectoryWriterView<L | Layout>
}
export interface Options<Layout extends unknown = unknown> {
writable: WritableBlockStream
settings?: EncoderSettings<Layout>
}