-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'.'.padEnd is not a function. #3
Comments
Create a file and paste the following content into the file and import it into the project entry file. const RequireObjectCoercible = O => {
if (O === null || typeof O === 'undefined') {
throw new TypeError('"this" value must not be null or undefined');
}
return O;
};
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1;
const ToLength = argument => {
const len = Number(argument);
if (Number.isNaN(len) || len <= 0) { return 0; }
if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; }
return len;
};
if (!String.prototype.padStart) {
String.prototype.padStart = function padStart(maxLength, fillString = ' ') {
const O = RequireObjectCoercible(this);
const S = String(O);
const intMaxLength = ToLength(maxLength);
const stringLength = ToLength(S.length);
if (intMaxLength <= stringLength) { return S; }
let filler = typeof fillString === 'undefined' ? ' ' : String(fillString);
if (filler === '') { return S; }
const fillLen = intMaxLength - stringLength;
while (filler.length < fillLen) {
const fLen = filler.length;
const remainingCodeUnits = fillLen - fLen;
if (fLen > remainingCodeUnits) {
filler += filler.slice(0, remainingCodeUnits);
} else {
filler += filler;
}
}
const truncatedStringFiller = filler.slice(0, fillLen);
return truncatedStringFiller + S;
};
}
if (!String.prototype.padEnd) {
String.prototype.padEnd = function padEnd(maxLength, fillString = ' ') {
const O = RequireObjectCoercible(this);
const S = String(O);
const intMaxLength = ToLength(maxLength);
const stringLength = ToLength(S.length);
if (intMaxLength <= stringLength) { return S; }
let filler = typeof fillString === 'undefined' ? ' ' : String(fillString);
if (filler === '') { return S; }
const fillLen = intMaxLength - stringLength;
while (filler.length < fillLen) {
const fLen = filler.length;
const remainingCodeUnits = fillLen - fLen;
if (fLen > remainingCodeUnits) {
filler += filler.slice(0, remainingCodeUnits);
} else {
filler += filler;
}
}
const truncatedStringFiller = filler.slice(0, fillLen);
return S + truncatedStringFiller;
};
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
'.'.padEnd is not a function.
The text was updated successfully, but these errors were encountered: