InstallErrorCause.js 658 B

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