
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
normalize-obj
Advanced tools
Rename keys, and/or change structure of an object.
npm install normalize-obj --save
var normalize = require('normalize-obj');
var object = {name: 'Darlan', age: 25, address: {num: '117'}};
var normalized = normalize(object).change('name', 'fullname');
// => {fullname: 'Darlan', age: 25, address: {num: '117'}};
Methods can be chained, example:
normalize(object)
.change('name', 'fullname')
.change('age', 'old');
// => {fullname: 'Darlan', old: 25, address: {num: '117'}};
Accept nesting keys, with dot syntax, to change key name
normalize(object).change('address.num', 'address.number');
// => {name: 'Darlan', age: 25, address: {number: '117'}};
or change structure too
normalize(object).change('address.num', 'number');
// => {name: 'Darlan', age: 25, number: '117'};
On change structure, like below, if old structure don't have others properties, there are deleted. I.e:
var object = {
address: {
street: 'Paulista',
country: 'br',
num: '1107'
},
phone: {
mobile: '0000-0000'
}
};
normalize(object).change('address.num', 'number');
/* =>
{
number: 1107,
// keep address, because have others properties
address: {
street: 'Paulista',
country: 'br'
},
phone: {
mobile: '0000-0000'
}
};
*/
// now, if dont have properties
normalize(object).change('phone.mobile', 'mobile');
/* =>
{
number: 1107,
address: {
street: 'Paulista',
country: 'br'
},
mobile: '0000-0000'
// delete phone, because don't have others properties
};
*/
And offer method to copy field
normalize(object).copy('address.num', 'number');
// => {name: 'Darlan', age: 25, address: {num: '117'}, number: '117'};
npm test
FAQs
Rename keys, and change structure of an object
The npm package normalize-obj receives a total of 0 weekly downloads. As such, normalize-obj popularity was classified as not popular.
We found that normalize-obj demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.