Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
This module supports making copy / clone deeply and faster.
It needs to be defined an object structure and the module will analyse the structure. If it isn't defined, it will be defined when it is called first time.
If it is called, functions which have the structure will be made.
alias: deep, copy
The deep clone will be made by defined structure.
If the key isn't defined, define
will be called and then the deep clone function will be called.
The shallow clone will be made.
var structure = {
a: 1,
b: 'default',
c: [undefined, undefined],
d: { d1: true }
};
var obj = {
a: 10,
c: [1, 2],
d: {}
};
dcp.define('test', structure);
var newObj = dcp.clone('test', obj);
/*
* { a: 10,
* b: '',
* c: [1, 2],
* d: { d1: false } }
*/
// or
var clone = dcp.clone('test', structure);
var newObj = clone(obj);
// or
dcp.define('test', structure);
var clone = dcp.clone('test');
var newObj = clone(obj);
// or
var newObj = dcp.clone('test', obj);
var obj = {
a: 1,
b: 'test',
c: [true, false, { c1: 'a' }],
d: { d1: { d11: { d111: { d1111: 0 }, d112: 1 } } }
};
dcp.define('test', obj);
dcp.clone('test', obj);
JSON.parse(JSON.stringify(obj));
_.cloneDeep(obj);
/*
* **** benchmark.js ****
* [1] "dcp" 0.00052ms [1.00]
* [2] "JSON.parse" 0.020ms [37.6]
* [3] "cloneDeep" 0.041ms [78.5]
*/
var obj = _.mapValues(_.times(10), function(num) {
return _.mapValues(_.times(num), function(num) {
return _.mapValues(_.times(num));
});
});
/*
* **** benchmark.js ****
* [1] "dcp" 0.15ms [1.00]
* [2] "JSON.parse" 0.47ms [3.11]
* [3] "cloneDeep" 1.1ms [7.55]
*/
FAQs
[![npm](https://img.shields.io/npm/v/dcp.svg)](https://www.npmjs.com/package/dcp)
The npm package dcp receives a total of 1,246 weekly downloads. As such, dcp popularity was classified as popular.
We found that dcp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.