Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
string.prototype.trimstart
Advanced tools
Package description
The string.prototype.trimstart package provides functionality to remove whitespace from the beginning of a string without altering the rest of the string. This is particularly useful for cleaning up user input, formatting strings before processing, or simply ensuring consistency in string data.
Trimming start of a string
This feature allows you to remove all whitespace from the beginning of a string. The example code demonstrates how to use the trimStart method to remove leading spaces from a string, resulting in 'Hello world!' without the leading spaces.
" Hello world!".trimStart()
Lodash's trimStart function offers similar functionality to string.prototype.trimstart by removing whitespace from the beginning of a string. Lodash provides a more extensive utility library that includes this method among many others for manipulating strings, arrays, objects, etc., making it a more versatile choice if additional utilities are needed.
The string.prototype.trimleft package is an alternative that provides similar functionality to trimStart. It's essentially an alias for trimStart in environments that support it, ensuring compatibility and providing a polyfill where necessary. This package is useful for developers looking for consistency in naming or needing support in environments where trimStart is not available.
Readme
An ES2019-spec-compliant String.prototype.trimStart
shim. Invoke its "shim" method to shim String.prototype.trimStart
if it is unavailable.
This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec. In an ES6 environment, it will also work properly with Symbol
s.
Most common usage:
var trimStart = require('string.prototype.trimstart');
assert(trimStart(' \t\na \t\n') === 'a \t\n');
if (!String.prototype.trimStart) {
trimStart.shim();
}
assert(trimStart(' \t\na \t\n') === ' \t\na \t\n'.trimStart());
Simply clone the repo, npm install
, and run npm test
FAQs
ES2019 spec-compliant String.prototype.trimStart shim.
The npm package string.prototype.trimstart receives a total of 28,473,700 weekly downloads. As such, string.prototype.trimstart popularity was classified as popular.
We found that string.prototype.trimstart demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
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.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.