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

extendr

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extendr

Utilities for cloning, extending, and de-referencing objects in shallow, deep, and safe ways

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
44K
increased by1.34%
Maintainers
1
Weekly downloads
 
Created
Source

Extendr

Build Status NPM version Flattr this project

Utilities for cloning, extending, and de-referencing objects in shallow, deep, and safe ways

Install

Backend

  1. Install Node.js
  2. npm install --save extendr

Frontend

  1. See Browserify

Usage

Example

// Shallow Clone
(function(){
	var a = {a:1}, b = {b:2}
	var c = require('extendr').clone(a,b)
	console.log(a) // {a:1}
	console.log(b) // {b:2}
	console.log(c) // {a:1,b:2}
})()

// Shallow Extend
(function(){
	var a = {a:1}, b = {b:2}
	var c = require('extendr').extend(a,b)
	console.log(a) // {a:1,b:2}
	console.log(b) // {b:2}
	console.log(c) // {a:1,b:2}
})()

Methods

  • clone(args...) - shallow extend the arguments into a new object, same as extend({},args...)
  • deepClone(args...) - deep extend the arguments into a new object, same as deepExtend({},args...)
  • dereference(obj) - return a copy of the object with all references destroyed, same as serializing then deserializing the object
  • extend(args...) - alias for shallowExtendPlainObjects
  • deepExtend(args...) - alias for deepExtendPlainObjects
  • shallowExtendPlainObjects(target, args...) - shallow extend the arguments into the target
  • deepExtendPlainObjects(target, args...) - deep extend the arguments into the target
  • safeShallowExtendPlainObjects(target, objs...) - shallow extend defined values from the arguments into the target
  • safeDeepExtendPlainObjects(target, args...) - deep extend defined values from the arguments into the target

Notes

  • Use the clone methods when you don't want to modify your first object
  • Use the extend methods when you want to modify the first argument
  • Use the dereference method when you want to make sure that nothing has any references to the old object
  • Use the safe methods when you don't want null and undefined values to overwrite a defined values

History

You can discover the history inside the History.md file

License

Licensed under the incredibly permissive MIT License
Copyright © 2013+ Bevry Pty Ltd
Copyright © 2011-2012 Benjamin Arthur Lupton

Keywords

FAQs

Package last updated on 28 Jun 2013

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