Noiseless Praying Mantis
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

functional-predicates

0.1.0 • Public • Published

Functional Predicates

Library for creating common predicates.

Useage

var is = require('functional-predicates');
 
var isDefined = is.defined()
var isDefined = is.undefined(false)
  // isDefined(undefined) === false
 
var isUndefined = is.undefined()
var isUndefined = is.defined(false)
  // isUndefined(undefined) === true
 
var isString = is.typeof('string')
  // isString('hello') === true
 
var isObject = is.instanceof(Object)
  // isObject(new Object()) === true
 
var isHello = is.equal('hello')
  // isHello('hello') === true
 
var isLt7 = is.lt(7)
  // isLt7(3) === true
 
var isGt12 = is.gt(12)
  // isGt12(7) === false
 
var isBeforeDec = is.before('Dec 31, 2015')
  // isBeforeDec('August 22, 2015') === true
 
var isAfterJul = is.after('July 1, 2015')
  // isAfterJul('August 22, 2015') === true
 
var isBetween20And45 = is.between(20, 45)
  // isBetween20And45(30) === true
 
var isBetweenJulAndDec = is.between('July 1, 2015', 'Dec 31, 2015')
  // isBetweenJulAndDec('August 22, 2015') === true
 
var isLongerThan10 = is.longer(10)
  // isLongerThan10('hello') === false
 
var isShorterThan12 = is.shorter(12)
  // isShorterThan12([1,2]) === true
 
var hasHello = is.includes('hello')
  // hasHello('hello world') === true
 
var has7 = is.includes(7)
  // has7([6,7,8]) === true
 
var hasNumbers = is.matches()
  // hasNumbers('123abc') === true

Library

  • defined()
  • undefined()
  • typeof(type);
  • instanceof(object);
  • equal(value)
  • lt(num);
  • gt(num);
  • between(num, num);
  • before(date);
  • after(date);
  • longer(length);
  • shorter(length);
  • includes(substr);
  • matches(regex);

install

npm i functional-predicates

Downloadsweekly downloads

1

version

0.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability