Socket
Socket
Sign inDemoInstall

node.extend

Package Overview
Dependencies
3
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node.extend

A port of jQuery.extend that actually works on node.js


Version published
Weekly downloads
485K
decreased by-22.93%
Maintainers
2
Install size
125 kB
Created
Weekly downloads
 

Readme

Source

node.extend

A port of jQuery.extend that actually works on node.js

Build Status dependency status dev dependency status

browser support

Description

None of the existing ones on npm really work therefore I ported it myself.

Usage

To install this module in your current working directory (which should already contain a package.json), run

npm install node.extend

You can additionally just list the module in your package.json and run npm install.

Then, require this package where you need it:

var extend = require('node.extend');

The syntax for merging two objects is as follows:

var destObject = extend({}, sourceObject);
// Where sourceObject is the object whose properties will be copied into another.
// NOTE: In this situation, this is not a deep merge. See below on how to handle a deep merge.

For information about how the clone works internally, view source in lib/extend.js or checkout the doc from jQuery

A Note About Deep Merge (avoiding pass-by-reference cloning)

In order to force a deep merge, when extending an object, you must pass boolean true as the first argument to extend:

var destObject = extend(true, {}, sourceObject);
// Where sourceObject is the object whose properties will be copied into another.

See this article for more information about the need for deep merges in JavaScript.

Credit

  • Jordan Harband @ljharb

License

Copyright 2011, John Resig Dual licensed under the MIT or GPL Version 2 licenses. http://jquery.org/license

Keywords

FAQs

Last updated on 21 Oct 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc