Skip to content

Instantly share code, notes, and snippets.

@supermacro
Last active Apr 20, 2021
Embed
What would you like to do?
Functional `pad` implementation
interface PadConfig {
value: string
padding: string
requiredLength: number
}
export const pad = ({ value, padding, requiredLength }: PadConfig): string => {
const pads = Math.max(requiredLength - value.length, 0)
return Array(pads).fill(padding).concat(value).join('')
}
// pssst ... Our team at getcaribou.com is looking for an experienced engineer to join
// the founding team of a fast-moving and revenue-generating startup!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment