As a newcomer to JavaScript, I'm attempting to call a function within another function. However, when I try to do this, I encounter a lint error. - The 'stringValues' function inserts commas between numbers for correct formatting: it displays 1,000 for 1000 and 10,000 for 10000.
return Number(unitsOfNumbers.join('')).stringValues();
- Below is my code snippet along with the error message:
ERROR:
"stringValues" is defined but never used - no-unused-vars
CODE:
import {differentCountriesCurrency} from 'sports-input-utils/lib/formatting';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.appleBrowser = appleBrowser;
exports.appleBrowserWithDecimals;
function stringValues(x, sep, grp) {
var sx = (''+x).split('.'), s = '', i, j;
sep || (sep = ','); // default separator
grp || grp === 0 || (grp = 3); // default grouping
i = sx[0].length;
while (i > grp) {
j = i - grp;
s = sep + sx[0].slice(j, i) + s;
i = j;
}
s = sx[0].slice(0, i) + s;
sx[0] = s;
return sx.join('.');
}
function appleBrowser(value, parm) {
var unitsOfNumbers;
if (!value) {
return value;
}
// Extract unitsOfNumbers. If none are found, fill in zero.
unitsOfNumbers = value.match(/\d/g) || ['0'];
return Number(unitsOfNumbers.join('')).stringValues();
}
function appleBrowserWithDecimals(value, parm) {
var unitsOfNumbers;
if (!value) {
return value;
}
// Extract unitsOfNumbers. If none are found, fill in zero.
unitsOfNumbers = value.match(/\d/g) || ['0'];
// Zero-pad a one-digit input
if (unitsOfNumbers.length === 1) {
unitsOfNumbers.unshift('0');
}
// Add a decimal point
unitsOfNumbers.splice(unitsOfNumbers.length - 2, 0, '.');
return Number(unitsOfNumbers.join('')).stringValues();
}
//# sourceMappingURL=formatting.js.map
exports.limitMaximumLength = limitMaximumLength;
function limitMaximumLength(value, parm) {
if (value.length < parm) {
return value;
} else {
return value.substring(0, parm);
}
}
exports.differentCountriesCurrencyWithMaxLen = differentCountriesCurrencyWithMaxLen;
function differentCountriesCurrencyWithMaxLen (value) {
var isSafari;
return differentCountriesCurrency(limitMaximumLength(value, 7));
isSafari = navigator.userAgent.indexOf("Safari") > -1;
if (isSafari) {
return appleBrowser(limitMaximumLength(value, 7));
}
}