ToPropertyKey.js 405 B

123456789101112131415
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $String = GetIntrinsic('%String%');
  4. var ToPrimitive = require('./ToPrimitive');
  5. var ToString = require('./ToString');
  6. // https://ecma-international.org/ecma-262/6.0/#sec-topropertykey
  7. module.exports = function ToPropertyKey(argument) {
  8. var key = ToPrimitive(argument, $String);
  9. return typeof key === 'symbol' ? key : ToString(key);
  10. };