You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

string-left-right

Package Overview
Dependencies
Maintainers
0
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-left-right

Looks up the first non-whitespace character to the left/right of a given index

6.0.20
latest
Source
npmnpm
Version published
Weekly downloads
139K
-6.52%
Maintainers
0
Weekly downloads
 
Created

What is string-left-right?

The string-left-right npm package provides utilities for trimming whitespace from the left and right sides of strings, as well as other string manipulation functionalities.

What are string-left-right's main functionalities?

trimLeft

The trimLeft function removes whitespace from the left side of a string.

const { trimLeft } = require('string-left-right');
const result = trimLeft('   Hello World!   ');
console.log(result); // 'Hello World!   '

trimRight

The trimRight function removes whitespace from the right side of a string.

const { trimRight } = require('string-left-right');
const result = trimRight('   Hello World!   ');
console.log(result); // '   Hello World!'

trim

The trim function removes whitespace from both sides of a string.

const { trim } = require('string-left-right');
const result = trim('   Hello World!   ');
console.log(result); // 'Hello World!'

left

The left function returns the index of the first non-whitespace character from the left.

const { left } = require('string-left-right');
const result = left('   Hello World!   ');
console.log(result); // 3

right

The right function returns the index of the first non-whitespace character from the right.

const { right } = require('string-left-right');
const result = right('   Hello World!   ');
console.log(result); // 15

Other packages similar to string-left-right

Keywords

check

FAQs

Package last updated on 02 Mar 2025

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