-
-
Notifications
You must be signed in to change notification settings - Fork 929
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to remove
Number.isInteger
polyfill (#5302)
We will no longer need the polyfill on the next major release (v14).
- Loading branch information
1 parent
90a174d
commit e4b6141
Showing
1 changed file
with
2 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,8 @@ | ||
'use strict'; | ||
|
||
// TODO: We need this polyfill because of the support of Node 10. | ||
// When we will drop Node 10, please remove this polyfill. | ||
// See <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger> | ||
const isInteger = | ||
Number.isInteger || | ||
function (value) { | ||
return typeof value === 'number' && isFinite(value) && Math.floor(value) === value; | ||
}; | ||
|
||
/** | ||
* @param {unknown} value | ||
*/ | ||
module.exports = function (value) { | ||
return isInteger(value) && typeof value === 'number' && value >= 0; | ||
module.exports = function isNonNegativeInteger(value) { | ||
return Number.isInteger(value) && typeof value === 'number' && value >= 0; | ||
}; |