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

comparisons

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

comparisons - npm Package Compare versions

Comparing version 2.2.8 to 2.2.9

7

lib/__tests__/comparison.test.js

@@ -22,3 +22,3 @@ const sift = require('sift').default;

age: 21,
language: 'en',
language: ['en', 'es'],
bestFriend: {

@@ -62,2 +62,7 @@ name: 'Jon',

describe('query', () => {
it('should return truthy on dynamic matching', () =>
expect(
new Comparison(['dynamic={{age}}']).query(stub),
).toMatchObject({}));
it('should return as mongo query', () =>

@@ -64,0 +69,0 @@ expect(new Comparison(exp).query(stub)).toMatchObject({

@@ -107,5 +107,17 @@ const flat = require('flat');

query() {
query(obj = {}) {
return {
$and: this.eligible.reduce((a, [key, value, fn]) => {
$and: this.eligible.reduce((a, params) => {
let key;
let value;
let fn;
if (Array.isArray(params)) {
[key, value, fn] = params;
} else if (isFn(params)) {
[key, value, fn] = params(obj);
} else {
return a;
}
const v = isSerialized(value) ? value.split(',') : value;

@@ -128,3 +140,3 @@ const name = Array.isArray(v) ? 'in' : fn.name;

return isFn(validator)
? validator(flat(obj)[key], value, this.locale)
? validator(flat(obj, { safe: true })[key], value, this.locale)
: false;

@@ -131,0 +143,0 @@ });

@@ -79,3 +79,7 @@ const moment = require('moment');

const equals = (a, b, locale) => {
const comp = (v) => runCompare(a, v, locale) === 0;
const comp = (input) => {
const exec = (value) => runCompare(value, input, locale) === 0;
return Array.isArray(a) ? a.some(exec) : exec(a);
};
if (b === '*') return a !== '' && a !== undefined && a !== null;

@@ -82,0 +86,0 @@ if (typeof b === 'string' && b.includes(','))

2

package.json
{
"name": "comparisons",
"version": "2.2.8",
"version": "2.2.9",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

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