Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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 38 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.