New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

condjs

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

condjs

Boolean builder library

latest
Source
npmnpm
Version
1.0.12
Version published
Weekly downloads
1
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status npm

Installation

Install the package using npm.

npm install condjs

or use Yarn

yarn add condjs

Usage

const Condition = require('condjs');

var willBeFalse = Condition.with(true).and(false).value;
var willBeTrue = Condition.with(false).or(true).value;

Methods

.and(condition)
.or(condition) - Logicial && (and) and || (or) operations

.set(condition) - Sets current value (.or(...).value) to given condition's value

What is condition?
Condition is a boolean or function that accepts a new Condition instance as a argument.

Condition.with(true).and(true).or(c => c.and(true).or(false)).value equals to true && true || (true || false).

.then(action, ...args) - Action will be called with given args if the condition value is true

.else(action, ...args) - Action will be called with given args if the condition value is false

Example

Condition.with(true)
    .and(coupon.isActive)
    .and(function (c) {
        c.or(coupon.limitDate === null)
         .or(coupon.limitDate > new Date())
    })
    .and(function (c) {
        c.or(coupon.limitMinPrice === null)
         .or(price >= coupon.limitMinPrice);
    })
    .then(function () {
        alert('Coupon applied')
    })
    .else(function () {
        alert('Coupon not available')
    });

Keywords

condition

FAQs

Package last updated on 07 Aug 2019

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