Skip to content

Commit

Permalink
Rename utility method printArray to stringifyArray
Browse files Browse the repository at this point in the history
  • Loading branch information
alexprey committed Dec 21, 2020
1 parent 5013751 commit 31ea048
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions lib/options.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { isString, printArray, isVisibilitySupported, VISIBILITIES } = require('./utils');
const { isString, stringifyArray, isVisibilitySupported, VISIBILITIES } = require('./utils');

/**
* @typedef {import("../typings").SvelteParserOptions} SvelteParserOptions
Expand All @@ -21,16 +21,16 @@ const ENCODINGS = [

const ERROR_ENCODING_FORMAT = 'Expected options.encoding to be a string. ';
const ERROR_VISIBILITIES_FORMAT = 'Expected options.ignoredVisibilities to be an array of strings. ';
const INFO_ENCODING_SUPPORTED = `Supported encodings: ${printArray(ENCODINGS)}.`;
const INFO_VISIBILITIES_SUPPORTED = `Supported visibilities: ${printArray(VISIBILITIES)}.`;
const INFO_ENCODING_SUPPORTED = `Supported encodings: ${stringifyArray(ENCODINGS)}.`;
const INFO_VISIBILITIES_SUPPORTED = `Supported visibilities: ${stringifyArray(VISIBILITIES)}.`;

function getUnsupportedEncodingString(enc) {
return `encoding ${printArray([enc])} not supported. ` +
return `encoding ${stringifyArray([enc])} not supported. ` +
INFO_ENCODING_SUPPORTED;
}

function getUnsupportedVisibilitiesString(arr) {
return `Visibilities [${printArray(arr)}] in ` +
return `Visibilities [${stringifyArray(arr)}] in ` +
'options.ignoredVisibilities are not supported. ' +
INFO_VISIBILITIES_SUPPORTED;
}
Expand Down Expand Up @@ -156,7 +156,7 @@ function validate(options) {
}
}

const getSupportedFeaturesString = (supported) => `Supported features: ${printArray(supported)}`;
const getSupportedFeaturesString = (supported) => `Supported features: ${stringifyArray(supported)}`;

const getFeaturesEmptyString = (supported) => {
return 'options.features must contain at least one feature. ' +
Expand All @@ -168,7 +168,7 @@ const getFeaturesEmptyString = (supported) => {
* @param {string[]} supported
*/
const getFeaturesNotSupportedString = (notSupported, supported) => {
return `Features [${printArray(notSupported)}] in ` +
return `Features [${stringifyArray(notSupported)}] in ` +
'options.features are not supported by this Parser. ' +
getSupportedFeaturesString(supported);
};
Expand Down
4 changes: 2 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ const isTopLevelComment = (comment) => {

const isString = (x) => typeof x === 'string' || x instanceof String;

const printArray = (array = []) => array.map(s => `'${s}'`).join(', ');
const stringifyArray = (array = []) => array.map(s => `'${s}'`).join(', ');

const hasOwnProperty = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);

Expand All @@ -316,5 +316,5 @@ module.exports.inferTypeFromVariableDeclaration = inferTypeFromVariableDeclarati
module.exports.isTopLevelComment = isTopLevelComment;
module.exports.buildCamelCase = buildCamelCase;
module.exports.isString = isString;
module.exports.printArray = printArray;
module.exports.stringifyArray = stringifyArray;
module.exports.hasOwnProperty = hasOwnProperty;

0 comments on commit 31ea048

Please sign in to comment.