-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6022 from video-dev/bugfix/is-safe-integer-polyfill
Add polyfill for isSafeInteger
- Loading branch information
Showing
3 changed files
with
18 additions
and
2 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
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,7 +1,15 @@ | ||
// https://caniuse.com/mdn-javascript_builtins_number_isfinite | ||
export const isFiniteNumber = | ||
Number.isFinite || | ||
function (value) { | ||
return typeof value === 'number' && isFinite(value); | ||
}; | ||
|
||
// https://caniuse.com/mdn-javascript_builtins_number_issafeinteger | ||
export const isSafeInteger = | ||
Number.isSafeInteger || | ||
function (value) { | ||
return typeof value === 'number' && Math.abs(value) <= MAX_SAFE_INTEGER; | ||
}; | ||
|
||
export const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; |
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