1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/traverse/examples/scrub.js

13 lines
253 B
JavaScript
Raw Normal View History

2024-01-16 21:26:16 +08:00
'use strict';
2023-12-18 13:12:25 +08:00
// scrub out circular references
var traverse = require('traverse');
2024-01-16 21:26:16 +08:00
var obj = { a: 1, b: 2, c: [3, 4] };
2023-12-18 13:12:25 +08:00
obj.c.push(obj);
2024-01-16 21:26:16 +08:00
var scrubbed = traverse(obj).map(function () {
if (this.circular) { this.remove(); }
2023-12-18 13:12:25 +08:00
});
console.dir(scrubbed);