Skip to content

Commit

Permalink
New: simple csv formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovitDmytro committed Aug 6, 2019
1 parent 2204db1 commit 7637b67
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@
"mocha": "^6.1.4",
"nyc": "^14.1.1",
"semantic-release": "^15.13.19"
},
"dependencies": {
"winston": "^3.2.1"
}
}
14 changes: 14 additions & 0 deletions src/Format.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { format } from 'winston';

export default function CSVFormatter(fields, options={}){
const delim = options.delimiter || ';';
return format.printf(logObject => {
const data = fields.map(key => {
const value = info[key];

return value === undefined ? '' : value;
});

return data.join(delim);
});
}
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import CSVFormatter from './CSVFormatter';
export default CSVFormatter;

0 comments on commit 7637b67

Please sign in to comment.