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.

GetV.js 571B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. var GetIntrinsic = require('../GetIntrinsic');
  3. var $TypeError = GetIntrinsic('%TypeError%');
  4. var IsPropertyKey = require('./IsPropertyKey');
  5. var ToObject = require('./ToObject');
  6. /**
  7. * 7.3.2 GetV (V, P)
  8. * 1. Assert: IsPropertyKey(P) is true.
  9. * 2. Let O be ToObject(V).
  10. * 3. ReturnIfAbrupt(O).
  11. * 4. Return O.[[Get]](P, V).
  12. */
  13. module.exports = function GetV(V, P) {
  14. // 7.3.2.1
  15. if (!IsPropertyKey(P)) {
  16. throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
  17. }
  18. // 7.3.2.2-3
  19. var O = ToObject(V);
  20. // 7.3.2.4
  21. return O[P];
  22. };