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

Rewrite an Object

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
701
increased by235.41%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status Test Coverage Dependabot Status Dependencies NPM Downloads Semantic-Release Gardener

object-rewrite

Rewrite an Object by defining exactly what gets excluded, rewritten and included.

Install

npm i --save object-rewrite

Getting Started

Modify the data object in place. If you need to create a copy consider using _.deepClone().

const objectRewrite = require("object-rewrite");

const data = [{/* ... */}, {/* ... */}];

const rewriter = objectRewrite({
  exclude: {/* ... */},
  inject: {/* ... */},
  include: [/* ... */]
});

rewriter(data);
// => data is now modified

The empty needle "" matches top level objects when data is an array.

Modifiers

Needles are specified according to object-scan.

Internally the option useArraySelector is set to false.

Functions have signature Fn(key, value, parents) as specified by object-scan. Keys are split (joined = false),

Exclude

Takes object where keys are needles and values are functions. The matches for a needle are excluded from the rewritten object iff the function returns true.

Inject

Takes object where keys are needles and values are functions. The result of the function is merged into every match for the needle. Both, the match and the function response, are expected to be objects.

Include

Array of all fields that are included in the modified object. All entries not matched are excluded.

Keywords

FAQs

Package last updated on 06 Oct 2018

Did you know?

Socket

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.

Install

Related posts

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