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

Commit 91d5871

Browse files
authored
Merge pull request #6 from ipfs/refactor-pull-stream-invocations
chore: replace last few pull.* invocations with *
2 parents cb3f6c5 + bdeea54 commit 91d5871

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ And write the importing logic:
5050

5151
```js
5252
const importer = require('ipfs-unixfs-importer')
53-
const pull = require('pull-stream')
53+
const pull = require('pull-stream/pull')
54+
const values = require('pull-stream/sources/values')
55+
const collect = require('pull-stream/sinks/collect')
5456

5557
// Import path /tmp/foo/bar
5658
pull(
57-
pull.values([{
59+
values([{
5860
path: '/tmp/foo/bar',
5961
content: fs.createReadStream(file)
6062
}, {
@@ -68,7 +70,7 @@ pull(
6870
importer(<ipld-resolver instance>, <options>),
6971

7072
// Handle the error and do something with the results
71-
pull.collect((err, files) => {
73+
collect((err, files) => {
7274
console.info(files)
7375
})
7476
)

test/builder-dir-sharding.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('builder: directory sharding', function () {
4545
values([
4646
{
4747
path: 'a/b',
48-
content: pull.values([Buffer.from('i have the best bytes')])
48+
content: values([Buffer.from('i have the best bytes')])
4949
}
5050
]),
5151
importer(ipld, options),

test/import-export-nested-dir.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ describe('import and export: directory', () => {
3333

3434
pull(
3535
values([
36-
{ path: 'a/b/c/d/e', content: pull.values([Buffer.from('banana')]) },
37-
{ path: 'a/b/c/d/f', content: pull.values([Buffer.from('strawberry')]) },
38-
{ path: 'a/b/g', content: pull.values([Buffer.from('ice')]) },
39-
{ path: 'a/b/h', content: pull.values([Buffer.from('cream')]) }
36+
{ path: 'a/b/c/d/e', content: values([Buffer.from('banana')]) },
37+
{ path: 'a/b/c/d/f', content: values([Buffer.from('strawberry')]) },
38+
{ path: 'a/b/g', content: values([Buffer.from('ice')]) },
39+
{ path: 'a/b/h', content: values([Buffer.from('cream')]) }
4040
]),
4141
importer(ipld),
4242
collect((err, files) => {

test/importer.spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ chai.use(require('dirty-chai'))
1010
const expect = chai.expect
1111
const spy = require('sinon/lib/sinon/spy')
1212
const pull = require('pull-stream/pull')
13+
const empty = require('pull-stream/sources/empty')
1314
const once = require('pull-stream/sources/once')
1415
const values = require('pull-stream/sources/values')
1516
const collect = require('pull-stream/sinks/collect')
17+
const onEnd = require('pull-stream/sinks/on-end')
1618
const CID = require('cids')
1719
const IPLD = require('ipld')
1820
const loadFixture = require('aegir/fixtures')
@@ -153,7 +155,7 @@ const checkLeafNodeTypes = (ipld, options, expected, done) => {
153155
const checkNodeLinks = (ipld, options, expected, done) => {
154156
waterfall([
155157
(cb) => pull(
156-
pull.once({
158+
once({
157159
path: '/foo',
158160
content: Buffer.alloc(100).fill(1)
159161
}),
@@ -258,7 +260,7 @@ strategies.forEach((strategy) => {
258260
content: 'banana'
259261
}]),
260262
importer(ipld, options),
261-
pull.onEnd((err) => {
263+
onEnd((err) => {
262264
expect(err).to.exist()
263265
done()
264266
})
@@ -267,7 +269,7 @@ strategies.forEach((strategy) => {
267269

268270
it('doesn\'t yield anything on empty source', (done) => {
269271
pull(
270-
pull.empty(),
272+
empty(),
271273
importer(ipld, options),
272274
collect((err, nodes) => {
273275
expect(err).to.not.exist()
@@ -280,7 +282,7 @@ strategies.forEach((strategy) => {
280282
pull(
281283
values([{
282284
path: 'emptyfile',
283-
content: pull.empty()
285+
content: empty()
284286
}]),
285287
importer(ipld, options),
286288
collect((err, nodes) => {
@@ -306,7 +308,7 @@ strategies.forEach((strategy) => {
306308
}
307309
]),
308310
importer(ipld, options),
309-
pull.onEnd((err) => {
311+
onEnd((err) => {
310312
expect(err).to.exist()
311313
expect(err.message).to.be.eql('detected more than one root')
312314
done()

0 commit comments

Comments
 (0)