Narcoleptic Programmers' Medicine
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

gates

0.1.2 • Public • Published

Gates

Gates defines logic gates function for composing more complex functions.

Functions

  • Gates.not
  • Gates.or
  • Gates.and
  • Gates.nor
  • Gates.nand
  • Gates.xor
  • Gates.xnor

Example

var isEven = function(n) { return n % 2 === 0 }
var isNotEven = Gates.not(isEven);
 
isEven(10); // true
isNotEven(10); // false
 
var isDivisibleBy3 = function(n) { return n % 3 === 0 }
var isNotEvenAndDivisibleBy3 = Gate.and(isNotEven, isDivisibleBy3)
 
isNotEvenAndDivisibleBy3(10) // false
isNotEvenAndDivisibleBy3(12) // true

install

npm i gates

Downloadsweekly downloads

4

version

0.1.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability