Socket
Socket
Sign inDemoInstall

comparify

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    comparify

Simple criteria checking, so you can test a subset of an object's properties.


Version published
Maintainers
1
Install size
40.0 kB
Created

Readme

Source

#Comparify

Simple criteria checking, so you can test a subset of an object's properties.

var comparify = require('comparify');

var data = {
  timestamp: 1395877795067,
  deviceID: '765CBA',
  recipient: {
    name: 'Thomas'
  },
  uses: ['making pancakes', 'running', 'hugs']
};

comparify(data, {deviceID: '765CBA'}) === true;
comparify(data, {deviceID: 'ABC123'}) === false;

// Comparify also supports nested requirements
comparify(data, {'recipient.name': 'Thomas'}) === true;
comparify(data, {recipient: {name: 'Thomas'}}) === true;

// And you can look in arrays
comparify(data, {uses: 'running'}) === true;
comparify(data, {uses: 'skiing'}) === false;

// You can require that multiple values are present in an array
comparify(data, {uses: ['running', 'hugs']}) === true;
comparify(data, {uses: ['running', 'skiing']}) === false;

// And you can use a Regex for values
comparify(data, {'recipient.name': /omas/}) === true;


To Do

  • Add support for arrays (any / all matching)
  • Add support for regex comparison
  • Add support for more types of comparison
    • Greater than / less than
    • Range

Keywords

FAQs

Last updated on 01 Jun 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc