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

just-extend

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

just-extend

extend an object

  • 5.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.3M
decreased by-0.29%
Maintainers
1
Weekly downloads
 
Created

What is just-extend?

The just-extend npm package is a utility library for deep or shallow copying and extending of objects. It allows users to merge properties from source objects into a target object, with the option to perform deep (recursive) merges.

What are just-extend's main functionalities?

Shallow extend

This feature allows the user to merge properties from one or more source objects into a target object. If the same property exists in both objects, the value from the last object will be used.

{"var extend = require('just-extend');
var obj1 = {a: 3, b: 4};
var obj2 = {b: 5, c: 6};
var result = extend(obj1, obj2);
// result is {a: 3, b: 5, c: 6}"}

Deep extend

This feature allows the user to perform a deep merge, where nested objects are also merged together. This is useful when you want to combine objects with nested structures.

{"var extend = require('just-extend');
var obj1 = {a: {b: 3}};
var obj2 = {a: {c: 4}};
var result = extend(true, obj1, obj2);
// result is {a: {b: 3, c: 4}}"}

Extend with customizer function

This feature allows the user to provide a customizer function that determines how values are merged. The customizer function can be used to specify custom merging behavior for specific properties or types of values.

{"var extend = require('just-extend');
var customizer = function(objValue, srcValue) {
  if (Array.isArray(objValue)) {
    return objValue.concat(srcValue);
  }
};
var obj1 = {a: [1, 2], b: 3};
var obj2 = {a: [3, 4], b: 4};
var result = extend(customizer, obj1, obj2);
// result is {a: [1, 2, 3, 4], b: 4}"}

Other packages similar to just-extend

Keywords

FAQs

Package last updated on 31 Oct 2021

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