AddToKeptObjects.js 645 B

123456789101112131415161718192021
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var callBound = require('call-bind/callBound');
  4. var SLOT = require('internal-slot');
  5. var $TypeError = GetIntrinsic('%TypeError%');
  6. var ClearKeptObjects = require('./ClearKeptObjects');
  7. var Type = require('./Type');
  8. var $push = callBound('Array.prototype.push');
  9. // https://ecma-international.org/ecma-262/12.0/#sec-addtokeptobjects
  10. module.exports = function AddToKeptObjects(object) {
  11. if (Type(object) !== 'Object') {
  12. throw new $TypeError('Assertion failed: `object` must be an Object');
  13. }
  14. $push(SLOT.get(ClearKeptObjects, '[[es-abstract internal: KeptAlive]]'), object);
  15. };