GetV.js 474 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $TypeError = GetIntrinsic('%TypeError%');
  4. var IsPropertyKey = require('./IsPropertyKey');
  5. var ToObject = require('./ToObject');
  6. // https://ecma-international.org/ecma-262/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');
  11. }
  12. // 7.3.2.2-3
  13. var O = ToObject(V);
  14. // 7.3.2.4
  15. return O[P];
  16. };