Left and right string padding for NodeJs
CoffeeScript JavaScript
Switch branches/tags
Nothing to show
Pull request Compare This branch is 67 commits behind adaltas:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
samples
test
.gitignore
Makefile
index.js
license.md
package.json
readme.md

readme.md

 _   _           _        _____          _ 
| \ | |         | |      |  __ \        | |
|  \| | ___   __| | ___  | |__) |_ _  __| |
| . ` |/ _ \ / _` |/ _ \ |  ___/ _` |/ _` |
| |\  | (_) | (_| |  __/ | |  | (_| | (_| |
|_| \_|\___/ \__,_|\___| |_|   \__,_|\__,_| New BSD License

Node Pad is a simple function to pad strings in the left and right directions.

Left padding

Node Pad does left padding when the first argument is a string and the second argument is a number.

var assert = require('assert');
var pad = require('pad');
assert.equal('pad   ', pad('pad', 6));

Right padding

Node Pad does right padding when the first argument is a number and the second argument is a string.

var assert = require('assert');
var pad = require('pad');
assert.equal( '  pad', pad(5, 'pad'));

Installing

Via git (or downloaded tarball):

$ git clone http://github.com/wdavidw/node-pad.git

Then, simply copy or link the project inside a discoverable Node directory (node_modules).

Via npm:

$ npm install pad