Skip to content
This repository was archived by the owner on Jun 28, 2021. It is now read-only.

Commit e5dfda3

Browse files
committed
Refactor code
1 parent 49a8456 commit e5dfda3

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,8 @@ class Parser extends Transform {
107107
options.delimiter = options.delimiter.map(function(del){
108108
if(del === undefined || del === null || del === false){
109109
return Buffer.from(',')
110-
}else if(typeof del === 'string' && del.length !== 0){
110+
}else if((typeof del === 'string' || Buffer.isBuffer(del)) && del.length !== 0){
111111
return Buffer.from(del)
112-
}else if(Buffer.isBuffer(del) && del.length !== 0){
113-
return del
114112
}
115113
throw new CsvError('CSV_INVALID_OPTION_DELIMITER', [
116114
'Invalid option delimiter:',
@@ -932,7 +930,7 @@ class Parser extends Transform {
932930
__isDelimiter(chr, buf, pos){
933931
const {delimiter} = this.options
934932
loop1: for(let i = 0; i < delimiter.length; i++){
935-
const del = delimiter[i];
933+
const del = delimiter[i]
936934
if(del[0] === chr){
937935
for(let j = 1; j < del.length; j++){
938936
if(del[j] !== buf[pos+j]) continue loop1

0 commit comments

Comments
 (0)