New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

advanced-pad

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

advanced-pad

Left and right string padding with advanced features.

latest
Source
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

[Node] advanced-pad

Build Status dependencies Status devDependencies Status License: MIT

Super lightweight and advanced padding module.

advanced-pad is a super light string padding function with advanced truncation and character padding support.

Features

  • Directional - One module for padding both left and right.
  • Multi Character Padding - Pad strings with multiple characters without going over set length.
  • Advanced Truncation - Easily toggle string truncation based on length of padding.

Install

$ npm install advanced-pad

Usage

// include advanced-pad
var pad = require('advanced-pad');

// call a padding function
pad.padLeft(string, len, chr = ' ', trunc = false);
pad.padRight(string, len, chr = ' ', trunc = false);
- string = input string to pad
- len = iteger length to pad string to
- chr = string to use as padding character, can be multi
- trunc = true / false. Setting to true will retun the input string truncated from the left or right if it is longer than len.

// pad with '0' to left with length of 10
pad.padLeft('67454', 10, '0');
Output: 0000067454

// pad with '01' to left with legnth of 15
pad.padLeft('67454, 15, '01');
Output: 010101010167454

// pad with 'x' to right with length of 10
pad.padRight('test', 10, 'x');
Output: testxxxxxx

// pad to with 'x' to right, length of 5, with truncate
pad.padRight('testing', 4, 'x', true);
Output: test

License

MIT © Tyler Colwell

Keywords

padding

FAQs

Package last updated on 27 Mar 2020

Did you know?

Socket

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