Skip to content

Commit

Permalink
update .name properties of `String#{trimStart, trimEnd , trimLeft, …
Browse files Browse the repository at this point in the history
…trimRight}` by proposal, mark mongolian vowel separator as non-whitespace in one more place
  • Loading branch information
zloirock committed May 5, 2018
1 parent 8d6f675 commit 15c790f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/core-js/internals/string-trim.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ var requireObjectCoercible = require('../internals/require-object-coercible');
var fails = require('../internals/fails');
var whitespaces = require('../internals/whitespaces');
var space = '[' + whitespaces + ']';
var non = '\u200b\u0085';
var non = '\u200b\u0085\u180e';
var ltrim = RegExp('^' + space + space + '*');
var rtrim = RegExp(space + space + '*$');

var exporter = module.exports = function (KEY, exec, ALIAS) {
var exported = {};
var FORCED = fails(function () {
return !!whitespaces[KEY]() || non[KEY]() != non;
return !!whitespaces[KEY]() || non[KEY]() != non || whitespaces[KEY].name !== KEY;
});
var fn = exported[KEY] = FORCED ? exec(trim) : whitespaces[KEY];
if (ALIAS) exported[ALIAS] = fn;
Expand Down
6 changes: 3 additions & 3 deletions packages/core-js/modules/esnext.string.trim-left.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
// `String.prototype.{ trimLeft, trimStart }` methods
// https://github.com/tc39/ecmascript-string-left-right-trim
require('../internals/string-trim')('trimLeft', function (internalTrim) {
return function trimLeft() {
require('../internals/string-trim')('trimStart', function (internalTrim) {
return function trimStart() {
return internalTrim(this, 1);
};
}, 'trimStart');
}, 'trimLeft');
6 changes: 3 additions & 3 deletions packages/core-js/modules/esnext.string.trim-right.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
// `String.prototype.{ trimRight, trimEnd }` methods
// https://github.com/tc39/ecmascript-string-left-right-trim
require('../internals/string-trim')('trimRight', function (internalTrim) {
return function trimRight() {
require('../internals/string-trim')('trimEnd', function (internalTrim) {
return function trimEnd() {
return internalTrim(this, 2);
};
}, 'trimEnd');
}, 'trimRight');
4 changes: 2 additions & 2 deletions tests/tests/esnext.string.trim-left.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ QUnit.test('String#trimLeft', assert => {
const { trimLeft } = String.prototype;
assert.isFunction(trimLeft);
assert.arity(trimLeft, 0);
assert.name(trimLeft, 'trimLeft');
assert.name(trimLeft, 'trimStart');
assert.looksNative(trimLeft);
assert.nonEnumerable(String.prototype, 'trimLeft');
assert.strictEqual(' \n q w e \n '.trimLeft(), 'q w e \n ', 'removes whitespaces at left side of string');
Expand All @@ -20,7 +20,7 @@ QUnit.test('String#trimStart', assert => {
const { trimStart } = String.prototype;
assert.isFunction(trimStart);
assert.arity(trimStart, 0);
assert.name(trimStart, 'trimLeft');
assert.name(trimStart, 'trimStart');
assert.looksNative(trimStart);
assert.nonEnumerable(String.prototype, 'trimStart');
assert.same(trimStart, String.prototype.trimLeft, 'same #trimLeft');
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/esnext.string.trim-right.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ QUnit.test('String#trimRight', assert => {
const { trimRight } = String.prototype;
assert.isFunction(trimRight);
assert.arity(trimRight, 0);
assert.name(trimRight, 'trimRight');
assert.name(trimRight, 'trimEnd');
assert.looksNative(trimRight);
assert.nonEnumerable(String.prototype, 'trimRight');
assert.strictEqual(' \n q w e \n '.trimRight(), ' \n q w e', 'removes whitespaces at right side of string');
Expand All @@ -20,7 +20,7 @@ QUnit.test('String#trimEnd', assert => {
const { trimEnd } = String.prototype;
assert.isFunction(trimEnd);
assert.arity(trimEnd, 0);
assert.name(trimEnd, 'trimRight');
assert.name(trimEnd, 'trimEnd');
assert.looksNative(trimEnd);
assert.nonEnumerable(String.prototype, 'trimEnd');
assert.same(trimEnd, String.prototype.trimRight, 'same #trimRight');
Expand Down

0 comments on commit 15c790f

Please sign in to comment.