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

fix: turn non-function progress callback into a noop #16

Merged
merged 1 commit into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const defaultOptions = {

module.exports = function builder (createChunker, ipld, createReducer, _options) {
const options = extend({}, defaultOptions, _options)
options.progress = typeof options.progress === 'function' ? options.progress : defaultOptions.progress

return function (source) {
return function (items, cb) {
Expand Down
17 changes: 17 additions & 0 deletions test/importer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,23 @@ strategies.forEach((strategy) => {
)
})

it('survives bad progress option', (done) => {
pull(
values([{
path: '200Bytes.txt',
content: Buffer.from([0, 1, 2])
}]),
importer(ipld, {
...options,
progress: null
}),
onEnd((err) => {
expect(err).to.not.exist()
done()
})
)
})

it('doesn\'t yield anything on empty source', (done) => {
pull(
empty(),
Expand Down