Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

functional-predicates

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

functional-predicates

Library for creating common predicates.

latest
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

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);

Keywords

predicates

FAQs

Package last updated on 02 Jun 2015

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