Skip to content

Commit

Permalink
Corrected lint errors in singleton lib files 👕
Browse files Browse the repository at this point in the history
  • Loading branch information
kunagpal committed Jul 16, 2018
1 parent ebd57e7 commit 759d63b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 43 deletions.
10 changes: 5 additions & 5 deletions lib/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports.SCHEMA_V2_URL = 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json';
module.exports.SCHEMA_V2_1_0_URL = 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json';
module.exports.SCHEMA_V1_URL = 'https://schema.getpostman.com/json/collection/v1.0.0/collection.json';
module.exports.PREREQUEST_EXT = '_preRequestScript';
module.exports.TESTS_EXT = '_tests';
exports.SCHEMA_V2_URL = 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json';
exports.SCHEMA_V2_1_0_URL = 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json';
exports.SCHEMA_V1_URL = 'https://schema.getpostman.com/json/collection/v1.0.0/collection.json';
exports.PREREQUEST_EXT = '_preRequestScript';
exports.TESTS_EXT = '_tests';
46 changes: 23 additions & 23 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
var converter = require('./converters'),
normalizers = require('./normalizers'),
var semver = require('semver'),

util = require('./util'),
semver = require('semver');
converter = require('./converters'),
normalizers = require('./normalizers');

module.exports = {

/**
* Converts a Collection between different versions, based on the given input.
*
* @param collection
* @param options
* @param options.outputVersion
* @param options.inputVersion
* @param {Function=} callback
* @returns {*}
* @param {Object} collection - The collection object to be converted.
* @param {Object} options - The set of conversion options.
* @param {String} options.outputVersion - The version to convert to.
* @param {String} options.inputVersion - The version to convert from.
* @param {Function} callback - The function invoked to mark the completion of the conversion process.
*/
convert: function (collection, options, callback) {
if (!options.outputVersion || !semver.valid(options.outputVersion, true)) {
Expand All @@ -38,8 +38,8 @@ module.exports = {
/**
* Checks whether the given object is a v1 collection
*
* @param object
* @returns {Boolean}
* @param {Object} object - The Object to check for v1 collection compliance.
* @returns {Boolean} - A boolean result indicating whether or not the passed object was a v1 collection.
*/
isv1: function (object) {
return Boolean(object.name && object.order && object.requests);
Expand All @@ -48,8 +48,8 @@ module.exports = {
/**
* Checks whether the given object is a v2 collection
*
* @param object
* @returns {Boolean}
* @param {Object} object - The Object to check for v2 collection compliance.
* @returns {Boolean} - A boolean result indicating whether or not the passed object was a v2 collection.
*/
isv2: function (object) {
return Boolean(object && object.info && object.info.schema);
Expand All @@ -58,11 +58,11 @@ module.exports = {
/**
* Converts a single V1 request to a V2 Item, or a V2 item to a single V1 request.
*
* @param object - A V1 request or a V2 item.
* @param options
* @param options.outputVersion
* @param options.inputVersion
* @param callback
* @param {Object} object - A V1 request or a V2 item.
* @param {Object} options - The set of options for response conversion.
* @param {String} options.outputVersion - The version to convert to.
* @param {String} options.inputVersion - The version to convert from.
* @param {Function} callback - The function invoked to mark the completion of the conversion process.
*/
convertSingle: function (object, options, callback) {
if (!options.outputVersion || !semver.valid(options.outputVersion, true)) {
Expand All @@ -78,11 +78,11 @@ module.exports = {
/**
* Converts a single V1 request to a V2 Item, or a V2 item to a single V1 request.
*
* @param object - A V1 request or a V2 item.
* @param options
* @param options.outputVersion
* @param options.inputVersion
* @param callback
* @param {Object} object - A V1 request or a V2 item.
* @param {Object} options - The set of options for response conversion.
* @param {String} options.outputVersion - The version to convert to.
* @param {String} options.inputVersion - The version to convert from.
* @param {Function} callback - The function invoked to mark the completion of the conversion process.
*/
convertResponse: function (object, options, callback) {
if (!options.outputVersion || !semver.valid(options.outputVersion, true)) {
Expand Down
11 changes: 8 additions & 3 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ var _ = require('lodash').noConflict(),
/**
* Unparses a single query param into a string.
*
* @param param
* @returns {string}
* @param {Object} param - The query parameter object to be unparsed.
* @returns {String} - The unparsed query string.
*/
unparseQueryParam = function (param) {
if (!param || param.disabled) { return ''; }
Expand All @@ -21,6 +21,7 @@ var _ = require('lodash').noConflict(),
// @note - The "param.value != null" check is basically !_.isNil(). (isNil is not available in lodash v3.x)
// This is the right thing to use here.
(param.value !== null) && (unparsed += ('=' + (param.value || '')));

return unparsed;
},

Expand All @@ -45,6 +46,7 @@ var _ = require('lodash').noConflict(),
splitDomain: /\.(?![^{]*\}{2})/g
};

/* eslint-disable object-shorthand */
module.exports = {
parse: function (url) {
url = _.trim(url);
Expand Down Expand Up @@ -85,7 +87,8 @@ module.exports = {
url = url.substr(p.path.length);
p.path && (p.path = p.path.replace(regexes.trimPath, MATCH_1)); // remove leading slash for valid path
// if path is blank string, we set it to undefined, if '/' then single blank string array
p.path = !p.path ? undefined : (p.path === PATH_SEPARATOR ? [E] : p.path.split(PATH_SEPARATOR));
// eslint-disable-next-line no-nested-ternary
p.path = p.path ? (p.path === PATH_SEPARATOR ? [E] : p.path.split(PATH_SEPARATOR)) : undefined;
}

// extract the query string
Expand All @@ -103,6 +106,7 @@ module.exports = {

// extract the hash
p.hash = _.get(url.match(regexes.extractSearch), GET_1);

return p;
},

Expand Down Expand Up @@ -141,6 +145,7 @@ module.exports = {
accumulator += '&';
}
accumulator += unparsed;

return accumulator;
}, '');

Expand Down
23 changes: 11 additions & 12 deletions lib/util.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable object-shorthand */
var _ = require('lodash'),
url = require('./url'),
rnd = Math.random,
util;
rnd = Math.random;

util = {
module.exports = {
// @todo: Add support for a `json` type once it becomes available
typeMap: {
string: 'string',
Expand All @@ -30,6 +30,7 @@ util = {
// in other cases (if "n" is 9,14,19,24) insert "-"
// eslint-disable-next-line curly
for (r = n = E; n++ < 36; r += n * 51 & 52 ? (n ^ 15 ? 8 ^ rnd() * (n ^ 20 ? 16 : 4) : 4).toString(16) : H);

return r;
},

Expand All @@ -52,7 +53,7 @@ util = {
* instead of being deleted.
* @param {Object} [modifiers] - A set of behavioral modifiers for variable handling.
* @param {Boolean} [modifiers.isV1=false] - When set to true, looks for the pathVariableData property as well.
* @return {Array} - The set of sanitized entity level variables.
* @returns {Object[]} - The set of sanitized entity level variables.
*/
handleVars: function (entity, options, modifiers) {
!options && (options = {});
Expand All @@ -65,7 +66,7 @@ util = {
fallback = options.fallback && options.fallback.values,
result = _.map(source || fallback, function (item) {
var result = {
id: !(noDefaults || item.id) ? self.uid() : item.id,
id: (noDefaults || item.id) ? item.id : self.uid(),
key: item.key || item.id,
value: item.value,
type: (item.type === 'text' ? 'string' : item.type) || self.typeMap[typeof item.value] || 'any'
Expand All @@ -88,7 +89,7 @@ util = {
* @param {Object} entity - The wrapped auth entity to be cleaned.
* @param {?Object} options - The set of options for the current auth cleansing operation.
* @param {?Boolean} [options.excludeNoauth=false] - When set to true, noauth is set to null.
* @returns {Object} - The processed auth data.
* @returns {Object|*} - The processed auth data.
*/
cleanAuth: function (entity, options) {
!options && (options = {});
Expand All @@ -115,7 +116,7 @@ util = {
/**
* Transforms an array of auth params to their object equivalent.
*
* @param entity {Object} - The wrapper object for the array of auth params.
* @param {Object} entity - The wrapper object for the array of auth params.
* @param {?Object} options - The set of options for the current auth cleansing operation.
* @param {?Boolean} [options.excludeNoauth=false] - When set to true, noauth is set to null.
* @returns {*}
Expand All @@ -142,7 +143,7 @@ util = {
/**
* Transforms an object of auth params to their array equivalent.
*
* @param entity {Object} - The wrapper object for the array of auth params.
* @param {Object} entity - The wrapper object for the array of auth params.
* @param {?Object} options - The set of options for the current auth cleansing operation.
* @param {?Boolean} [options.excludeNoauth=false] - When set to true, noauth is set to null.
* @returns {*}
Expand Down Expand Up @@ -177,7 +178,7 @@ util = {
/**
* Sanitizes a collection SDK compliant auth list.
*
* @param entity {Object} - The wrapper entity for the auth manifest.
* @param {Object} entity - The wrapper entity for the auth manifest.
* @param {?Object} options - The set of options for the current auth cleansing operation.
* @param {?Boolean} [options.excludeNoauth=false] - When set to true, noauth is set to null.
* @returns {Object[]} - An array of raw collection SDK compliant auth parameters.
Expand Down Expand Up @@ -211,7 +212,7 @@ util = {
* @private
* @param {Object} entityV1 - The v1 entity to be checked for the presence of legacy properties.
* @param {String} type - The type of property to be adjudged against.
* @returns {Boolean} - A flag to indicate the legacy property status of the passed v1 entity.
* @returns {Boolean|*} - A flag to indicate the legacy property status of the passed v1 entity.
*/
notLegacy: function (entityV1, type) {
if (!entityV1) { return; }
Expand Down Expand Up @@ -415,5 +416,3 @@ util = {
}
}
};

module.exports = util;

0 comments on commit 759d63b

Please sign in to comment.