Socket
Socket
Sign inDemoInstall

sphinx

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sphinx

Recursively merges and guards your objects against unwanted tampering.


Version published
Weekly downloads
16
increased by128.57%
Maintainers
1
Install size
5.72 kB
Created
Weekly downloads
 

Readme

Source

Sphinx Build Status

Recursively merges and guards your objects against unwanted tampering.

Features

Sphinx guards your objects during a merge by allowing you to:

  • only change the values for properties that exist on the destination object.
  • only change the values for properties that are of the same type as the destination object.

Getting Started

npm install --save sphinx

Usage

var sphinx = require( "sphinx" );

var destination = { foo: "bar" };
var source      = { foo: "qux" };

var merged = sphinx.merge( destination, source );
//=> { foo: "qux" }

Examples

  • Trying to add a property that doesn't exist on the destination object.
var destination = { foo: "bar" };
var source      = { baz: "qux" };

var merged = sphinx.merge( destination, source );
//=> [Error: Property "baz" does not exist on destination object]
  • Trying to merge a property of a mismatched type.
var destination = { foo: "bar" };
var source      = { foo: 1 };

var merged = sphinx.merge( destination, source );
//=> [TypeError: Expected property "foo" to be a [object String]]

API

sphinx.merge( destination, object )

NameTypeArgumentDefaultDescription
destinationObject<required>nullThe destination object.
sourceObject<required>nullThe source object.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.

License

Copyright (c) 2014 Jason Bellamy
Licensed under the MIT license.

Keywords

FAQs

Last updated on 16 Aug 2014

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