0.0.4 • Published 10 years ago
node-string-pad v0.0.4
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__');