Skip to content

Commit 6d2c15d

Browse files
authored
fix: turn non-function progress callback into a noop (#16)
1 parent 3199688 commit 6d2c15d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/builder/builder.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const defaultOptions = {
3030

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

3435
return function (source) {
3536
return function (items, cb) {

test/importer.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,23 @@ strategies.forEach((strategy) => {
267267
)
268268
})
269269

270+
it('survives bad progress option', (done) => {
271+
pull(
272+
values([{
273+
path: '200Bytes.txt',
274+
content: Buffer.from([0, 1, 2])
275+
}]),
276+
importer(ipld, {
277+
...options,
278+
progress: null
279+
}),
280+
onEnd((err) => {
281+
expect(err).to.not.exist()
282+
done()
283+
})
284+
)
285+
})
286+
270287
it('doesn\'t yield anything on empty source', (done) => {
271288
pull(
272289
empty(),

0 commit comments

Comments
 (0)