New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@marxlnfcs/smart-merge

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@marxlnfcs/smart-merge

Simple library for merging objects and array.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-87.5%
Maintainers
0
Weekly downloads
 
Created
Source

Smart Merge

A simple library for merging objects and arrays

NPM Version Package License NPM Downloads Package Size

Installation

npm i @marxlnfcs/smart-merge

Usage

import { smartMerge } from '@marxlnfcs/smart-merge';

// objects
const objectA: any = { ... };
const objectB: any = { ... };

// merge both objects into one
const objectC = smartMerge(objectA, objectB, {
  matchSimilarKeys: false,
  cloneObject: true,
  prioritizedKeys: [
    ['apiVersion', 'kind', 'metadata.name', 'metadata.namespace'], // prioritize items that have all of the defined keys and all keys are the same
    ['name'],
  ],
});

Options

 /**
 * The prioritized keys checking for keys in arrays that are the same. If one of the prioritized keys matches, the array will
 * be merged based of the keys as identifiers. Otherwise, is searches for "similar" keys and merges them if enabled.
 * @default []
 */
prioritizedKeys: Array<string[]>;

/**
 * If true and no key of the prioritizedKeys matches, it searches for a similar key used in the array. If false, it will just append the item to the array.
 * @default true
 */
matchSimilarKeys: boolean;

/**
 * Set to true, if the output object should be cloned or not.
 * @default true
 */
cloneObject: boolean;

FAQs

Package last updated on 10 Nov 2024

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