mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-28 13:13:37 +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>
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
var GetIntrinsic = require('get-intrinsic');
|
|
|
|
var $Number = GetIntrinsic('%Number%');
|
|
var $TypeError = require('es-errors/type');
|
|
|
|
var $isNaN = require('../helpers/isNaN');
|
|
var $isFinite = require('../helpers/isFinite');
|
|
var isPrefixOf = require('../helpers/isPrefixOf');
|
|
|
|
var ToNumber = require('./ToNumber');
|
|
var ToPrimitive = require('./ToPrimitive');
|
|
|
|
// https://262.ecma-international.org/5.1/#sec-11.8.5
|
|
|
|
// eslint-disable-next-line max-statements
|
|
module.exports = function AbstractRelationalComparison(x, y, LeftFirst) {
|
|
if (typeof LeftFirst !== 'boolean') {
|
|
throw new $TypeError('Assertion failed: LeftFirst argument must be a Boolean');
|
|
}
|
|
var px;
|
|
var py;
|
|
if (LeftFirst) {
|
|
px = ToPrimitive(x, $Number);
|
|
py = ToPrimitive(y, $Number);
|
|
} else {
|
|
py = ToPrimitive(y, $Number);
|
|
px = ToPrimitive(x, $Number);
|
|
}
|
|
var bothStrings = typeof px === 'string' && typeof py === 'string';
|
|
if (!bothStrings) {
|
|
var nx = ToNumber(px);
|
|
var ny = ToNumber(py);
|
|
if ($isNaN(nx) || $isNaN(ny)) {
|
|
return undefined;
|
|
}
|
|
if ($isFinite(nx) && $isFinite(ny) && nx === ny) {
|
|
return false;
|
|
}
|
|
if (nx === Infinity) {
|
|
return false;
|
|
}
|
|
if (ny === Infinity) {
|
|
return true;
|
|
}
|
|
if (ny === -Infinity) {
|
|
return false;
|
|
}
|
|
if (nx === -Infinity) {
|
|
return true;
|
|
}
|
|
return nx < ny; // by now, these are both nonzero, finite, and not equal
|
|
}
|
|
if (isPrefixOf(py, px)) {
|
|
return false;
|
|
}
|
|
if (isPrefixOf(px, py)) {
|
|
return true;
|
|
}
|
|
return px < py; // both strings, neither a prefix of the other. shortcut for steps c-f
|
|
};
|