Skip to content

Commit

Permalink
IqonHash: remove String.padEnd polyfill
Browse files Browse the repository at this point in the history
Browser support for padEnd is now sufficiently good.
  • Loading branch information
danimoh committed Sep 6, 2024
1 parent 9e93f27 commit a15fcda
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions src/lib/IqonHash.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class IqonHash { /* eslint-disable-line no-unused-vars */
// leading to an invalid bottom index and feature color. Adding
// padding creates a bottom feature and accent color where no
// existed previously, thus it's not a disrupting change.
return this._padEnd(hash, 13, fullHash[5]);
return hash.padEnd(13, fullHash[5]);
}

/**
Expand All @@ -47,21 +47,4 @@ class IqonHash { /* eslint-disable-line no-unused-vars */
}
return an;
}

/**
* Polyfill for String.padEnd()
*
* @param {string} string
* @param {number} maxLength
* @param {string} fillString
* @returns {string}
*/
static _padEnd(string, maxLength, fillString) {
if ('padEnd' in String.prototype) return string.padEnd(maxLength, fillString);

while (string.length < maxLength) {
string += fillString;
}
return string.substring(0, Math.max(string.length, maxLength));
}
}

0 comments on commit a15fcda

Please sign in to comment.