string.prototype.trim
Advanced tools
Comparing version 1.2.5 to 1.2.6
@@ -8,2 +8,14 @@ # Changelog | ||
## [v1.2.6](https://github.com/es-shims/String.prototype.trim/compare/v1.2.5...v1.2.6) - 2022-04-24 | ||
### Commits | ||
- [actions] reuse common workflows [`dbfc093`](https://github.com/es-shims/String.prototype.trim/commit/dbfc0932e7b2fad166245599310a1d84a1be0882) | ||
- [Fix] as of unicode v6, the mongolian vowel separator is no longer whitespace [`56bbb86`](https://github.com/es-shims/String.prototype.trim/commit/56bbb86b8e514a16fc47e095b8c1014e12a2e92a) | ||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `@es-shims/api`, `safe-publish-latest`, `tape` [`7fa437e`](https://github.com/es-shims/String.prototype.trim/commit/7fa437e4c3d25798d979294a121f93cb4346ba04) | ||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `functions-have-names`, `tape` [`716a060`](https://github.com/es-shims/String.prototype.trim/commit/716a06080dbca68ec8e3b2e0e18c0a333ed28594) | ||
- [actions] update codecov uploader [`9a39958`](https://github.com/es-shims/String.prototype.trim/commit/9a39958a13e20d6b9f01f9fce71dd37cc03da52e) | ||
- [Fix] ensure main entry point properly checks the receiver in ES3 engines [`24220c4`](https://github.com/es-shims/String.prototype.trim/commit/24220c49dcb7055b5b94eb52c4d610428e19d3e4) | ||
- [Deps] update `define-properties`, `es-abstract` [`c6008ea`](https://github.com/es-shims/String.prototype.trim/commit/c6008ea9007741755710b70ae05003cb71a7d1bd) | ||
## [v1.2.5](https://github.com/es-shims/String.prototype.trim/compare/v1.2.4...v1.2.5) - 2021-10-03 | ||
@@ -10,0 +22,0 @@ |
@@ -8,5 +8,10 @@ 'use strict'; | ||
var mvsIsWS = (/^\s$/).test('\u180E'); | ||
/* eslint-disable no-control-regex */ | ||
var leftWhitespace = /^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/; | ||
var rightWhitespace = /[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/; | ||
var leftWhitespace = mvsIsWS | ||
? /^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/ | ||
: /^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/; | ||
var rightWhitespace = mvsIsWS | ||
? /[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/ | ||
: /[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/; | ||
/* eslint-enable no-control-regex */ | ||
@@ -13,0 +18,0 @@ |
11
index.js
@@ -5,2 +5,3 @@ 'use strict'; | ||
var define = require('define-properties'); | ||
var RequireObjectCoercible = require('es-abstract/2021/RequireObjectCoercible'); | ||
@@ -11,5 +12,9 @@ var implementation = require('./implementation'); | ||
var boundTrim = callBind(getPolyfill()); | ||
var bound = callBind(getPolyfill()); | ||
var boundMethod = function trim(receiver) { | ||
RequireObjectCoercible(receiver); | ||
return bound(receiver); | ||
}; | ||
define(boundTrim, { | ||
define(boundMethod, { | ||
getPolyfill: getPolyfill, | ||
@@ -20,2 +25,2 @@ implementation: implementation, | ||
module.exports = boundTrim; | ||
module.exports = boundMethod; |
{ | ||
"name": "string.prototype.trim", | ||
"version": "1.2.5", | ||
"version": "1.2.6", | ||
"author": { | ||
@@ -27,5 +27,5 @@ "name": "Jordan Harband", | ||
"test": "npm run tests-only", | ||
"posttest": "npx aud --production", | ||
"posttest": "aud --production", | ||
"tests-only": "nyc tape 'test/**/*.js'", | ||
"lint": "eslint .", | ||
"lint": "eslint --ext=js,mjs .", | ||
"postlint": "es-shim-api --bound", | ||
@@ -50,16 +50,16 @@ "version": "auto-changelog && git add CHANGELOG.md", | ||
"call-bind": "^1.0.2", | ||
"define-properties": "^1.1.3", | ||
"es-abstract": "^1.19.1" | ||
"define-properties": "^1.1.4", | ||
"es-abstract": "^1.19.5" | ||
}, | ||
"devDependencies": { | ||
"@es-shims/api": "^2.2.2", | ||
"@ljharb/eslint-config": "^18.0.0", | ||
"aud": "^1.1.5", | ||
"auto-changelog": "^2.3.0", | ||
"eslint": "^7.32.0", | ||
"functions-have-names": "^1.2.2", | ||
"@es-shims/api": "^2.2.3", | ||
"@ljharb/eslint-config": "^21.0.0", | ||
"aud": "^2.0.0", | ||
"auto-changelog": "^2.4.0", | ||
"eslint": "=8.8.0", | ||
"functions-have-names": "^1.2.3", | ||
"has-strict-mode": "^1.0.1", | ||
"nyc": "^10.3.2", | ||
"safe-publish-latest": "^1.1.4", | ||
"tape": "^5.3.1" | ||
"safe-publish-latest": "^2.0.0", | ||
"tape": "^5.5.3" | ||
}, | ||
@@ -94,8 +94,3 @@ "testling": { | ||
"hideCredit": true | ||
}, | ||
"greenkeeper": { | ||
"ignore": [ | ||
"nyc" | ||
] | ||
} | ||
} |
@@ -6,5 +6,12 @@ 'use strict'; | ||
var zeroWidthSpace = '\u200b'; | ||
var mongolianVowelSeparator = '\u180E'; | ||
module.exports = function getPolyfill() { | ||
if (String.prototype.trim && zeroWidthSpace.trim() === zeroWidthSpace) { | ||
if ( | ||
String.prototype.trim | ||
&& zeroWidthSpace.trim() === zeroWidthSpace | ||
&& mongolianVowelSeparator.trim() === mongolianVowelSeparator | ||
&& ('_' + mongolianVowelSeparator).trim() === ('_' + mongolianVowelSeparator) | ||
&& (mongolianVowelSeparator + '_').trim() === (mongolianVowelSeparator + '_') | ||
) { | ||
return String.prototype.trim; | ||
@@ -11,0 +18,0 @@ } |
@@ -16,4 +16,23 @@ 'use strict'; | ||
var mongolianVowelSeparator = '\u180E'; | ||
t.test('unicode >= 4 && < 6.3', { skip: !(/^\s$/).test(mongolianVowelSeparator) }, function (st) { | ||
st.equal(trim(mongolianVowelSeparator + 'a' + mongolianVowelSeparator), 'a', 'mongolian vowel separator is whitespace'); | ||
var mvsIsWS = (/^\s$/).test('\u180E'); | ||
t.test('unicode >= 4 && < 6.3', function (st) { | ||
st.equal( | ||
trim(mongolianVowelSeparator + 'a' + mongolianVowelSeparator), | ||
mvsIsWS ? 'a' : mongolianVowelSeparator + 'a' + mongolianVowelSeparator, | ||
'mongolian vowel separator is' + (mvsIsWS ? '' : ' not') + ' whitespace' | ||
); | ||
st.equal( | ||
trim(mongolianVowelSeparator), | ||
mvsIsWS ? '' : mongolianVowelSeparator | ||
); | ||
st.equal( | ||
trim('_' + mongolianVowelSeparator), | ||
'_' + (mvsIsWS ? '' : mongolianVowelSeparator) | ||
); | ||
st.equal( | ||
trim(mongolianVowelSeparator + '_'), | ||
(mvsIsWS ? '' : mongolianVowelSeparator) + '_' | ||
); | ||
st.end(); | ||
@@ -20,0 +39,0 @@ }); |
30711
160
16
Updateddefine-properties@^1.1.4
Updatedes-abstract@^1.19.5