You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

thisSymbolValue.js 520B

12345678910111213141516171819
  1. 'use strict';
  2. var callBound = require('../helpers/callBound');
  3. var $SymbolValueOf = callBound('Symbol.prototype.valueOf', true);
  4. var Type = require('./Type');
  5. // https://ecma-international.org/ecma-262/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. };