Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var atShim = function at(pos) {
ES.RequireObjectCoercible(this);
var O = ES.ToObject(this);
var S = ES.ToString(O);
var position = ES.ToInteger(pos);
var size = S.length;
if (position < 0 || position >= size) {
return '';
}
// Get the first code unit and code unit value
var cuFirst = S.charCodeAt(position);
var cuSecond;
var nextIndex = position + 1;
var len = 1;
// Check if it’s the start of a surrogate pair.
var isHighSurrogate = cuFirst >= 0xD800 && cuFirst <= 0xDBFF;
if (isHighSurrogate && size > nextIndex /* there is a next code unit */) {
cuSecond = S.charCodeAt(nextIndex);
if (cuSecond >= 0xDC00 && cuSecond <= 0xDFFF) { // low surrogate
len = 2;
module.exports = function padStart(maxLength) {
var O = ES.RequireObjectCoercible(this);
var S = ES.ToString(O);
var stringLength = ES.ToLength(S.length);
var fillString;
if (arguments.length > 1) {
fillString = arguments[1];
}
var filler = typeof fillString === 'undefined' ? '' : ES.ToString(fillString);
if (filler === '') {
filler = ' ';
}
var intMaxLength = ES.ToLength(maxLength);
if (intMaxLength <= stringLength) {
return S;
}
var fillLen = intMaxLength - stringLength;
while (filler.length < fillLen) {
var fLen = filler.length;
var remainingCodeUnits = fillLen - fLen;
filler += fLen > remainingCodeUnits ? slice(filler, 0, remainingCodeUnits) : filler;
}
var truncatedStringFiller = filler.length > fillLen ? slice(filler, 0, fillLen) : filler;
return truncatedStringFiller + S;
module.exports = function padStart(maxLength) {
var O = ES.RequireObjectCoercible(this);
var S = ES.ToString(O);
var stringLength = ES.ToLength(S.length);
var fillString;
if (arguments.length > 1) {
fillString = arguments[1];
}
var filler = typeof fillString === 'undefined' ? '' : ES.ToString(fillString);
if (filler === '') {
filler = ' ';
}
var intMaxLength = ES.ToLength(maxLength);
if (intMaxLength <= stringLength) {
return S;
}
var fillLen = intMaxLength - stringLength;
while (filler.length < fillLen) {
var fLen = filler.length;
module.exports = function padEnd(maxLength) {
var O = ES.RequireObjectCoercible(this);
var S = ES.ToString(O);
var stringLength = ES.ToLength(S.length);
var fillString;
if (arguments.length > 1) {
fillString = arguments[1];
}
var filler = typeof fillString === 'undefined' ? '' : ES.ToString(fillString);
if (filler === '') {
filler = ' ';
}
var intMaxLength = ES.ToLength(maxLength);
if (intMaxLength <= stringLength) {
return S;
}
var fillLen = intMaxLength - stringLength;
while (filler.length < fillLen) {
var fLen = filler.length;
module.exports = function padEnd(maxLength) {
var O = ES.RequireObjectCoercible(this);
var S = ES.ToString(O);
var stringLength = ES.ToLength(S.length);
var fillString;
if (arguments.length > 1) {
fillString = arguments[1];
}
var filler = typeof fillString === 'undefined' ? '' : ES.ToString(fillString);
if (filler === '') {
filler = ' ';
}
var intMaxLength = ES.ToLength(maxLength);
if (intMaxLength <= stringLength) {
return S;
}
var fillLen = intMaxLength - stringLength;
while (filler.length < fillLen) {
var fLen = filler.length;
var remainingCodeUnits = fillLen - fLen;
filler += fLen > remainingCodeUnits ? slice(filler, 0, remainingCodeUnits) : filler;
}
var truncatedStringFiller = filler.length > fillLen ? slice(filler, 0, fillLen) : filler;
return S + truncatedStringFiller;