UNPKG

423 BJavaScriptView Raw
1'use strict';
2var toPrimitive = require('../internals/to-primitive');
3
4var $TypeError = TypeError;
5
6// `ToBigInt` abstract operation
7// https://tc39.es/ecma262/#sec-tobigint
8module.exports = function (argument) {
9 var prim = toPrimitive(argument, 'number');
10 if (typeof prim == 'number') throw new $TypeError("Can't convert number to bigint");
11 // eslint-disable-next-line es/no-bigint -- safe
12 return BigInt(prim);
13};