GetV.js 488 B

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