Skip to content

Commit

Permalink
Merge pull request #6 from ipfs/refactor-pull-stream-invocations
Browse files Browse the repository at this point in the history
chore: replace last few pull.* invocations with *
  • Loading branch information
achingbrain authored Dec 19, 2018
2 parents cb3f6c5 + bdeea54 commit 91d5871
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ And write the importing logic:

```js
const importer = require('ipfs-unixfs-importer')
const pull = require('pull-stream')
const pull = require('pull-stream/pull')
const values = require('pull-stream/sources/values')
const collect = require('pull-stream/sinks/collect')

// Import path /tmp/foo/bar
pull(
pull.values([{
values([{
path: '/tmp/foo/bar',
content: fs.createReadStream(file)
}, {
Expand All @@ -68,7 +70,7 @@ pull(
importer(<ipld-resolver instance>, <options>),

// Handle the error and do something with the results
pull.collect((err, files) => {
collect((err, files) => {
console.info(files)
})
)
Expand Down
2 changes: 1 addition & 1 deletion test/builder-dir-sharding.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('builder: directory sharding', function () {
values([
{
path: 'a/b',
content: pull.values([Buffer.from('i have the best bytes')])
content: values([Buffer.from('i have the best bytes')])
}
]),
importer(ipld, options),
Expand Down
8 changes: 4 additions & 4 deletions test/import-export-nested-dir.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ describe('import and export: directory', () => {

pull(
values([
{ path: 'a/b/c/d/e', content: pull.values([Buffer.from('banana')]) },
{ path: 'a/b/c/d/f', content: pull.values([Buffer.from('strawberry')]) },
{ path: 'a/b/g', content: pull.values([Buffer.from('ice')]) },
{ path: 'a/b/h', content: pull.values([Buffer.from('cream')]) }
{ path: 'a/b/c/d/e', content: values([Buffer.from('banana')]) },
{ path: 'a/b/c/d/f', content: values([Buffer.from('strawberry')]) },
{ path: 'a/b/g', content: values([Buffer.from('ice')]) },
{ path: 'a/b/h', content: values([Buffer.from('cream')]) }
]),
importer(ipld),
collect((err, files) => {
Expand Down
12 changes: 7 additions & 5 deletions test/importer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ chai.use(require('dirty-chai'))
const expect = chai.expect
const spy = require('sinon/lib/sinon/spy')
const pull = require('pull-stream/pull')
const empty = require('pull-stream/sources/empty')
const once = require('pull-stream/sources/once')
const values = require('pull-stream/sources/values')
const collect = require('pull-stream/sinks/collect')
const onEnd = require('pull-stream/sinks/on-end')
const CID = require('cids')
const IPLD = require('ipld')
const loadFixture = require('aegir/fixtures')
Expand Down Expand Up @@ -153,7 +155,7 @@ const checkLeafNodeTypes = (ipld, options, expected, done) => {
const checkNodeLinks = (ipld, options, expected, done) => {
waterfall([
(cb) => pull(
pull.once({
once({
path: '/foo',
content: Buffer.alloc(100).fill(1)
}),
Expand Down Expand Up @@ -258,7 +260,7 @@ strategies.forEach((strategy) => {
content: 'banana'
}]),
importer(ipld, options),
pull.onEnd((err) => {
onEnd((err) => {
expect(err).to.exist()
done()
})
Expand All @@ -267,7 +269,7 @@ strategies.forEach((strategy) => {

it('doesn\'t yield anything on empty source', (done) => {
pull(
pull.empty(),
empty(),
importer(ipld, options),
collect((err, nodes) => {
expect(err).to.not.exist()
Expand All @@ -280,7 +282,7 @@ strategies.forEach((strategy) => {
pull(
values([{
path: 'emptyfile',
content: pull.empty()
content: empty()
}]),
importer(ipld, options),
collect((err, nodes) => {
Expand All @@ -306,7 +308,7 @@ strategies.forEach((strategy) => {
}
]),
importer(ipld, options),
pull.onEnd((err) => {
onEnd((err) => {
expect(err).to.exist()
expect(err.message).to.be.eql('detected more than one root')
done()
Expand Down

0 comments on commit 91d5871

Please sign in to comment.