specification-pattern

0.0.3 • Public • Published

Javascript specification pattern ES6

Coverage Status

import Specification from 'specification-pattern'
 
class Spec extends Specification {
  isSatisfied (candidate) {
    return candidate % 3 === 0
  }
}
 
class Spec2 extends Specification {
  isSatisfied (candidate) {
    return candidate % 7 === 0
  }
}
 
class Spec3 extends Specification {
  isSatisfied (candidate) {
    return candidate % 10 === 0
  }
}
 
const s12 = new Spec().and(new Spec2())
const s123 = s12.or(new Spec3())
 
console.log(s123.isSatisfied(3*7)) // true
console.log(s123.isSatisfied(10)) // true
console.log(s123.isSatisfied(22)) // false

Readme

Keywords

none

Package Sidebar

Install

npm i specification-pattern

Weekly Downloads

3

Version

0.0.3

License

MIT

Last publish

Collaborators

  • skahrz