UNPKG

@beyond-sharepoint/spo-shell

Version:

Cross-Platform Command Line Utility for SharePoint Online

22 lines (19 loc) 482 B
'use strict'; const strip = require('./stripAnsi'); /** * Pads a value with with space or * a specified delimiter to match a * given width. * * @param {String} str * @param {Integer} width * @param {String} delimiter * @return {String} * @api public */ module.exports = function (str, width, delimiter) { width = Math.floor(width); delimiter = delimiter || ' '; const len = Math.max(0, width - strip(str).length); return str + Array(len + 1).join(delimiter); };