
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
decircularize
Advanced tools
Remove circular dependencies. It also functions as a deep-copy, to ensure that the input is never mutated and that the output can be trusted, even if there are no issues with circular structures.
The default behavior replaces the dependencies with a string suitable for debugging.
import decircularize from 'decircularize'
var obj = {
a: 1,
b: { something: 2 }
}
obj.b.bad = obj
obj.b.alsoBad = obj.b
JSON.stringify(obj) // explodes
JSON.stringify(decircularize(obj), null, 2)
/* returns
{
a: 1,
b: {
something: 2,
bad: '[Circular to: <root>]',
alsoBad: '[Circular to: <root>.b]'
}
}
*/
This can easily be overridden for any custom need. For example, imagine a REST
API where each entity have an id
prop that uniquely identifies it:
import decircularize from 'decircularize'
var obj = {
id: '123',
b: {
id: 'abc',
entities: [ 2 ]
}
}
obj.b.entities.push(obj.b)
decircularize(obj, {
onCircular: (object, otherPath, offendingPath) => {
assert(object === obj.b)
// In this instance, otherPath equals [ '<root>', 'b' ]
// and offendingPath equals [ '<root>', 'b', 'entities', 1 ]
return { id: object.id }
}
})
/* returns
{
a: 1,
b: {
id: 'abc',
entities: [
2,
{ id: 'abc' }
]
}
}
*/
FAQs
Remove circular dependencies
The npm package decircularize receives a total of 71 weekly downloads. As such, decircularize popularity was classified as not popular.
We found that decircularize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.