From 31ea048915a7cf22b1560f8216bb358da9e72c8d Mon Sep 17 00:00:00 2001 From: "Alexey Mulyukin (alexprey)" Date: Mon, 21 Dec 2020 16:38:16 +0300 Subject: [PATCH] Rename utility method `printArray` to `stringifyArray` --- lib/options.js | 14 +++++++------- lib/utils.js | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/options.js b/lib/options.js index 2731b56..baf34f3 100644 --- a/lib/options.js +++ b/lib/options.js @@ -1,4 +1,4 @@ -const { isString, printArray, isVisibilitySupported, VISIBILITIES } = require('./utils'); +const { isString, stringifyArray, isVisibilitySupported, VISIBILITIES } = require('./utils'); /** * @typedef {import("../typings").SvelteParserOptions} SvelteParserOptions @@ -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; } @@ -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. ' + @@ -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); }; diff --git a/lib/utils.js b/lib/utils.js index 59035f3..19f6f91 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -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); @@ -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;