string-padding
Advanced tools
Comparing version 1.0.0 to 1.0.1
var pad = function(input, length, padding, side) { | ||
input = (input || '').toString(); | ||
length = parseInt(length) || 0; | ||
@@ -3,0 +4,0 @@ padding = (padding || '').toString() || ' '; |
{ | ||
"name": "string-padding", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Pad strings/text", | ||
@@ -5,0 +5,0 @@ |
@@ -14,14 +14,16 @@ # String-padding | ||
- *string*: A string of text of any length. | ||
- *length* (optional): The length the output string should be. Note that it doesn’t truncate the original string. | ||
- *padding* (optional): The character(s) for padding. Yes, you could go crazy with multiple characters ;) | ||
- *side* (optional): The side which should be padded; please use `pad.LEFT`, `pad.RIGHT` or `pad.BOTH`. | ||
- **string**: A string of text of any length. | ||
- **length** (optional): The length the output string should be. Note that it doesn’t truncate the original string. | ||
- **padding** (optional): The character(s) for padding. Yes, you could go crazy with multiple characters ;) | ||
- **side** (optional): The side which should be padded; please use `pad.LEFT`, `pad.RIGHT` or `pad.BOTH`. | ||
For those who are totally fine with prototyping strings, you can do that. If you do, you can skip the first parameter. | ||
var pad = require('string-padding'); | ||
String.prototype.pad = pad.prototype; | ||
'Hello World!'.pad(16, '0'); // 0000Hello World! | ||
```javascript | ||
var pad = require('string-padding'); | ||
String.prototype.pad = pad.prototype; | ||
'Hello World!'.pad(16, '0'); // 0000Hello World! | ||
``` | ||
Happy padding! :) |
Sorry, the diff of this file is not supported yet
2239
25
28