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

Commit

Permalink
stream: pass stream options without modification
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Nov 22, 2018
1 parent 31d2793 commit 173b886
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,10 @@ New features:

* options: accept camelize and underscore forms

Fix:

* stream: pass stream options without modification

## Version 4.0.1

Fix:
Expand Down
21 changes: 13 additions & 8 deletions lib/es5/index.js
Expand Up @@ -18,6 +18,10 @@ function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
Expand Down Expand Up @@ -78,19 +82,20 @@ function (_Transform) {

_classCallCheck(this, Parser);

var options = {};

for (var opt in opts) {
options[underscore(opt)] = opts[opt];
}

options.readableObjectMode = true;
_this = _possibleConstructorReturn(this, _getPrototypeOf(Parser).call(this, options)); // Import default options
_this = _possibleConstructorReturn(this, _getPrototypeOf(Parser).call(this, _objectSpread({}, {
readableObjectMode: true
}, opts)));
var options = {}; // Import default options

for (var k in default_options) {
if (options[k] === undefined) {
options[k] = default_options[k];
}
} // Merge with user options


for (var opt in opts) {
options[underscore(opt)] = opts[opt];
} // Normalize option `cast`


Expand Down
10 changes: 5 additions & 5 deletions lib/index.js
Expand Up @@ -32,18 +32,18 @@ const space = 32

class Parser extends Transform {
constructor(opts = {}){
super({...{readableObjectMode: true}, ...opts})
const options = {}
for(let opt in opts){
options[underscore(opt)] = opts[opt]
}
options.readableObjectMode = true
super(options)
// Import default options
for(let k in default_options){
if(options[k] === undefined){
options[k] = default_options[k]
}
}
// Merge with user options
for(let opt in opts){
options[underscore(opt)] = opts[opt]
}
// Normalize option `cast`
let fnCastField = null
if(options.cast === undefined || options.cast === null || options.cast === false || options.cast === ''){
Expand Down
8 changes: 4 additions & 4 deletions test/api.types.ts
Expand Up @@ -14,10 +14,10 @@ describe('API Types', () => {
keys.sort().should.eql([
'cast', 'cast_date', 'columns', 'comment', 'delimiter',
'escape', 'from', 'from_line', 'info', 'ltrim', 'max_record_size',
'objname', 'quote', 'raw', 'readableObjectMode',
'record_delimiter', 'relax', 'relax_column_count',
'rtrim', 'skip_empty_lines', 'skip_lines_with_empty_values',
'skip_lines_with_error', 'to', 'to_line', 'trim'
'objname', 'quote', 'raw', 'record_delimiter',
'relax', 'relax_column_count', 'rtrim', 'skip_empty_lines',
'skip_lines_with_empty_values', 'skip_lines_with_error', 'to',
'to_line', 'trim'
])
})

Expand Down

0 comments on commit 173b886

Please sign in to comment.