main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
573 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var callBound = require('call-bind/callBound');
|
---|
| 4 |
|
---|
| 5 | var $TypeError = require('es-errors/type');
|
---|
| 6 | var $deref = callBound('WeakRef.prototype.deref', true);
|
---|
| 7 |
|
---|
| 8 | var isWeakRef = require('is-weakref');
|
---|
| 9 |
|
---|
| 10 | var AddToKeptObjects = require('./AddToKeptObjects');
|
---|
| 11 |
|
---|
| 12 | // https://262.ecma-international.org/12.0/#sec-weakrefderef
|
---|
| 13 |
|
---|
| 14 | module.exports = function WeakRefDeref(weakRef) {
|
---|
| 15 | if (!isWeakRef(weakRef)) {
|
---|
| 16 | throw new $TypeError('Assertion failed: `weakRef` must be a WeakRef');
|
---|
| 17 | }
|
---|
| 18 | var target = $deref(weakRef);
|
---|
| 19 | if (target) {
|
---|
| 20 | AddToKeptObjects(target);
|
---|
| 21 | }
|
---|
| 22 | return target;
|
---|
| 23 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.