Comparing version 5.2.0 to 5.2.1
# History | ||
## 5.2.1 | ||
### Bug fixes | ||
* walk: handle stream errors sanely (9fe21ff) | ||
### Other changes | ||
* deps: update dev dependencies (c1d0518) | ||
* ci: run tests in node 9 (222356e) | ||
* deps: update dev dependencies (be54dbf) | ||
## 5.2.0 | ||
@@ -4,0 +16,0 @@ |
{ | ||
"name": "bfj-node4", | ||
"version": "5.2.0", | ||
"version": "5.2.1", | ||
"description": "Big-friendly JSON. Asynchronous streaming functions for large JSON data sets.", | ||
@@ -37,9 +37,9 @@ "homepage": "https://github.com/philbooth/bfj", | ||
"devDependencies": { | ||
"eslint": "4.6.x", | ||
"mocha": "3.5.x", | ||
"eslint": "4.17.x", | ||
"mocha": "5.0.x", | ||
"chai": "4.1.x", | ||
"proxyquire": "1.8.x", | ||
"spooks": "2.0.x", | ||
"please-release-me": "1.0.x", | ||
"request": "2.81.x" | ||
"please-release-me": "2.0.x", | ||
"request": "2.83.x" | ||
}, | ||
@@ -46,0 +46,0 @@ "scripts": { |
@@ -5,3 +5,2 @@ 'use strict' | ||
const parse = require('./parse') | ||
const promise = require('./promise') | ||
@@ -27,9 +26,3 @@ module.exports = read | ||
function read (path, options) { | ||
const Promise = promise(options) | ||
try { | ||
return parse(fs.createReadStream(path, options), options) | ||
} catch (error) { | ||
return Promise.reject(error) | ||
} | ||
return parse(fs.createReadStream(path, options), options) | ||
} |
@@ -77,2 +77,6 @@ 'use strict' | ||
stream.on('end', endStream) | ||
stream.on('error', err => { | ||
emitter.emit(events.error, err) | ||
endStream() | ||
}) | ||
@@ -79,0 +83,0 @@ emitter.pause = () => { |
@@ -19,6 +19,2 @@ 'use strict' | ||
teardown(() => { | ||
log = undefined | ||
}) | ||
test('require does not throw', () => { | ||
@@ -41,6 +37,2 @@ assert.doesNotThrow(() => { | ||
teardown(() => { | ||
bfj = undefined | ||
}) | ||
test('walk function is exported', () => { | ||
@@ -129,3 +121,2 @@ assert.isFunction(bfj.walk) | ||
fs.unlinkSync(file) | ||
failed = file = result = error = undefined | ||
}) | ||
@@ -167,3 +158,2 @@ | ||
fs.unlinkSync(file) | ||
failed = file = result = error = undefined | ||
}) | ||
@@ -195,3 +185,2 @@ | ||
fs.unlinkSync(file) | ||
failed = file = result = error = undefined | ||
}) | ||
@@ -206,2 +195,24 @@ | ||
suite('read missing file:', () => { | ||
let failed, file, result, error | ||
setup(() => { | ||
failed = false | ||
file = path.join(__dirname, 'missing.json') | ||
assert.isFalse(fs.existsSync(file)) | ||
return bfj.read(file) | ||
.then(res => result = res) | ||
.catch(err => { | ||
failed = true | ||
error = err | ||
}) | ||
}) | ||
test('result was correct', () => { | ||
assert.isTrue(failed) | ||
assert.isUndefined(result) | ||
assert.instanceOf(error, Error) | ||
}) | ||
}) | ||
suite('stringify value:', () => { | ||
@@ -217,6 +228,2 @@ let result | ||
teardown(() => { | ||
result = undefined | ||
}) | ||
test('result was correct', () => { | ||
@@ -248,3 +255,2 @@ assert.strictEqual(result, '"foo\\t\\"\\nbar"') | ||
fs.unlinkSync(file) | ||
failed = file = result = undefined | ||
}) | ||
@@ -251,0 +257,0 @@ |
@@ -103,31 +103,1 @@ 'use strict' | ||
}) | ||
suite('read with error thrown by fs.createReadStream:', () => { | ||
let read | ||
setup(() => { | ||
read = proxyquire(modulePath, { | ||
fs: { | ||
createReadStream () { | ||
throw new Error('foo') | ||
} | ||
}, | ||
'./parse': () => {} | ||
}) | ||
}) | ||
test('read does not throw', () => { | ||
assert.doesNotThrow(() => { | ||
read().catch(() => {}) | ||
}) | ||
}) | ||
test('read rejects', () => { | ||
read() | ||
.then(() => assert.fail('read should reject')) | ||
.catch(error => { | ||
assert.instanceOf(error, Error) | ||
assert.equal(error.message, 'foo') | ||
}) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
282228
7371