Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The nanoclone npm package is a lightweight utility for deep cloning JavaScript objects. It is designed to be simple and efficient, making it a useful tool for copying objects without retaining references to the original objects.
Deep Cloning
This feature allows you to create a deep copy of an object, ensuring that nested objects are also cloned and not just referenced.
const clone = require('nanoclone');
const original = { a: 1, b: { c: 2 } };
const copy = clone(original);
console.log(copy); // { a: 1, b: { c: 2 } }
console.log(copy.b === original.b); // false
Lodash's `cloneDeep` function provides similar functionality for deep cloning objects. It is part of the larger Lodash utility library, which offers a wide range of functions for manipulating and traversing data structures. Compared to nanoclone, lodash.clonedeep is more feature-rich but also larger in size.
The `rfdc` (Really Fast Deep Clone) package is another alternative for deep cloning objects. It is designed to be extremely fast and efficient, making it a good choice for performance-critical applications. Like nanoclone, it focuses solely on deep cloning, but it is optimized for speed.
The `clone-deep` package is another utility for deep cloning objects. It supports cloning of various data types, including arrays, buffers, and more. It is more versatile than nanoclone but also slightly larger in size.
Only 300B to deep clone JavaScript objects
See the size of the most popular clone npm package with 250M+ downloads
And nanoclone size:
yarn add nanoclone
npm install nanoclone
import clone from 'nanoclone'
let a = {
num: 2,
arr: [1, 2, 3],
nested: {
obj: {
a: 0
}
}
}
let b = clone(a)
MIT
FAQs
300B to deep clone JavaScript objects
We found that nanoclone 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.