GetV.js 536 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $TypeError = GetIntrinsic('%TypeError%');
  4. var inspect = require('object-inspect');
  5. var IsPropertyKey = require('./IsPropertyKey');
  6. // var ToObject = require('./ToObject');
  7. // https://262.ecma-international.org/6.0/#sec-getv
  8. module.exports = function GetV(V, P) {
  9. // 7.3.2.1
  10. if (!IsPropertyKey(P)) {
  11. throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true, got ' + inspect(P));
  12. }
  13. // 7.3.2.2-3
  14. // var O = ToObject(V);
  15. // 7.3.2.4
  16. return V[P];
  17. };