A small library for padding strings in JavaScript. Marmalade-free.
NOTE: PADDINGTON IS NO LONGER UNDER ACTIVE DEVELOPMENT.
If you're interested in maintaining Paddington, please get in touch via GitHub.
Current Version: 1.0.0
Node Support: 0.10.x, 0.11.x
Browser Support: Chrome, Firefox 4+, IE 6+, Safari 4+
Build Status:
paddington.pad('foo', 5, '_'); // '_foo_'
paddington.left('foo', 5, '_'); // '__foo'
paddington.right('foo', 5, '_'); // 'foo__'Install Paddington with npm, Bower, or Component:
$ npm install paddington
$ bower install paddington
$ component install rowanmanning/paddingtonAlternatively, just include paddington.js via a <script/> in your page.
If you're using Paddington with Node.js or Component, you can require the module:
var paddington = require('paddington');In-browser, paddington is available as a global variable.
Paddington exposes the following methods:
Return string padded to length by distributing char equally on the left and right.
Return string padded to length by adding char to the left side of it.
Return string padded to length by adding char to the right side of it.
To contribute to Paddington, clone this repo locally and commit your code on a separate branch.
Please write unit tests for your code, and check that everything works by running the following before opening a pull-request:
$ npm testPaddington is licensed under the MIT license.
