mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-20 16:49:52 +00:00
Poor man's rightPad
This commit is contained in:
parent
01afc1c067
commit
df81666b1d
1 changed files with 11 additions and 1 deletions
|
|
@ -4,10 +4,20 @@ import { connect } from "react-redux";
|
|||
import CharacterString from "../CharacterString";
|
||||
import { getRunningTimeMessage } from "../../selectors";
|
||||
|
||||
// While all the browsers I care about support String.prototype.padEnd,
|
||||
// Not all node versions do, and I want tests to pass in Jest...
|
||||
// Sigh.
|
||||
function rightPad(str, len, fillChar) {
|
||||
while (str.length < len) {
|
||||
str += fillChar;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
const RunningTimeDisplay = props => (
|
||||
<div className="playlist-running-time-display draggable">
|
||||
<CharacterString>
|
||||
{props.runningTimeMessage.padEnd(18, " ")}
|
||||
{rightPad(props.runningTimeMessage, 18, " ")}
|
||||
</CharacterString>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue