rasch / deadlift-png

🫸 just another module for padding a string on its left

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pixel art of a person performing deadlifts

deadlift-png

Left Pad 0BSD License Unmaintained

An obsolete left-pad module (since ES2017 includes String.prototype.padStart()).

install

pnpm

pnpm add deadlift-png

npm

npm install deadlift-png

yarn

yarn add deadlift-png

usage

leftPad :: Char -> Integer -> String -> String

The first argument is a string containing a single character to use for padding the string. By default, the character used is a space (" "). The second argument is an integer that represents the length of the string after padding is added. If the string length is greater than the given number, then the string is returned without modification. The third and final argument is the string to pad.

import { leftPad } from "deadlift-png"

const paddedString = leftPad()(13)("hello world") // => "  hello world"
const paddedNumber = leftPad("0")(3)(7)           // => "007"
const paddedDots = leftPad(".")(10)("hi")         // => "........hi"
const tooShort = leftPad()(3)("hello")            // => "hello"

About

🫸 just another module for padding a string on its left

License:BSD Zero Clause License


Languages

Language:TypeScript 100.0%