OrdinaryHasProperty.js 496 B

123456789101112131415161718
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. var isObject = require('../helpers/isObject');
  4. var isPropertyKey = require('../helpers/isPropertyKey');
  5. // https://262.ecma-international.org/6.0/#sec-ordinaryhasproperty
  6. module.exports = function OrdinaryHasProperty(O, P) {
  7. if (!isObject(O)) {
  8. throw new $TypeError('Assertion failed: Type(O) is not Object');
  9. }
  10. if (!isPropertyKey(P)) {
  11. throw new $TypeError('Assertion failed: P must be a Property Key');
  12. }
  13. return P in O;
  14. };