UNPKG

@instana/collector

Version:

The Instana Node.js metrics and trace data collector

23 lines (20 loc) 441 B
/* * (c) Copyright IBM Corp. 2021 * (c) Copyright Instana Inc. and contributors 2019 */ 'use strict'; /** * @returns {(key: string, value: *) => *} */ module.exports = function createCircularReferencesRemover() { const seen = new WeakSet(); return (_key, value) => { if (typeof value === 'object' && value !== null) { if (seen.has(value)) { return; } seen.add(value); } return value; }; };