AddToKeptObjects.js 593 B

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