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

Commit 9661a5b

Browse files
wintonwdavidw
authored andcommitted
Simplify duplicate column test
1 parent 9c8b584 commit 9661a5b

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

lib/es5/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ var Parser = /*#__PURE__*/function (_Transform) {
882882
var obj = {}; // Transform record array to an object
883883

884884
for (var i = 0, l = record.length; i < l; i++) {
885-
if (columns[i] === undefined || columns[i].disabled) continue;
885+
if (columns[i] === undefined || columns[i].disabled) continue; // Turn duplicate columns into an array
886886

887887
if (obj[columns[i].name]) {
888888
if (Array.isArray(obj[columns[i].name])) {

test/option.columns.coffee

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,14 @@ describe 'Option `columns`', ->
7878

7979
it 'handle duplicate column names if true', (next) ->
8080
parse """
81-
FIELD_1,FIELD_2,FIELD_3,FIELD_4,FIELD_5,FIELD_5
82-
20322051544,1979,8.8017226E7,ABC,45,2000-01-01
83-
28392898392,1974,8.8392926E7,DEF,23,2050-11-27
81+
FIELD_1,FIELD_1
82+
ABC,DEF
83+
GHI,JKL
8484
""", columns: true, (err, data) ->
8585
data.should.eql [
86-
'FIELD_1': '20322051544'
87-
'FIELD_2': '1979'
88-
'FIELD_3': '8.8017226E7'
89-
'FIELD_4': 'ABC'
90-
'FIELD_5': ['45', '2000-01-01']
86+
'FIELD_1': ['ABC', 'DEF']
9187
,
92-
'FIELD_1': '28392898392'
93-
'FIELD_2': '1974'
94-
'FIELD_3': '8.8392926E7'
95-
'FIELD_4': 'DEF'
96-
'FIELD_5': ['23', '2050-11-27']
88+
'FIELD_1': ['GHI', 'JKL']
9789
] unless err
9890
next err
9991

0 commit comments

Comments
 (0)