diff --git a/lib/normalizers/index.js b/lib/normalizers/index.js index d6ff565f..55f923e6 100644 --- a/lib/normalizers/index.js +++ b/lib/normalizers/index.js @@ -1,3 +1,4 @@ +/* eslint-disable object-shorthand */ var semver = require('semver'), // @todo: Add support for more normalizers diff --git a/lib/normalizers/v1.js b/lib/normalizers/v1.js index f083c3a7..65f33852 100644 --- a/lib/normalizers/v1.js +++ b/lib/normalizers/v1.js @@ -1,10 +1,11 @@ +/* eslint-disable object-shorthand */ var _ = require('lodash').noConflict(), v1Common = require('../common/v1'), v2Common = require('../common/v2'), util = require('../util'), url = require('../url'), - Builders = function ConverterBuilder (options) { + Builders = function (options) { this.options = options || {}; }, script = function (entityV1, listen, key) { @@ -148,10 +149,12 @@ _.assign(Builders.prototype, { if (!requestV1) { return; } var mode = requestV1.dataMode; + if ((!mode || mode === 'binary') && !this.options.noDefaults) { return []; } if (!requestV1.data) { return; } _.isArray(requestV1.data) && normalizeEntities(requestV1.data, this.options); + return requestV1.data; }, @@ -277,7 +280,9 @@ _.assign(Builders.prototype, { requestV1.currentHelper = v2Common.authMap[requestV1.auth.type]; (requestV1.currentHelper === null) && (requestV1.helperAttributes = null); - if (mapper = util.authMappersFromCurrent[requestV1.currentHelper]) { + mapper = util.authMappersFromCurrent[requestV1.currentHelper]; + + if (mapper) { (map = util.authArrayToMap(requestV1)) && (helperAttributes = mapper(map[requestV1.auth.type])); helperAttributes && (requestV1.helperAttributes = helperAttributes); } @@ -415,7 +420,7 @@ _.assign(Builders.prototype, { * Normalizes a potentially raw v1 request object. * * @param {Object} collectionV1 - The potentially raw v1 collection object. - * @returns {Object[]} - The normalized v1 request list. + * @returns {Object[]|*} - The normalized v1 request list. */ requests: function (collectionV1) { if (_.isEmpty(collectionV1 && collectionV1.requests)) { return; } @@ -545,6 +550,7 @@ module.exports = { } if (callback) { return callback(null, collection); } + return collection; } };