Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

object-rewrite

Package Overview
Dependencies
Maintainers
1
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-rewrite - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

4

package.json
{
"name": "object-rewrite",
"version": "1.0.1",
"version": "1.0.2",
"description": "Rewrite an Object",

@@ -10,3 +10,3 @@ "main": "lib/index.js",

"dependencies": {
"object-scan": "1.10.3"
"object-scan": "1.10.4"
},

@@ -13,0 +13,0 @@ "devDependencies": {

@@ -28,12 +28,44 @@ [![Build Status](https://circleci.com/gh/blackflux/object-rewrite.png?style=shield)](https://circleci.com/gh/blackflux/object-rewrite)

const data = [{/* ... */}, {/* ... */}];
const data = [{
guid: "aad8b948-a3de-4bff-a50f-3d59e9510aa9",
count: 3,
active: true,
tags: [{ id: 1 }, { id: 2 }, { id: 3 }]
}, {
guid: "4409fb72-36e3-4385-b3da-b4944d028dcb",
count: 4,
active: true,
tags: [{ id: 2 }, { id: 3 }, { id: 4 }]
}, {
guid: "96067a3c-caa2-4018-bcec-6969a874dad9",
count: 5,
active: false,
tags: [{ id: 3 }, { id: 4 }, { id: 5 }]
}];
const rewriter = objectRewrite({
exclude: {/* ... */},
inject: {/* ... */},
include: [/* ... */]
exclude: {
"": (key, value) => value.active !== true,
tags: (key, value) => value.id !== 4
},
inject: {
"": (key, value) => ({ count: value.count + 100 })
},
include: ["count", "active", "tags.id"]
});
rewriter(data);
// => data is now modified
/*
[{
"count": 103,
"active": true,
"tags": []
}, {
"count": 104,
"active": true,
"tags": [{"id": 4}]
}]
*/
```

@@ -40,0 +72,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc