Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

matches-where-query

Package Overview
Dependencies
Maintainers
11
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

matches-where-query - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

8

lib/matchesWhereQuery.js

@@ -10,3 +10,3 @@ "use strict";

if (_underscore["default"].isObject(queryAttribute) && queryAttribute.comparator) {
if (_underscore["default"].isUndefined(queryAttribute.value)) throw new Error('Value must be supplied for comparator queries');
if (_underscore["default"].isUndefined(queryAttribute.value) && !['isNull', 'isNotNull'].includes(queryAttribute.comparator)) throw new Error('Value must be supplied for comparator queries');
switch (queryAttribute.comparator) {

@@ -46,2 +46,8 @@ case 'doesNotEqual':

break;
case 'isNull':
if (!_underscore["default"].isNull(objectAttribute)) return false;
break;
case 'isNotNull':
if (_underscore["default"].isNull(objectAttribute)) return false;
break;
default:

@@ -48,0 +54,0 @@ throw new Error('Invalid comparator ' + queryAttribute.comparator);

2

package.json
{
"name": "matches-where-query",
"version": "2.0.2",
"version": "2.0.3",
"main": "lib/matchesWhereQuery.js",

@@ -5,0 +5,0 @@ "scripts": {

@@ -12,2 +12,3 @@ # matchesWhereQuery( object, whereQuery )

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

@@ -18,3 +19,3 @@ }

# Comparisons
For each clause in `whereQuery`, an attribute of `object` is compared to a value (primitive or object.)
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.

@@ -109,1 +110,19 @@ ## equals (default)

```
## 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' }
}
```

@@ -14,3 +14,4 @@ var _ = require( 'underscore' );

height : 172,
city : 'Buenos Aires'
city : 'Buenos Aires',
age : null
};

@@ -209,2 +210,30 @@ } );

} );
describe( 'isNull', function() {
it( 'Match', function() {
var comparator = { age : { comparator : 'isNull' } };
expect( matchesWhereQuery( person, comparator ) ).to.be.true;
} );
it( 'Not Match', function() {
var comparator = { firstName : { comparator : 'isNull' } };
expect( matchesWhereQuery( person, comparator ) ).to.be.false;
} );
} );
describe( 'isNotNull', function() {
it( 'Match', function() {
var comparator = { firstName : { comparator : 'isNotNull' } };
expect( matchesWhereQuery( person, comparator ) ).to.be.true;
} );
it( 'Not Match', function() {
var comparator = { age : { comparator : 'isNotNull' } };
expect( matchesWhereQuery( person, comparator ) ).to.be.false;
} );
} );
} );

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc