tc39 / proposal-string-left-right-trim Goto Github PK
View Code? Open in Web Editor NEWA proposal to the ECMAScript standard for including left and right trim of whitespace to strings
A proposal to the ECMAScript standard for including left and right trim of whitespace to strings
Is it the same functions? If the same - which names they should have?
String.prototype.trimStart === String.prototype.trimLeft; // ???
String.prototype.trimStart.name; // ???
String.prototype.trimLeft.name; // ???
Per discussion around tc39/proposal-string-pad-start-end@35f1ef6 the committee decided it would be ideal to also provide trimStart
and trimEnd
- not necessarily in Annex B - so that the language's official naming conventions for strings trended towards start/end instead of left/right.
Just some stuff I think we should do before the next meeting
@ljharb Can you think of anything else?
I reviewed the spec text and this is good for Stage 3.
I believe @spectranaut can confirm the same.
In C# you can very handily use .TrimStart("?"), this will remove specifically a "?" if it is at the beginning. This can be incredibly useful for very common cases where you want to remove starting string characters such as dealing with query urls on the web.
JS eg:
var query = ...;
if(query.indexOf("?") === -1)
query = query.slice(1);
C# eg:
var query = (...).TrimStart("?");
Not sure if this has already been considered, just been using it a lot lately in C# and thought to check if it could be used in JS.
Criteria taken from the TC39 process document minus those from previous stages:
- Test262 acceptance tests have been written for mainline usage scenarios, and merged
PR by @spectranaut: tc39/test262#1246
- Two compatible implementations which pass the acceptance tests
https://github.com/tc39/proposal-string-left-right-trim#implementations
- Significant in-the-field experience with shipping implementations, such as that provided by two independent VMs
https://github.com/tc39/proposal-string-left-right-trim#implementations
- A pull request has been sent to https://github.com/tc39/ecma262 with the integrated spec text
PR by @evilpie: tc39/ecma262#1275
- The ECMAScript editor has signed off on the pull request
We should decide which is more important: compatibility or good design?
Left
is not allways Start
in multilingual text. This is my proposal:
LTR | RTL | |
---|---|---|
trimStart == | trimLeft | trimRight |
trimEnd == | trimRigth | trimLeft |
But understand it's not that easy to decide when dealing with bidirectional strings.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.