1.0.2 • Published 9 years ago

json-subset v1.0.2

Weekly downloads
233
License
MIT
Repository
github
Last release
9 years ago

json-subset

return whether one json object is a subset of another json object

uses a recursive depth-first-search algorithm to compare for equality across depth levels.

Equality is checked using the toString() representation of each leaf node. Objects are recursively checked.

NOTE: This can be very expensive for deep json objects.

installation

npm install json-subset

jsonSubset(a,b)

returns a boolean indicating whether json a is a subset of b

usage

var subset = require('json-subset')

console.log(subset(
  { a: 'a' },
  { a: 'a', b: 'b' }
))

console.log(subset(
  { a: 'a', b: 'b' },
  { a: 'a' }
))

output

true
false