Git Product home page Git Product logo

node.extend's Introduction

node.extend

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

Build Status 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

License

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

node.extend's People

Contributors

ljharb avatar ben-lin avatar jasonkarns avatar

Watchers

James Cloos avatar Gonzalo De Spírito avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.