Package Exports
- string.prototype.trimstart
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (string.prototype.trimstart) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Introduction
This is a polyfill for the proposed String
API trimStart
by @sebmarkbage, @evilpie and @ljharb.
As the proposal says this API will trim the whitespaces from a string just like the trim
function but only from the start/beginning of the string leaving any white space at the end. This is implemented by some browsers (like FireFox and Chrome) under the name trimLeft
which is not a standard API by the ECMA.
Example
Here's a basic example for the usage of this API:
var str = ' foo ';
str = str.trimStart();
console.log(str.length); // 6
console.log(str); // 'foo '
How it work
This polyfill will fallback on the trimLeft
if it's found, since they're doing the same thing, and if not it will do a work around with the help of trim
function.
Note: for older browsers you need to polyfill trim
, I didn't do that because my target was browsers with the trim
support already since this API is going to take sometime to get accepted.
License
This project is under the MIT License.