Created
February 12, 2019 20:42
-
-
Save nummi/9d75ef602950fad31b29b5af7347d2c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { helper } from '@ember/component/helper'; | |
import { htmlSafe } from '@ember/string'; | |
export function matchDigits([value, max, pad]) { | |
max = max.toString(); | |
value = value.toString(); | |
return htmlSafe( | |
value.length >= max.length ? value : new Array(max.length - value.length + 1).join(pad) + value | |
); | |
} | |
export default helper(matchDigits); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment