var fs = require ('fs') , join = require('path').join , file = join(__dirname, 'fixtures','error.json') , JSONStream = require('../') , it = require('it-is') var expected = JSON.parse(fs.readFileSync(file)) , parser = JSONStream.parse(['rows']) , called = 0 , headerCalled = 0 , footerCalled = 0 , ended = false , parsed = [] fs.createReadStream(file).pipe(parser) parser.on('header', function (data) { headerCalled ++ it(data).deepEqual({ error: 'error_code', message: 'this is an error message' }) }) parser.on('footer', function (data) { footerCalled ++ }) parser.on('data', function (data) { called ++ parsed.push(data) }) parser.on('end', function () { ended = true }) process.on('exit', function () { it(called).equal(0) it(headerCalled).equal(1) it(footerCalled).equal(0) console.error('PASSED') })
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
fixtures | Folder | 0755 |
|
|
bool.js | File | 921 B | 0644 |
|
browser.js | File | 482 B | 0644 |
|
destroy_missing.js | File | 679 B | 0644 |
|
doubledot1.js | File | 685 B | 0644 |
|
doubledot2.js | File | 754 B | 0644 |
|
empty.js | File | 1023 B | 0644 |
|
error_contents.js | File | 865 B | 0644 |
|
fn.js | File | 785 B | 0644 |
|
gen.js | File | 4.14 KB | 0644 |
|
header_footer.js | File | 1.09 KB | 0644 |
|
issues.js | File | 647 B | 0644 |
|
keys.js | File | 2.57 KB | 0644 |
|
map.js | File | 767 B | 0644 |
|
multiple_objects.js | File | 932 B | 0644 |
|
multiple_objects_error.js | File | 694 B | 0644 |
|
null.js | File | 553 B | 0644 |
|
parsejson.js | File | 546 B | 0644 |
|
run.js | File | 443 B | 0644 |
|
stringify.js | File | 949 B | 0644 |
|
stringify_object.js | File | 1.1 KB | 0644 |
|
test.js | File | 748 B | 0644 |
|
test2.js | File | 556 B | 0644 |
|
two-ways.js | File | 920 B | 0644 |
|