blob: 2d8cc824673f237cd5190386a9a7260272f0647a [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4
5var $TypeError = GetIntrinsic('%TypeError%');
6
7var IsPropertyKey = require('./IsPropertyKey');
8var ToObject = require('./ToObject');
9
10/**
11 * 7.3.2 GetV (V, P)
12 * 1. Assert: IsPropertyKey(P) is true.
13 * 2. Let O be ToObject(V).
14 * 3. ReturnIfAbrupt(O).
15 * 4. Return O.[[Get]](P, V).
16 */
17
18module.exports = function GetV(V, P) {
19 // 7.3.2.1
20 if (!IsPropertyKey(P)) {
21 throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
22 }
23
24 // 7.3.2.2-3
25 var O = ToObject(V);
26
27 // 7.3.2.4
28 return O[P];
29};