Socket
Socket
Sign inDemoInstall

left-right-padding

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    left-right-padding

Left and Right Padding with given string with given count or uptill n length


Version published
Weekly downloads
1
Maintainers
1
Install size
5.41 kB
Created
Weekly downloads
 

Readme

Source

left-right-padding

Left and Right Padding with given string with given count or uptill n length

#Installation

npm install left-right-padding --save

#Integration


var padding = require("left-right-padding");

Argument

padding.lpad( inputString, paddingValue, noOfTimes, maxStringLength);
  • inputString - String to be processed.
  • paddingValue - String to be padded.
  • noOfTimes (optional) - paddingValue will be repated for value defined in noOfTimes. If maxStringLength defined and if maxStringLength reached, then noOfTimes will be repeated upto maxStringLength.
  • maxStringLength - if noOfTimes is zero or less than 1, then padding value will be padded upto inputstring length becomes masStringLength.
### Left Padding using lpad
console.log ( padding.lpad("test", "*"));
//Output:	*test

console.log ( padding.lpad("test", "*", 10));
//Output:	**********test

console.log ( padding.lpad("test", "*", 3, 15));
//Output:	***test

console.log ( padding.lpad("test", "*", 3, 5));
//Output:	*test

console.log ( padding.lpad("test", "*", 0, 15));
//Output:	***********test

console.log ( padding.lpad());
//Output:	undefined

console.log ( padding.lpad("test"));
//Output:	test


### Right Padding using rpad
console.log ( padding.rpad("test", "*"));
//Output:	test*

console.log ( padding.rpad("test", "*", 10));
//Output:	test**********

console.log ( padding.rpad("test", "*", 3, 15));
//Output:	test***

console.log ( padding.rpad("test", "*", 3, 5));
//Output:	test*

console.log ( padding.rpad("test", "*", 0, 15));
//Output:	test***********

console.log ( padding.rpad());
//Output:	undefined

console.log ( padding.rpad("test"));
//Output:	test

Keywords

FAQs

Last updated on 26 Nov 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc