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.
data transform object for javascript
var data = {
name: '张三',
age: '0',
hello: {
world: 1489470599650
},
list: [
{a: 1},
{b: 2},
{c: 3}
]
}
// 可以通过 src 参数 或者 this 来获得 data,并且是深拷贝,不影响原对象
// 也可以直接传入 object path 来赋给一个新 key
var convert = {
userName: 'name',
age: function (src) {
return parseInt(src.age)
},
helloWorld: function () {
return new Date(this.hello.world)
},
hello_world: 'hello.world',
array: 'list',
arrayFirst: 'list[0]',
foo: {
bar: {
baz: function () {
return this.list[0].a * 666
}
}
}
}
console.log(dto4j(convert, data))
// {
// userName: '张三',
// age: 0,
// helloWorld: 'Tue Mar 14 2017 13:49:59 GMT+0800 (CST)',
// hello_world: 1489470599650,
// array: [ { a: 1 }, { b: 2 }, { c: 3 } ],
// arrayFirst: { a: 1 },
// foo: { bar: { baz: 666 } }
// }
// 也可以传入一个参数,返回一个 dto 转换器,以便后面执行多次转换
var dto1 = dto4j(convert)
console.log(dto1(data))
// console.log(dto1(data2))
// console.log(dto1(data3))
FAQs
> data transform object for javascript
The npm package dto4j receives a total of 0 weekly downloads. As such, dto4j popularity was classified as not popular.
We found that dto4j 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.