
Product
Introducing Historical Analytics – Now in Beta
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.
string.prototype.trimstart
Advanced tools
ES2019 spec-compliant String.prototype.trimStart shim.
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.
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 24,946,837 weekly downloads. As such, string.prototype.trimstart popularity was classified as popular.
We found that string.prototype.trimstart demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.
Product
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
Company News
Socket is bringing best-in-class reachability analysis into the platform — cutting false positives, accelerating triage, and cementing our place as the leader in software supply chain security.