Skip to content

Commit

Permalink
[Fix] ES2020+: abs should accept bigints too
Browse files Browse the repository at this point in the history
Technically it only accepts mathematical values, but JS doesn‘t have those, so it accepts all numerics instead
  • Loading branch information
ljharb committed Jan 20, 2025
1 parent 0a25934 commit c408c8a
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 17 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,6 @@
/2020/WeekDay.js spackled linguist-generated=true
/2020/WordCharacters.js spackled linguist-generated=true
/2020/YearFromTime.js spackled linguist-generated=true
/2020/abs.js spackled linguist-generated=true
/2020/max.js spackled linguist-generated=true
/2020/min.js spackled linguist-generated=true
/2020/modulo.js spackled linguist-generated=true
Expand Down
2 changes: 1 addition & 1 deletion 2015/abs.js

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

2 changes: 1 addition & 1 deletion 2016/abs.js

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

2 changes: 1 addition & 1 deletion 2017/abs.js

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

2 changes: 1 addition & 1 deletion 2018/abs.js

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

2 changes: 1 addition & 1 deletion 2019/abs.js

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

4 changes: 2 additions & 2 deletions 2020/abs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

var $abs = require('math-intrinsics/abs');

// http://262.ecma-international.org/5.1/#sec-5.2
// https://262.ecma-international.org/11.0/#eqn-abs

module.exports = function abs(x) {
return $abs(x);
return typeof x === 'bigint' ? BigInt($abs(Number(x))) : $abs(x);
};
4 changes: 2 additions & 2 deletions 2021/abs.js

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

4 changes: 2 additions & 2 deletions 2022/abs.js

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

4 changes: 2 additions & 2 deletions 2023/abs.js

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

4 changes: 2 additions & 2 deletions 2024/abs.js

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

2 changes: 1 addition & 1 deletion 5/abs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var $abs = require('math-intrinsics/abs');

// http://262.ecma-international.org/5.1/#sec-5.2
// https://262.ecma-international.org/5.1/#sec-5.2

module.exports = function abs(x) {
return $abs(x);
Expand Down

0 comments on commit c408c8a

Please sign in to comment.