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.
The fclone npm package is designed to provide deep cloning functionality for JavaScript objects. It ensures that complex objects, including those with circular references, are cloned accurately without losing any data or structure.
Deep Cloning
This feature allows you to create a deep clone of an object, ensuring that nested objects are also cloned rather than referenced.
const fclone = require('fclone');
const original = { a: 1, b: { c: 2 } };
const clone = fclone(original);
console.log(clone); // { a: 1, b: { c: 2 } }
Handling Circular References
fclone can handle objects with circular references, ensuring that the clone maintains the same structure without causing infinite loops.
const fclone = require('fclone');
const obj = { a: 1 };
obj.self = obj;
const clone = fclone(obj);
console.log(clone); // { a: 1, self: [Circular] }
Cloning Arrays
This feature allows you to deep clone arrays, ensuring that nested objects within the array are also cloned.
const fclone = require('fclone');
const original = [1, 2, { a: 3 }];
const clone = fclone(original);
console.log(clone); // [1, 2, { a: 3 }]
Lodash is a utility library that provides a wide range of functions, including deep cloning with `_.cloneDeep`. It is more feature-rich compared to fclone, offering many other utilities for data manipulation.
rfdc (Really Fast Deep Clone) is a lightweight and fast deep cloning library. It is designed for performance and is faster than fclone, but it may not handle all edge cases as comprehensively.
clone-deep is another library focused on deep cloning. It offers similar functionality to fclone but with additional options for customizing the cloning process.
This module clones a Javascript object in safe mode (eg: drops circular values) recursively. Circular values are replaced with a string: '[Circular]'
.
Ideas from tracker1/safe-clone-deep. I improved the workflow a bit by:
Array.isArray
and Buffer.isBuffer
npm install fclone
# or
bower install fclone
const fclone = require('fclone')
let a = {b: a, c: 'hello'}
let o = fclone(a)
console.log(o)
// outputs: { c: 'hello', b: '[Circular]' }
Some benchs:
fclone x 13,342 ops/sec ±3.83% (79 runs sampled)
fclone + json.stringify x 7,311 ops/sec ±3.99% (77 runs sampled)
jsan x 4,419 ops/sec ±3.11% (86 runs sampled)
circularjson x 4,294 ops/sec ±0.82% (91 runs sampled)
deepcopy x 5,298 ops/sec ±0.76% (83 runs sampled)
json-stringify-safe x 5,201 ops/sec ±0.82% (84 runs sampled)
Fastest is fclone
FAQs
Clone objects by dropping circular references
The npm package fclone receives a total of 1,098,054 weekly downloads. As such, fclone popularity was classified as popular.
We found that fclone 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.