Socket
Socket
Sign inDemoInstall

is-subset

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-subset

Check if an object is contained within another one


Version published
Weekly downloads
2.2M
increased by2.3%
Maintainers
1
Install size
11.2 kB
Created
Weekly downloads
 

Readme

Source

Coveralls – test coverage
Travis – build status
David – status of dependencies
Code style: airbnb

is-subset

Check if an object is contained within another one.

Installation

$ npm install is-subset

Usage

  1. Import the module:
import isSubset from 'is-subset/module';

// …or:
var isSubset = require('is-subset');
  1. These are true:
isSubset(
  {a: 1, b: 2},
  {a: 1}
);

isSubset(
  {a: 1, b: {c: 3, d: 4}, e: 5},
  {a: 1, b: {c: 3}}
);

isSubset(
  {a: 1, bcd: [1, 2, 3]},
  {a: 1, bcd: [1, 2]}
);

…and these are false:

isSubset(
  {a: 1},
  {a: 2}
);

isSubset(
  {a: 1},
  {a: 1, b: 2}
);

isSubset(
  {a: 1, bcd: [1, 2, 3]},
  {a: 1, bcd: [1, 3]}
);

See the specs for more info.

API

isSubset(superset, subset)

Check if an object is contained within another object.

Returns true if:

  • all enumerable keys of subset are also enumerable in superset, and
  • every value assigned to an enumerable key of subset strictly equals the value assigned to the same key of superset – or is a subset of it.

Parameters:

  • Object superset
  • Object subset

Return value:

  • Boolean

License

MIT © Studio B12 GmbH

Keywords

FAQs

Last updated on 29 Apr 2015

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