Skip to content

Commit

Permalink
adaltas#50: added ability to skip columns
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Jul 28, 2016
1 parent 5be0510 commit 1ec608b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/index.coffee.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ Implementation of the [`stream.Transform` API][transform]
if @options.columns?
lineAsColumns = {}
for field, i in line
continue if this.options.columns[i] is false
lineAsColumns[@options.columns[i]] = field
if @options.objname
row = [lineAsColumns[@options.objname], lineAsColumns]
Expand Down
15 changes: 15 additions & 0 deletions test/columns.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ describe 'columns', ->
"FIELD_6":"2050-11-27"
]
next()

it 'skip columns with false value', (next) ->
parse """
abc,123,def,456
hij,789,klm,789
""", columns: ["FIELD_1", false, "FIELD_2", false], (err, data) ->
return next err if err
data.should.eql [
"FIELD_1":"abc"
"FIELD_2":"def"
,
"FIELD_1":"hij"
"FIELD_2":"klm"
]
next()

it 'validate options column length on first line', (next) ->
parse """
Expand Down

0 comments on commit 1ec608b

Please sign in to comment.