Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

string-padding

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-padding - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

11

index.js
var pad = function(input, length, padding, side) {
input = (input || '').toString();
input = (input || '').toString();
length = parseInt(length) || 0;

@@ -9,2 +9,11 @@ padding = (padding || '').toString() || ' ';

if(
length === Infinity || // Non-valid length
padding.length === 0 || // Non-valid padding
(side !== pad.LEFT && // Non-valid padding types
side !== pad.RIGHT &&
side !== pad.BOTH)
) return input;
while(input.length < length) {

@@ -11,0 +20,0 @@ if(

2

package.json
{
"name": "string-padding",
"version": "1.0.1",
"version": "1.0.2",
"description": "Pad strings/text",

@@ -5,0 +5,0 @@

@@ -15,8 +15,10 @@ # 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`.
- **length** (optional): The length the output string should be. It doesn’t truncate the original string.
- **padding** (optional): The character(s) for padding. You can go crazy with multiple characters ;)
- **side** (optional): The side which should be padded; `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.
## Extending core String object
For those who are fine with extending the core String object, you can do just that. Note you can skip the first parameter and directly call `.pad()` on a string.
```javascript

@@ -23,0 +25,0 @@ var pad = require('string-padding');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc