Skip to content

Commit

Permalink
[Robustness] ES2017+: NumberToRawBytes, NumericToRawBytes: use …
Browse files Browse the repository at this point in the history
…`SameValue` instead of `Object.is`
  • Loading branch information
ljharb committed Jun 7, 2023
1 parent a36004f commit b2c2e6c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion 2017/NumberToRawBytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var $strSlice = callBound('String.prototype.slice');

var abs = require('./abs');
var hasOwnProperty = require('./HasOwnProperty');
var SameValue = require('./SameValue');
var ToInt16 = require('./ToInt16');
var ToInt32 = require('./ToInt32');
var ToInt8 = require('./ToInt8');
Expand Down Expand Up @@ -83,7 +84,7 @@ module.exports = function NumberToRawBytes(type, value, isLittleEndian) {
var leastSig;

if (value === 0) {
leastSig = Object.is(value, -0) ? 0x80 : 0;
leastSig = SameValue(value, -0) ? 0x80 : 0;
return isLittleEndian ? [0, 0, 0, leastSig] : [leastSig, 0, 0, 0];
}

Expand Down
3 changes: 2 additions & 1 deletion 2018/NumberToRawBytes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion 2019/NumberToRawBytes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion 2020/NumericToRawBytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var $strSlice = callBound('String.prototype.slice');

var abs = require('./abs');
var hasOwnProperty = require('./HasOwnProperty');
var SameValue = require('./SameValue');
var ToBigInt64 = require('./ToBigInt64');
var ToBigUint64 = require('./ToBigUint64');
var ToInt16 = require('./ToInt16');
Expand Down Expand Up @@ -91,7 +92,7 @@ module.exports = function NumericToRawBytes(type, value, isLittleEndian) {
var leastSig;

if (value === 0) {
leastSig = Object.is(value, -0) ? 0x80 : 0;
leastSig = SameValue(value, -0) ? 0x80 : 0;
return isLittleEndian ? [0, 0, 0, leastSig] : [leastSig, 0, 0, 0];
}

Expand Down
3 changes: 2 additions & 1 deletion 2021/NumericToRawBytes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion 2022/NumericToRawBytes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b2c2e6c

Please sign in to comment.