Skip to content
Permalink
Newer
Older
100644 22 lines (17 sloc) 557 Bytes
Ignoring revisions in .git-blame-ignore-revs.
September 14, 2020 10:42
1
'use strict';
2
July 27, 2021 16:54
3
var GetIntrinsic = require('get-intrinsic');
4
var callBound = require('call-bind/callBound');
September 14, 2020 10:42
5
6
var $SyntaxError = GetIntrinsic('%SyntaxError%');
September 14, 2020 10:42
7
var $bigIntValueOf = callBound('BigInt.prototype.valueOf', true);
8
9
var Type = require('./Type');
10
July 27, 2021 16:54
11
// https://262.ecma-international.org/11.0/#sec-thisbigintvalue
September 14, 2020 10:42
12
13
module.exports = function thisBigIntValue(value) {
14
var type = Type(value);
15
if (type === 'BigInt') {
16
return value;
17
}
18
if (!$bigIntValueOf) {
19
throw new $SyntaxError('BigInt is not supported');
September 14, 2020 10:42
20
}
21
return $bigIntValueOf(value);
22
};