summaryrefslogtreecommitdiff
path: root/src/node_modules/es-abstract/2020/thisBigIntValue.js
blob: 1389247a3cacf03879d3f9d994117256baeb7300 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'use strict';

var GetIntrinsic = require('../GetIntrinsic');
var callBound = require('../helpers/callBound');

var $TypeError = GetIntrinsic('%TypeError%');
var $bigIntValueOf = callBound('BigInt.prototype.valueOf', true);

var Type = require('./Type');

// https://tc39.es/ecma262/2020/#sec-thisbigintvalue

module.exports = function thisBigIntValue(value) {
	var type = Type(value);
	if (type === 'BigInt') {
		return value;
	}
	if (!$bigIntValueOf) {
		throw new $TypeError('BigInt is not supported');
	}
	return $bigIntValueOf(value);
};