UNPKG

270 BJavaScriptView Raw
1'use strict';
2/**
3 * left-pad module
4 * @module left-pad
5 * @see module:index
6 */
7module.exports = (str, total, spacer) => {
8 spacer = spacer || ' ';
9 let result = str.toString();
10 while (result.length < total) {
11 result = spacer + result;
12 }
13 return result;
14};