2.0.2 • Published 9 years ago

aureooms-js-predicate v2.0.2

Weekly downloads
2
License
AGPL-3.0
Repository
github
Last release
9 years ago

js-predicate

Predicate code bricks for JavaScript.

NPM license NPM version Bower version Build Status Coverage Status Dependencies Status devDependencies Status Code Climate NPM downloads per month GitHub issues Inline docs

Can be managed through jspm, duo, component, bower, ender, jam, spm, and npm.

Install

jspm

jspm install github:aureooms/js-predicate
# or
jspm install npm:aureooms-js-predicate

duo

No install step needed for duo!

component

component install aureooms/js-predicate

bower

bower install aureooms-js-predicate

ender

ender add aureooms-js-predicate

jam

jam install aureooms-js-predicate

spm

spm install aureooms-js-predicate --save

npm

npm install aureooms-js-predicate --save

Require

jspm

let predicate = require( "github:aureooms/js-predicate" ) ;
// or
import predicate from 'aureooms-js-predicate' ;

duo

let predicate = require( "aureooms/js-predicate" ) ;

component, ender, spm, npm

let predicate = require( "aureooms-js-predicate" ) ;

bower

The script tag exposes the global variable predicate.

<script src="bower_components/aureooms-js-predicate/js/dist/predicate.min.js"></script>

Alternatively, you can use any tool mentioned here.

jam

require( [ "aureooms-js-predicate" ] , function ( predicate ) { ... } ) ;

Use

const {
	lt , le , gt ,
	truth , untruth ,
	negation ,
	conjunction , disjunction ,
	implication
} = predicate ;

let p = gt( 5 ) ;
p( 5 ) ; // false
p( 6 ) ; // true

let q = lt( 7 ) ;
q( 6 ) ; // true
q( 7 ) ; // false

let r = conjunction( p , q ) ;
r( 5 ) ; // false
r( 6 ) ; // true
r( 7 ) ; // false

let s = negation( r ) ;
s( 5 ) ; // true
s( 6 ) ; // false
s( 7 ) ; // true

let t = equivalence( p , negation( le( 5 ) ) ) ;
t( ... ) ; // true

let u = implication( negation( q ) , p ) ;
u( ... ) ; // true

let v = disjunction( truth , untruth ) ;
v( ... ) ; // true

References