diff --git a/lib/converters/index.js b/lib/converters/index.js index ea8b8c1b..534c39ee 100644 --- a/lib/converters/index.js +++ b/lib/converters/index.js @@ -5,12 +5,12 @@ var semver = require('semver'), /** * Prototype interface definition of a converter * - * @param {object} model - * @param {string} model.input - * @param {string} model.output - * @param {function} model.convert - * @param {function} model.create - * @param {function=} [model.init] + * @param {Object} model - A manifest that defines the conversion process. + * @param {String} model.input - The input version to convert from. + * @param {String} model.output - The output version to convert to. + * @param {Function} model.convert - A function to convert entire collections. + * @param {Function} model.create - A function to perform creation operations. + * @param {Function} [model.init] - An initializer function to bootstrap the generated converter. * * @throws {Error} If model definition does not meet requirements */ @@ -66,9 +66,9 @@ module.exports = { /** * Fetches a converter for the given input and output versions * - * @param inputVersion - * @param outputVersion - * @returns {Converter} + * @param {String} inputVersion - The version to convert from. + * @param {String} outputVersion - The version to convert to. + * @returns {Converter} - A converter for the given set of options. */ getConverter: function (inputVersion, outputVersion) { var converter; @@ -77,6 +77,7 @@ module.exports = { outputVersion = semver.clean(outputVersion); for (converter in this.converters) { + // eslint-disable-next-line no-prototype-builtins converter = this.converters.hasOwnProperty(converter) && this.converters[converter]; if (converter && semver.eq(converter.input, inputVersion) && semver.eq(converter.output, outputVersion)) { return generateConverter(converter); @@ -87,10 +88,9 @@ module.exports = { /** * Picks the appropriate converter and converts the given collection. * - * @param collection - * @param options - * @param callback - * @returns {*} + * @param {Object} collection - The collection to be converted. + * @param {Object} options - The set of options for request conversion. + * @param {Function} callback - The function to be invoked after the completion of conversion process. */ convert: function (collection, options, callback) { var chosenConverter = this.getConverter(options.inputVersion, options.outputVersion); @@ -98,16 +98,16 @@ module.exports = { if (!chosenConverter) { return callback(new Error('no conversion path found')); } + return chosenConverter.convert(collection, options, callback); }, /** * Picks the appropriate converter and converts the given object. * - * @param object - A single V1 request or a V2 Item. - * @param options - * @param callback - * @returns {*} + * @param {Object} object - A single V1 request or a V2 Item. + * @param {Object} options - The set of options for request conversion. + * @param {Function} callback - The function to be invoked after the completion of conversion process. */ convertSingle: function (object, options, callback) { var chosenConverter = this.getConverter(options.inputVersion, options.outputVersion); @@ -122,9 +122,9 @@ module.exports = { /** * Picks the appropriate converter and converts the given object. * - * @param object - A single V1 Response or a V2 Response. - * @param options - * @param callback + * @param {Object} object - A single V1 Response or a V2 Response. + * @param {Object} options - The set of options for response conversion. + * @param {Function} callback - The function invoked to mark the completion of the conversion process. * @returns {*} */ convertResponse: function (object, options, callback) { @@ -140,8 +140,8 @@ module.exports = { /** * Returns a builder, which can be used to convert individual requests, etc. * - * @param options - * @returns {options} + * @param {Object} options - The set of options for builder creation. + * @returns {Function} - The builder for the given set of options. */ builder: function (options) { var chosenConverter = this.getConverter(options.inputVersion, options.outputVersion);