Skip to content

Commit

Permalink
Refactor to remove Number.isInteger polyfill (#5302)
Browse files Browse the repository at this point in the history
We will no longer need the polyfill on the next major release (v14).
  • Loading branch information
ybiquitous committed May 14, 2021
1 parent 90a174d commit e4b6141
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions lib/utils/isNonNegativeInteger.js
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;
};

0 comments on commit e4b6141

Please sign in to comment.