Skip to content

Javascript library to check if an object is deeply contained into another

License

Notifications You must be signed in to change notification settings

marcodave/is-deep-subset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

is-deep-subset

Javascript library to check if an object is deeply contained into another

Build Status

Usage

require it...

var isDeepSubset = require("is-deep-subset")

and then use it...

with strings

isDeepSubset("Some string", "string") === true

isDeepSubset("Some string", "another string") === false

with arrays

isDeepSubset([1, 2, "hello"], [1]) === true

isDeepSubset([1, 2, "hello"], [3, "hello"]) === false

with objects

isDeepSubset({ some: "deep object", you: { have: "here!" } }, { some: "deep object" }) === true
isDeepSubset({ some: "deep object", you: { have: "here!" } }, { you: { have: "here!" } }) === true

checks objects inside objects

isDeepSubset({ some: "deep object", you: { have: "here!" } }, { have: "here!" }) === true
isDeepSubset({ some: "deep object", you: { have: "here!" } }, "here!") === true
isDeepSubset({ some: "deep object", you: { have: "here!", its: 3 } }, 3) === true
isDeepSubset({ some: "deep object", you: { have: "here!", its: true } }, true) === true

and also checks deeply inside nested arrays

isDeepSubset({ some: ["deep", "object", { you: { have: "here!" } } ] }, ["deep", "object"]) === true
isDeepSubset({ some: ["deep", "object", { you: { have: "here!" } } ] }, [{ you: {} }]) === true

and also substrings inside deep object structure

isDeepSubset({ some: ["deep", "object", { you: { have: "here!" } } ] }, "deep") === true
isDeepSubset({ some: ["deep", "object", { you: { have: "here!" } } ] }, "here") === true
isDeepSubset({ some: ["deep", "object", { you: { have: "here!" } } ] }, "!") === true

About

Javascript library to check if an object is deeply contained into another

Resources

License

Stars

Watchers

Forks

Packages

No packages published