npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

matches-where-query

v2.0.7

Published

This function determines if the provided `object` matches every comparison clause in `whereQuery`, returning `true` or `false` accordingly.

Downloads

337

Readme

matchesWhereQuery( object, whereQuery )

This function determines if the provided object matches every comparison clause in whereQuery, returning true or false accordingly.

whereQuery is an object of the form:

{
	<attribute> : <value>
	<attribute> : [ <value1>, ..., <valueN> ]
	<attribute> : { comparator : <comparator> }
	<attribute> : { comparator : <comparator>, value : <value> }
}

Comparisons

For each clause in whereQuery, an attribute of object is compared to a value (primitive or object.) except in the cases of the isNull and isNotNull comparators, which do not require for a value to be provided.

equals (default)

Single Value

If the attribute is a single value, object.attribute must strictly equal the value to result in a match.

{
	<attribute> : <value>
}

Array

If the attribute is is an array, only records for which object.attribute is strictly equally to one of the elements in the array will result in a match.

{
	<attribute> : [ <value1>, ..., <valueN> ]
}

contains

The compared attribute must be a string that contains the provided value, or an array that has at least one element strictly equal to the provided value.

{
   <attribute> : { comparator : 'contains', value : <value> }
}

doesNotEqual

The compared attribute must must not be strictly equal to the value to result in a match.

{
	<attribute> : { comparator : 'doesNotEqual', value : <value> }
}

isGreaterThan

The compared attribute must be greater than the value to result in a match. NULL values are automatically discarded.

{
	<attribute> : { comparator : 'isGreaterThan', value : <value> }
}

isGreaterThanOrEqualTo

The compared attribute must be greater than or equal to the value to result in a match. NULL values are automatically discarded.

{
	<attribute> : { comparator : 'isGreaterThan', value : <value> }
}

isLessThan

The compared attribute must be less than the value to result in a match. NULL values are automatically discarded.

{
	<attribute> : { comparator : 'isLessThan', value : <value> }
}

isLessThanOrEqualTo

The compared attribute must be less than or equal to the value to result in a match. NULL values are automatically discarded.

{
	<attribute> : { comparator : 'isLessThanOrEqualTo', value : <value> }
}

isBetween

The compared attribute must be between the minimum and maximum values provided to result in a match. The limits provided are included in the range for the value. NULL values are automatically discarded.

{
	<attribute> : { comparator : 'isBetween', value : [ <minValue>, <maxValue> ] }
}

startsWith

The compared attribute must be a string that starts with the string value provided to result in a match. NULL values are automatically discarded.

{
	<attribute> : { comparator : 'startsWith', value : <value> }
}

endsWith

The compared attribute must be a string that ends with the string value provided to result in a match. NULL values are automatically discarded.

{
	<attribute> : { comparator : 'endsWith', value : <value> }
}

isNull

The compared attribute must be null to result in a match (no value needs to be provided).

{
	<attribute> : { comparator : 'isNull' }
}

isNotNull

The compared attribute must not be null to result in a match (no value needs to be provided).

{
	<attribute> : { comparator : 'isNotNull' }
}