New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

contains-reference

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contains-reference

Checks to see if any iterable object or array reference in two objects or arrays match.

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

contains-reference

Checks to see if any iterable object or array reference in two objects or arrays match.

Useful to ensure that a "copied" object does not inadvertently affect distant areas of code when modified.

Usage

const assert = require('assert')
const containsReference = require('contains-reference')

// Object structure and primitives are the same,
// but the object references are different
const object1 = { foo: 'bar', inner: { a: 'b' } }
const object2 = { foo: 'bar', inner: { a: 'b' } }

assert(!containsReference(object1, object2)) // false

// This array contains a reference to the first object now
const someArray = [object1]

assert(containsReference(someArray, object1)) // true
assert(!containsReference(someArray, object2)) // false

// the second object now contains a reference to the first,
// and by extension the array also has a reference to the second object
object1.inner = object2.inner

assert(containsReference(object1, object2)) // true
assert(containsReference(someArray, object1)) // true
assert(containsReference(someArray, object2)) // true

Keywords

array

FAQs

Package last updated on 15 Jul 2018

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