From df81666b1d78252bed2a985cff2e58e841aaf10c Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Wed, 31 Jan 2018 21:12:35 -0800 Subject: [PATCH] Poor man's rightPad --- js/components/PlaylistWindow/RunningTimeDisplay.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/components/PlaylistWindow/RunningTimeDisplay.js b/js/components/PlaylistWindow/RunningTimeDisplay.js index 8331a0ed..97ae5900 100644 --- a/js/components/PlaylistWindow/RunningTimeDisplay.js +++ b/js/components/PlaylistWindow/RunningTimeDisplay.js @@ -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 => (
- {props.runningTimeMessage.padEnd(18, " ")} + {rightPad(props.runningTimeMessage, 18, " ")}
);