thisSymbolValue.js 514 B

12345678910111213141516171819
  1. 'use strict';
  2. var callBound = require('call-bind/callBound');
  3. var $SymbolValueOf = callBound('Symbol.prototype.valueOf', true);
  4. var Type = require('./Type');
  5. // https://262.ecma-international.org/9.0/#sec-thissymbolvalue
  6. module.exports = function thisSymbolValue(value) {
  7. if (!$SymbolValueOf) {
  8. throw new SyntaxError('Symbols are not supported; thisSymbolValue requires that `value` be a Symbol or a Symbol object');
  9. }
  10. if (Type(value) === 'Symbol') {
  11. return value;
  12. }
  13. return $SymbolValueOf(value);
  14. };