Global

Methods

leftpad(input, length, text) → {string}

This funciton applies the padding on left side of the input using the given length and given text to pad The given text's length should not be more than 1

Function to add padding in the left side of the input
Author:
  • Himanshu Jangid
License:
  • MIT
Source:
Parameters:
Name Type Default Description
input number | string the input number to apply the padding on - (can be of any length)
length number 3 the lenght that you want the input to be of - (can be any positive integer number or natural number), @default - 3
text number | string 0 the number or text that will be used to pad - (can be ony the lengh of 1), @default - 0
Returns:
Type:
string
the output after appling the padding
Example
- code 
const vtextpad = require("vtextpad")
const input = 12
const ouput = vtextpad.leftpad(12, 3, '0')
console.log(output)

*****
output : 
012

rigthpad(input, length, text) → {string}

This funciton applies the padding right side of the input using the given length and given text to pad The given text's length should not be more than 1

Function to add padding in the right side of the input
Author:
  • Himanshu Jangid
License:
  • MIT
Source:
Parameters:
Name Type Default Description
input number | string the input number to apply the padding on - (can be of any length)
length number 2 the lenght that you want the input to be of - (can be any positive integer number or natural number), @default - 3
text number | string 0 the number or text that will be used to pad - (can be ony the lengh of 1), @default - 0
Returns:
Type:
string
the output after appling the padding
Example
- code 
const vtextpad = require("vtextpad")
const input = 12
const ouput = vtextpad.rightpad(12, 3, '0')
console.log(output)

*****
output : 
012