final-stream
Advanced tools
Comparing version 1.0.0 to 1.0.2
@@ -26,3 +26,9 @@ const ErrorWithObject = require('error-with-object'); | ||
callback(null, bodyString && mutation ? mutation(bodyString) : bodyString); | ||
let finalBody; | ||
try { | ||
finalBody = bodyString && mutation ? mutation(bodyString) : bodyString; | ||
callback(null, finalBody); | ||
} catch (error) { | ||
callback(error); | ||
} | ||
}) | ||
@@ -29,0 +35,0 @@ .on('error', function (error) { |
{ | ||
"name": "final-stream", | ||
"version": "1.0.0", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
# FinalStream | ||
# Final Stream | ||
[![Build Status](https://travis-ci.org/markwylde/final-stream.svg?branch=master)](https://travis-ci.org/markwylde/final-stream) | ||
@@ -13,6 +13,6 @@ [![David DM](https://david-dm.org/markwylde/final-stream.svg)](https://david-dm.org/markwylde/final-stream) | ||
```javascript | ||
const finalStream = require('final-stream') | ||
const finalStream = require('final-stream'); | ||
finalStream(response, function (error, result) { | ||
console.log({error, result}) | ||
}) | ||
console.log({error, result}); | ||
}); | ||
``` | ||
@@ -22,6 +22,6 @@ | ||
```javascript | ||
const finalStream = require('final-stream') | ||
const finalStream = require('final-stream'); | ||
finalStream(response, JSON.parse, function (error, result) { | ||
console.log({error, result}) | ||
}) | ||
console.log({error, result}); | ||
}); | ||
``` | ||
@@ -28,0 +28,0 @@ |
@@ -32,2 +32,12 @@ const test = require('tape'); | ||
test('basic stream with invalid json', t => { | ||
t.plan(1); | ||
const stream = fs.createReadStream('./test/testInvalidJsonFileToStream.json', { highWaterMark: 32 }); | ||
finalStream(stream, JSON.parse, function (error, result) { | ||
t.ok(error.toString().includes('SyntaxError: Unexpected token } in JSON')); | ||
}); | ||
}); | ||
test('with no stream object', t => { | ||
@@ -34,0 +44,0 @@ t.plan(1); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13191
9
101