New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

logic-filter-strings

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logic-filter-strings

An algebraic expression parser for stream logic filters

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
81
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

node-logic-filter-strings

Build Status

A parser that transforms logical expression strings for filtering JSON objects into their equivalent logic filter structure.

#Example

var logicFilterString = require('logic-filter-strings');

var obj = logicFilterString('foo === "bar"&&bar === "baz qux"');

Obj will be:

[['foo', '===', 'bar'], '&&', ['bar', '===', 'baz qux']]

##Filter Language This interpreter was desgined with the end goal of being able to provide rules for filtering JSON object streams. It was meant to be used by node-logic-filter as the means of parsing filter rules. In general, strings on the left side of an equality represent keys in an object, and strings/numbers/arrays/objects on the right side of an equality represent values to compare against. You are also able to use &&, ||, and ! to combine conditions/expressions as you might expect.

###Case: foo exists in the comparison object

'foo'

###Case: foo does not exist in the comparison object

'!foo'

###Case: foo equals string

'foo === "bar"'

Note: The quotes around "bar" are required

###Case: foo equals array

'foo === [1, 2, 3]'

###Case: foo equals object

'foo === {bar: "baz"}'

###Case: foo equals string and bar equals string

'foo == "baz" && bar == "qux"'

Note: == and === are interchangeable

###Case: foo does not equal string

'foo !== "baz"'

###Case: field on a nested object equals string

'foo.bar.qux === "baz"'

###Case: Or-ing 3 or more conditions

'(foo == "baz" || bar == "qux") || a === "b"'

Note: Parentheses are necessary

Keywords

FAQs

Package last updated on 20 Oct 2014

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc