Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@digitregroup/object-mapper
Advanced tools
Readme
Makes object-to-object transformation easy.
const sourceObject = {
fabfour: { user_count: 4 },
user: [
{
first: 'John',
last: 'Lennon',
instruments: [
{ name: 'Guitar', colour: 'Red' },
{ name: 'Bass guitar', colour: 'Blue' }
]
},
{
first: 'Paul',
last: 'McCartney',
picture: ['picture0.jpg', 'picture1.png', 'picture2.gif' ]
},
{ first: 'George', last: 'Harrison' },
{ first: 'Ringo', last: 'Starr' }
]
};
const mapping = {
'ringo.last_name': 'user[first=Ringo].last',
'paul.pictures': 'user.1.picture[]',
'john.bass.colour': 'user.0.instruments.1.colour',
'amount_of_band_members': 'fabfour.user_count',
};
const result = ObjectMapper.mapItem(sourceObject, mapping);
//{
// "ringo": {
// "last_name": "Starr"
// },
// "paul": {
// "pictures": [
// "picture0.jpg",
// "picture1.png",
// "picture2.gif"
// ]
// },
// "john": {
// "bass": {
// "colour": "Blue"
// }
// },
// "amount_of_band_members": 4
//}
Dot notation matching
ObjectMapper.mapItem (
{parent: {child: {value: 'bar'}}},
{result: 'parent.child.value'}
);
// {"result":"bar"}
Query matching
ObjectMapper.mapItem (
{
children: [
{name: 'foo', value: 'bar'},
{name: 'baz', value: 'biz'}
]
},
{result: 'children[name=baz].value'}
);
// {"result":"biz"}
Data transformation
ObjectMapper.mapItem (
{
user: {
name: 'lennon',
firstname: 'john'
}
},
{
'result': [
'user.name',
name => name.toUpperCase(),
uppername => uppername.split('')
]
}
);
// {"result":["L","E","N","N","O","N"]}
Dot notation object conversion
ObjectMapper.mapItem (
{foo: 'bar'},
{'target.name.can.be.anything.0': 'foo'}
);
// {"target":{"name":{"can":{"be":{"anything":["bar"]}}}}}
npm install --save @digitregroup/object-mapper
Package | Version | Dev |
---|---|---|
flat | ^4.1.0 | ✖ |
chai | ^4.2.0 | ✔ |
cross-env | ^5.2.0 | ✔ |
laravel-mix | ^4.0.14 | ✔ |
mocha | ^6.0.2 | ✔ |
nyc | ^13.3.0 | ✔ |
vue-template-compiler | ^2.6.7 | ✔ |
Contributions welcome; Please submit all pull requests against the develop branch. If your pull request contains JavaScript patches or features, you should include relevant unit tests. Thanks!
DigitRE Group
FAQs
Makes object-to-object transformation easy.
The npm package @digitregroup/object-mapper receives a total of 15 weekly downloads. As such, @digitregroup/object-mapper popularity was classified as not popular.
We found that @digitregroup/object-mapper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.