0.0.3 • Published 7 years ago

specification-pattern v0.0.3

Weekly downloads
46
License
MIT
Repository
github
Last release
7 years ago

Javascript specification pattern ES6

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
0.0.3

7 years ago

0.0.2

8 years ago

0.0.1

8 years ago