main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 2 weeks ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
844 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var hasBigInts = require('has-bigints')();
|
---|
| 4 |
|
---|
| 5 | if (hasBigInts) {
|
---|
| 6 | var bigIntValueOf = BigInt.prototype.valueOf;
|
---|
[79a0317] | 7 | /** @type {(value: object) => value is BigInt} */
|
---|
[d565449] | 8 | var tryBigInt = function tryBigIntObject(value) {
|
---|
| 9 | try {
|
---|
| 10 | bigIntValueOf.call(value);
|
---|
| 11 | return true;
|
---|
| 12 | } catch (e) {
|
---|
| 13 | }
|
---|
| 14 | return false;
|
---|
| 15 | };
|
---|
| 16 |
|
---|
[79a0317] | 17 | /** @type {import('.')} */
|
---|
[d565449] | 18 | module.exports = function isBigInt(value) {
|
---|
| 19 | if (
|
---|
| 20 | value === null
|
---|
| 21 | || typeof value === 'undefined'
|
---|
| 22 | || typeof value === 'boolean'
|
---|
| 23 | || typeof value === 'string'
|
---|
| 24 | || typeof value === 'number'
|
---|
| 25 | || typeof value === 'symbol'
|
---|
| 26 | || typeof value === 'function'
|
---|
| 27 | ) {
|
---|
| 28 | return false;
|
---|
| 29 | }
|
---|
| 30 | if (typeof value === 'bigint') {
|
---|
| 31 | return true;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | return tryBigInt(value);
|
---|
| 35 | };
|
---|
| 36 | } else {
|
---|
[79a0317] | 37 | /** @type {import('.')} */
|
---|
[d565449] | 38 | module.exports = function isBigInt(value) {
|
---|
| 39 | return false && value;
|
---|
| 40 | };
|
---|
| 41 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.