Skip to content

Instantly share code, notes, and snippets.

Last active Apr 20, 2021
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 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