Skip to content

Commit

Permalink
fix(csv-stringify): throw err with no records and header in sync mode
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Jun 14, 2022
1 parent 851a129 commit 5c8ef2e
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion packages/csv-stringify/dist/cjs/sync.cjs
Expand Up @@ -546,9 +546,10 @@ const stringify = function(records, opts={}){
api.bom((d) => {
data.push(d);
});
api.headers((headers) => {
const err = api.headers((headers) => {
data.push(headers);
});
if(err !== undefined) throw err;
}
return data.join('');
};
Expand Down
3 changes: 2 additions & 1 deletion packages/csv-stringify/dist/esm/sync.js
Expand Up @@ -2514,9 +2514,10 @@ const stringify = function(records, opts={}){
api.bom((d) => {
data.push(d);
});
api.headers((headers) => {
const err = api.headers((headers) => {
data.push(headers);
});
if(err !== undefined) throw err;
}
return data.join('');
};
Expand Down
3 changes: 2 additions & 1 deletion packages/csv-stringify/dist/iife/sync.js
Expand Up @@ -2517,9 +2517,10 @@ var csv_stringify_sync = (function (exports) {
api.bom((d) => {
data.push(d);
});
api.headers((headers) => {
const err = api.headers((headers) => {
data.push(headers);
});
if(err !== undefined) throw err;
}
return data.join('');
};
Expand Down
3 changes: 2 additions & 1 deletion packages/csv-stringify/dist/umd/sync.js
Expand Up @@ -2520,9 +2520,10 @@
api.bom((d) => {
data.push(d);
});
api.headers((headers) => {
const err = api.headers((headers) => {
data.push(headers);
});
if(err !== undefined) throw err;
}
return data.join('');
};
Expand Down
1 change: 1 addition & 0 deletions packages/csv-stringify/lib/sync.js
Expand Up @@ -27,6 +27,7 @@ const stringify = function(records, opts={}){
const err = api.headers((headers) => {
data.push(headers);
});
if(err !== undefined) throw err;
}
return data.join('');
};
Expand Down
8 changes: 4 additions & 4 deletions packages/csv-stringify/samples/option.cast.js
Expand Up @@ -2,12 +2,12 @@
import assert from 'assert';
import { stringify } from 'csv-stringify/sync';

const data = stringify( [ [1], [2] ], {
const data = stringify([ [1], [2] ], {
cast: {
number: function(value){
return {value: `="${value}"`, quote: false}
return {value: `="${value}"`, quote: false};
}
}
})
});

assert.equal(data, '="1"\n="2"\n')
assert.equal(data, '="1"\n="2"\n');
4 changes: 2 additions & 2 deletions packages/csv-stringify/test/api.web_stream.coffee
Expand Up @@ -2,9 +2,9 @@
# import {generate as generateStream} from 'csv-generate/stream'
# import {stringify as stringifyStream} from '../lib/stream.js'
# import {stringify as stringifyClassic} from '../lib/index.js'
#
#
# describe 'api stream', ->
#
#
# it.skip 'perf stream with iterator', ->
# generator = generateStream
# objectMode: true,
Expand Down

0 comments on commit 5c8ef2e

Please sign in to comment.