Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Commit 96a8aa2

Browse files
committed
README <3
1 parent 462d2f4 commit 96a8aa2

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

README.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
IPFS unixFS Engine
22
===================
33

4-
> Import data into an IPFS DAG Service.
4+
> Import & Export data to/from an [IPFS DAG Service][]
55
66
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
77
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
@@ -74,41 +74,47 @@ When run, the stat of DAG Node is outputted for each file on data event until th
7474

7575
```
7676
{ multihash: <Buffer 12 20 bd e2 2b 57 3f 6f bd 7c cc 5a 11 7f 28 6c a2 9a 9f c0 90 e1 d4 16 d0 5f 42 81 ec 0c 2a 7f 7f 93>,
77-
Size: 39243,
77+
size: 39243,
7878
path: '/tmp/foo/bar' }
7979
8080
{ multihash: <Buffer 12 20 bd e2 2b 57 3f 6f bd 7c cc 5a 11 7f 28 6c a2 9a 9f c0 90 e1 d4 16 d0 5f 42 81 ec 0c 2a 7f 7f 93>,
81-
Size: 59843,
81+
size: 59843,
8282
path: '/tmp/foo/quxx' }
8383
8484
{ multihash: <Buffer 12 20 bd e2 2b 57 3f 6f bd 7c cc 5a 11 7f 28 6c a2 9a 9f c0 90 e1 d4 16 d0 5f 42 81 ec 0c 2a 7f 7f 93>,
85-
Size: 93242,
85+
size: 93242,
8686
path: '/tmp/foo' }
8787
8888
{ multihash: <Buffer 12 20 bd e2 2b 57 3f 6f bd 7c cc 5a 11 7f 28 6c a2 9a 9f c0 90 e1 d4 16 d0 5f 42 81 ec 0c 2a 7f 7f 93>,
89-
Size: 94234,
89+
size: 94234,
9090
path: '/tmp' }
9191
9292
```
9393

94-
## API
94+
## Importer API
9595

9696
```js
9797
const Importer = require('ipfs-unixfs-engine').importer
9898
```
9999

100100
### const add = new Importer(dag)
101101

102-
The importer is a duplex stream in object mode that writes inputs of tuples
103-
of path and readable streams of data. You can stream an array of files to the
104-
importer, just call the 'end' function to signal that you are done inputting file/s.
105-
Listen to the 'data' for the returned informtion 'multihash, size and path' for
106-
each file added. Listen to the 'end' event from the stream to know when the
107-
importer has finished importing files. Input file paths with directory structure
108-
will preserve the hierarchy in the dag node.
102+
The importer is a object Transform stream that accepts objects of the form
103+
104+
```js
105+
{
106+
path: 'a name',
107+
content: (Buffer or Readable stream)
108+
}
109+
```
110+
111+
The stream will output IPFS DAG Node stats for the nodes it as added to the DAG
112+
Service. When stats on a node are emitted they are guaranteed to have been
113+
written into the DAG Service's storage mechanism.
114+
115+
The input's file paths and directory structure will be preserved in the DAG
116+
Nodes.
109117

110-
Uses the [DAG Service](https://github.com/vijayee/js-ipfs-merkle-dag/) instance
111-
`dagService`.
112118

113119
## Example Exporter
114120

@@ -133,22 +139,27 @@ exportEvent.on('data', (result) => {
133139
}
134140
```
135141

136-
##API
142+
## Exporter: API
137143
```js
138144
const Importer = require('ipfs-unixfs-engine').exporter
139145
```
140146

141-
The exporter is a readable stream in object mode that returns an object ```{ content: stream, path: 'path' }``` by the multihash of the file from the dag service.
147+
The exporter is a readable stream in object mode that returns an object ```{
148+
content: stream, path: 'path' }``` by the multihash of the file from the dag
149+
service.
142150

143151

144-
## install
152+
## Install
145153

146154
With [npm](https://npmjs.org/) installed, run
147155

148156
```
149157
$ npm install ipfs-unixfs-engine
150158
```
151159

152-
## license
160+
## License
153161

154162
ISC
163+
164+
165+
[IPFS DAG Service]: https://github.com/vijayee/js-ipfs-merkle-dag/

0 commit comments

Comments
 (0)