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

Commit 3ef4ea1

Browse files
committed
chore: remove exporter code
1 parent 60ae4d5 commit 3ef4ea1

22 files changed

+57
-1891
lines changed

README.md

Lines changed: 36 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
IPFS unixFS Engine
2-
==================
1+
# ipfs-unixfs-importer
32

43
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
54
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
65
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
76
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
8-
[![Jenkins](https://ci.ipfs.team/buildStatus/icon?job=ipfs/js-ipfs-unixfs-engine/master)](https://ci.ipfs.team/job/ipfs/job/js-ipfs-unixfs-engine/job/master/)
9-
[![Codecov](https://codecov.io/gh/ipfs/js-ipfs-unixfs-engine/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/js-ipfs-unixfs-engine)
10-
[![Dependency Status](https://david-dm.org/ipfs/js-ipfs-unixfs-engine.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-unixfs-engine)
7+
[![Jenkins](https://ci.ipfs.team/buildStatus/icon?job=ipfs/js-ipfs-unixfs-importer/master)](https://ci.ipfs.team/job/ipfs/job/js-ipfs-unixfs-importer/job/master/)
8+
[![Codecov](https://codecov.io/gh/ipfs/js-ipfs-unixfs-importer/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/js-ipfs-unixfs-importer)
9+
[![Dependency Status](https://david-dm.org/ipfs/js-ipfs-unixfs-importer.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-unixfs-importer)
1110
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
1211
![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square)
1312
![](https://img.shields.io/badge/Node.js-%3E%3D8.0.0-orange.svg?style=flat-square)
@@ -22,26 +21,21 @@ IPFS unixFS Engine
2221

2322
- [Install](#install)
2423
- [Usage](#usage)
25-
- [Example Importer](#example-importer)
26-
- [Importer API](#importer-api)
27-
- [const add = new Importer(dag)](#const-add--new-importerdag)
28-
- [Example Exporter](#example-exporter)
29-
- [Exporter: API](#exporter-api)
30-
- [new Exporter(hash, dagService)](#new-exporterhash-dagservice)
24+
- [Example](#example)
25+
- [API](#api)
26+
- [const add = importer(dag, options)](#const-import--importerdag--options)
3127
- [Contribute](#contribute)
3228
- [License](#license)
3329

3430
## Install
3531

3632
```
37-
> npm install ipfs-unixfs-engine
33+
> npm install ipfs-unixfs-importer
3834
```
3935

4036
## Usage
4137

42-
### Importer
43-
44-
#### Importer example
38+
### Example
4539

4640
Let's create a little directory to import:
4741

@@ -55,36 +49,32 @@ Let's create a little directory to import:
5549
And write the importing logic:
5650

5751
```js
58-
const Importer = require('ipfs-unixfs-engine').Importer
59-
60-
// You need to create and pass an ipld-resolve instance
61-
// https://github.com/ipld/js-ipld-resolver
62-
const filesAddStream = new Importer(<ipld-resolver instance>)
63-
64-
// An array to hold the return of nested file/dir info from the importer
65-
// A root DAG Node is received upon completion
66-
67-
const res = []
52+
const importer = require('ipfs-unixfs-importer')
53+
const pull = require('pull-stream')
6854

6955
// Import path /tmp/foo/bar
70-
const rs = fs.createReadStream(file)
71-
const rs2 = fs.createReadStream(file2)
72-
const input = { path: '/tmp/foo/bar', content: rs }
73-
const input2 = { path: '/tmp/foo/quxx', content: rs2 }
74-
75-
// Listen for the data event from the importer stream
76-
filesAddStream.on('data', (info) => res.push(info))
77-
78-
// The end event of the stream signals that the importer is done
79-
filesAddStream.on('end', () => console.log('Finished filesAddStreaming files!'))
80-
81-
// Calling write on the importer to filesAddStream the file/object tuples
82-
filesAddStream.write(input)
83-
filesAddStream.write(input2)
84-
filesAddStream.end()
56+
pull(
57+
pull.values([{
58+
path: '/tmp/foo/bar',
59+
content: fs.createReadStream(file)
60+
}, {
61+
path: '/tmp/foo/quxx',
62+
content: fs.createReadStream(file2)
63+
}
64+
}]),
65+
66+
// You need to create and pass an ipld-resolve instance
67+
// https://github.com/ipld/js-ipld-resolver
68+
importer(<ipld-resolver instance>, <options>),
69+
70+
// Handle the error and do something with the results
71+
pull.collect((err, files) => {
72+
console.info(files)
73+
})
74+
)
8575
```
8676

87-
When run, the stat of DAG Node is outputted for each file on data event until the root:
77+
When run, the stat of DAGNode is outputted for each file on data event until the root:
8878

8979
```js
9080
{ 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>,
@@ -105,20 +95,20 @@ When run, the stat of DAG Node is outputted for each file on data event until th
10595

10696
```
10797

108-
#### Importer API
98+
#### API
10999

110100
```js
111-
const Importer = require('ipfs-unixfs-engine').Importer
101+
const importer = require('ipfs-unixfs-importer')
112102
```
113103

114-
#### const import = new Importer(dag [, options])
104+
#### const import = importer(dag [, options])
115105

116106
The `import` object is a duplex pull stream that takes objects of the form:
117107

118108
```js
119109
{
120110
path: 'a name',
121-
content: (Buffer or Readable stream)
111+
content: (Buffer, pull-stream emitting Buffers or a Readable stream)
122112
}
123113
```
124114

@@ -152,85 +142,14 @@ The input's file paths and directory structure will be preserved in the [`dag-pb
152142
- `rawLeaves` (boolean, defaults to false): When a file would span multiple DAGNodes, if this is true the leaf nodes will not be wrapped in `UnixFS` protobufs and will instead contain the raw file bytes
153143
- `leafType` (string, defaults to `'file'`) what type of UnixFS node leaves should be - can be `'file'` or `'raw'` (ignored when `rawLeaves` is `true`)
154144

155-
### Exporter
156-
157-
#### Exporter example
158-
159-
```js
160-
// Create an export source pull-stream cid or ipfs path you want to export and a
161-
// <dag or ipld-resolver instance> to fetch the file from
162-
const filesStream = Exporter(<cid or ipfsPath>, <dag or ipld-resolver instance>)
163-
164-
// Pipe the return stream to console
165-
filesStream.on('data', (file) => file.content.pipe(process.stdout))
166-
```
167-
168-
#### Exporter API
169-
170-
```js
171-
const Exporter = require('ipfs-unixfs-engine').Exporter
172-
```
173-
174-
### new Exporter(<cid or ipfsPath>, <dag or ipld-resolver>, <options>)
175-
176-
Uses the given [dag API][] or an [ipld-resolver instance][] to fetch an IPFS [UnixFS][] object(s) by their multiaddress.
177-
178-
Creates a new readable stream in object mode that outputs objects of the form
179-
180-
```js
181-
{
182-
path: 'a name',
183-
content: (Buffer or Readable stream)
184-
}
185-
```
186-
187-
#### `offset` and `length`
188-
189-
`offset` and `length` arguments can optionally be passed to the reader function. These will cause the returned stream to only emit bytes starting at `offset` and with length of `length`.
190-
191-
See [the tests](test/reader.js) for examples of using these arguments.
192-
193-
```js
194-
const exporter = require('ipfs-unixfs-engine').exporter
195-
const pull = require('pull-stream')
196-
const drain = require('pull-stream/sinks/drain')
197-
198-
pull(
199-
exporter(cid, ipldResolver, {
200-
offset: 0,
201-
length: 10
202-
})
203-
drain((file) => {
204-
// file.content is a pull stream containing only the first 10 bytes of the file
205-
})
206-
)
207-
```
208-
209-
#### Errors
210-
211-
Errors are received by [pull-stream][] sinks.
212-
213-
```js
214-
const exporter = require('ipfs-unixfs-engine').exporter
215-
const pull = require('pull-stream')
216-
const collect = require('pull-stream/sinks/collect')
217-
218-
pull(
219-
exporter(cid, ipldResolver)
220-
collect((error, chunks) => {
221-
// handle the error
222-
})
223-
)
224-
```
225-
226145
[dag API]: https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md
227146
[ipld-resolver instance]: https://github.com/ipld/js-ipld-resolver
228147
[UnixFS]: https://github.com/ipfs/specs/tree/master/unixfs
229148
[pull-stream]: https://www.npmjs.com/package/pull-stream
230149

231150
## Contribute
232151

233-
Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs-unixfs-engine/issues)!
152+
Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs-unixfs-importer/issues)!
234153

235154
This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
236155

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "ipfs-unixfs-engine",
2+
"name": "ipfs-unixfs-importer",
33
"version": "0.34.0",
4-
"description": "JavaScript implementation of the unixfs Engine used by IPFS",
4+
"description": "JavaScript implementation of the UnixFs importer used by IPFS",
55
"leadMaintainer": "Alex Potsides <[email protected]>",
66
"main": "src/index.js",
77
"browser": {
@@ -22,26 +22,27 @@
2222
},
2323
"repository": {
2424
"type": "git",
25-
"url": "git+https://github.com/ipfs/js-ipfs-unixfs-engine.git"
25+
"url": "git+https://github.com/ipfs/js-ipfs-unixfs-importer.git"
2626
},
2727
"keywords": [
2828
"IPFS"
2929
],
3030
"license": "MIT",
3131
"bugs": {
32-
"url": "https://github.com/ipfs/js-ipfs-unixfs-engine/issues"
32+
"url": "https://github.com/ipfs/js-ipfs-unixfs-importer/issues"
3333
},
3434
"engines": {
3535
"node": ">=8.0.0",
3636
"npm": ">=3.0.0"
3737
},
38-
"homepage": "https://github.com/ipfs/js-ipfs-unixfs-engine#readme",
38+
"homepage": "https://github.com/ipfs/js-ipfs-unixfs-importer#readme",
3939
"devDependencies": {
4040
"aegir": "^17.0.0",
4141
"chai": "^4.2.0",
4242
"dirty-chai": "^2.0.1",
4343
"ipfs-block-service": "~0.15.1",
4444
"ipfs-repo": "~0.25.0",
45+
"ipfs-unixfs-exporter": "~0.34.0",
4546
"ipld": "~0.20.0",
4647
"mkdirp": "~0.5.1",
4748
"multihashes": "~0.4.14",

src/exporter/dir-flat.js

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/exporter/dir-hamt-sharded.js

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/exporter/extract-data-from-block.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)