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

checkcond

v0.0.6

Published

check value against condition string

Downloads

58

Readme

checkcond

Build Status Coverage Status

NPM

Checks digit, date or string value against condition string.

For usage stand alone or e.g. in decision tables -> DMN Notation.

Usage

const compiler = require('checkcond').Compiler;
const check = require('checkcond').Check;

let condString = '[7..10]';
let x = 8;
let cond = compiler(condString);
let result = check(x, cond);    // => true

or via combined processing of compile + check:

const checkDirect = require('checkcond').CheckDirect;

let condString = '[7..10]';
let x = 8;
let result = checkDirect(x, condString);    // => true

Examples

Check digits.

'< 1.000'.

      x=-5 => true
      x=0.001 => true
      x=8 => false
      x=10000 => false

">= 5"

      x=4 => false
      x=5 => true
      x=5.001 => true
      x=8 => true

">= 5.001"

      x=5 => false
      x=5.001 => true
      x=8 => true

'[5..10]' between 5 and 10

      x=5 => true
      x=10 => true
      x=11 => false

'< 10, [5..100]' less then 10 or between 5 and 100

      x=1 => true
      x=5 => true
      x=100 => true
      x=101 => false

'< 1000, !([5..100])' less then 1000 and not between 5 and 100

      x=-50 => true
      x=4 => true
      x=5 => false
      x=100 => false
      x=100.1 => true

'[5.05..10.05],[70..100],-10.56'

      x=5.06 => true
      x=85 => true
      x=20 => false
      x=-10.56 => true
      x=-10 => false
      x=100 => true

'not(5,[7..9],12)'

      x=5 => false
      x=6 => true
      x=7 => false
      x=9.05 => true
      x=12 => false
      x=13 => true

Check dates

Supported date formats for conditions and values are:

  • mm/dd/yyyy
  • yyyy/mm/dd
  • yyyy-mm-dd
  • dd.mm.yyyy

'< 01/01/2017'.

      x='10/12/2015' => true
      x='05/03/2017' => false

'> 03.11.2017'.

      x='12/01/2017' => true
      x='10/04/2017' => false

'[01/01/2017..01/01/2018]'.

      x='10/12/2015' => false
      x='01/01/2017' => true
      x='05/06/2017' => true
      x='01/01/2018' => true
      x='01/01/2019' => false
      x='05/03/2019' => false

'not([01/01/2017..01/01/2018])'.

      x='10/12/2015' => true
      x='01/01/2017' => false
      x='05/06/2017' => false
      x='01/01/2018' => false
      x='01/01/2019' => true
      x='05/03/2019' => true

Check strings against arrays

"'AL','FGH','NO'"

      x='AL' => true
      x='AF' => false

"AL,FGH,NO" works also

      x='AL' => true
      x='AF' => false

"not('AL','FGH','NO')"

      x='AL' => false
      x='AF' => true

"not(AL,FGH,NO)"

      x='AL' => false
      x='AF' => true

"!('AL','FGH','NO')"

      x='AL' => false
      x='AF' => true

Other interesting implementation I found

js-feel.