ThisBigIntValue.js 472 B

123456789101112131415161718
  1. 'use strict';
  2. var callBound = require('call-bind/callBound');
  3. var $SyntaxError = require('es-errors/syntax');
  4. var $bigIntValueOf = callBound('BigInt.prototype.valueOf', true);
  5. // https://262.ecma-international.org/15.0/#sec-thisbigintvalue
  6. module.exports = function ThisBigIntValue(value) {
  7. if (typeof value === 'bigint') {
  8. return value; // step 1
  9. }
  10. if (!$bigIntValueOf) {
  11. throw new $SyntaxError('BigInt is not supported');
  12. }
  13. return $bigIntValueOf(value);
  14. };