tc39/proposal-string-left-right-trim

Name: proposal-string-left-right-trim

Owner: Ecma TC39

Description: A proposal to the ECMAScript standard for including left and right trim of whitespace to strings

Created: 2015-07-28 18:44:11.0

Updated: 2018-05-23 20:51:56.0

Pushed: 2018-05-14 14:19:00.0

Homepage: null

Size: 23

Language: Shell

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

String.prototype.trimStart / String.prototype.trimEnd

ECMAScript proposal, specs, tests, and reference implementation for String.prototype.trimStart/trimEnd (plus trimLeft/trimRight).

Rationale

ES5 standardized String.prototype.trim. All major engines have also implemented corresponding trimLeft and trimRight functions - without any standard specification. For consistency with padStart/padEnd we propose trimStart and trimEnd and trimLeft/trimRight as aliases required for web compatibility.

Specification

You can view the spec in ecmarkup or rendered as HTML.

Naming / Aliasing

For consistency with padStart/padEnd the standard functions will be trimStart and trimEnd, however for web compatilibity trimLeft will alias trimStart and trimRight will alias trimEnd. This means String.prototype.trimRight.name will change from "trimRight" to "trimEnd" in most engines. The spec author does not expect this to cause any breakage.

Test262 Coverage

PR open

Status of This Proposal

This initial proposal was drafted by @sebmarkbage and the updated spec was drafted by @evilpie with input from @ljharb.

This proposal is currently at stage 2 of the process.

Designated TC39 reviewers: Jordan Harband + Daniel Ehrenberg

Implementations

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.