Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! src: add WeakReference utility
  • Loading branch information
addaleax committed Feb 8, 2019
commit fa56b3542b7d405ef0d734e0616dcf0ceee6bae2
2 changes: 1 addition & 1 deletion src/node_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ using v8::Array;
using v8::Boolean;
using v8::Context;
using v8::Function;
using v8::FunctionTemplate;
using v8::FunctionCallbackInfo;
using v8::FunctionTemplate;
using v8::IndexFilter;
using v8::Integer;
using v8::Isolate;
Expand Down
17 changes: 17 additions & 0 deletions test/parallel/test-internal-util-weakreference.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Flags: --expose-internals --expose-gc
'use strict';
require('../common');
const assert = require('assert');
const { internalBinding } = require('internal/test/binding');
const { WeakReference } = internalBinding('util');

let obj = { hello: 'world' };
const ref = new WeakReference(obj);
assert.strictEqual(ref.get(), obj);

setImmediate(() => {
obj = null;
global.gc();

assert.strictEqual(ref.get(), undefined);
});