InstallErrorCause.js 706 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $TypeError = GetIntrinsic('%TypeError%');
  4. var CreateNonEnumerableDataPropertyOrThrow = require('./CreateNonEnumerableDataPropertyOrThrow');
  5. var Get = require('./Get');
  6. var HasProperty = require('./HasProperty');
  7. var Type = require('./Type');
  8. // https://262.ecma-international.org/13.0/#sec-installerrorcause
  9. module.exports = function InstallErrorCause(O, options) {
  10. if (Type(O) !== 'Object') {
  11. throw new $TypeError('Assertion failed: Type(O) is not Object');
  12. }
  13. if (Type(options) === 'Object' && HasProperty(options, 'cause')) {
  14. var cause = Get(options, 'cause');
  15. CreateNonEnumerableDataPropertyOrThrow(O, 'cause', cause);
  16. }
  17. };