mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-28 21:24:26 +08:00
This is need to be able to move to flat config which I am handling in a separate CL. The overrides are there as these packages got update today, so we need to way, but they were last touched 3 years ago, so reviewing their changes upstream as well. Bug: none Change-Id: I61534f881fd4e747c716b42b773f8f7f3e9bc761 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6063618 Commit-Queue: Nikolay Vitkov <nvitkov@chromium.org> Reviewed-by: Danil Somsikov <dsv@chromium.org>
33 lines
994 B
JavaScript
33 lines
994 B
JavaScript
'use strict';
|
|
|
|
var ToPrimitive = require('./ToPrimitive');
|
|
|
|
var callBound = require('call-bind/callBound');
|
|
|
|
var $replace = callBound('String.prototype.replace');
|
|
|
|
var safeRegexTester = require('safe-regex-test');
|
|
|
|
var isNonDecimal = safeRegexTester(/^0[ob]|^[+-]0x/);
|
|
|
|
// http://262.ecma-international.org/5.1/#sec-9.3
|
|
|
|
module.exports = function ToNumber(value) {
|
|
var prim = ToPrimitive(value, Number);
|
|
if (typeof prim !== 'string') {
|
|
return +prim; // eslint-disable-line no-implicit-coercion
|
|
}
|
|
|
|
var trimmed = $replace(
|
|
prim,
|
|
// eslint-disable-next-line no-control-regex
|
|
/^[ \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u0085]+|[ \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u0085]+$/g,
|
|
''
|
|
);
|
|
if (isNonDecimal(trimmed)) {
|
|
return NaN;
|
|
}
|
|
|
|
return +trimmed; // eslint-disable-line no-implicit-coercion
|
|
};
|