node-string-pad

0.0.4 • Public • Published

node-string-pad is a simple function to pad strings. Original code from http://www.webtoolkit.info/, modified by me as node.js module with better arguments input.

Installing

npm install node-string-pad

Usage

var pad = require('node-string-pad');

var padded_string = pad(string, len, [direction, character]);

Default: pad RIGHT using ' '.

pad('pad', 7).should.equal('pad    ');

Direction can be 'RIGHT' or 'LEFT' or 'BOTH', though 'RIGHT' can be omitted.

pad('pad', 7, '_').should.equal('pad____');
pad('pad', 7, 'LEFT', '_').should.equal('pad____');
pad('pad', 7, 'BOTH', '_').should.equal('__pad__');

Readme

Keywords

Package Sidebar

Install

npm i node-string-pad

Weekly Downloads

4

Version

0.0.4

License

BSD

Last publish

Collaborators

  • netcell