mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
util: use ES2015+ Object.is to check negative zero
Use `Object.is` to check whether the value is negative zero or not. Ref: https://github.com/nodejs/node/commit/b3e4fc6a48b97b52bd19de43c76b7082dcab4988 PR-URL: https://github.com/nodejs/node/pull/11332 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
e7b7d7279c
commit
e54b433c8d
1 file changed
+2
-3
+2
-3
@@ -598,9 +598,8 @@ function formatValue(ctx, value, recurseTimes) {
|
||||
|
||||
|
||||
function formatNumber(ctx, value) {
|
||||
// Format -0 as '-0'. Strict equality won't distinguish 0 from -0,
|
||||
// so instead we use the fact that 1 / -0 < 0 whereas 1 / 0 > 0 .
|
||||
if (value === 0 && 1 / value < 0)
|
||||
// Format -0 as '-0'. Strict equality won't distinguish 0 from -0.
|
||||
if (Object.is(value, -0))
|
||||
return ctx.stylize('-0', 'number');
|
||||
return ctx.stylize('' + value, 'number');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user