@elzup/fizzbuzz

elzup's rich fizz buzz

Usage no npm install needed!

<script type="module">
  import elzupFizzbuzz from 'https://cdn.skypack.dev/@elzup/fizzbuzz';
</script>

README

fizzbuzz

Build Status tested with jest styled with prettier

elzup's rich fizz buzz

Install

$ npm install @elzup/fizzbuzz

Usage

const fizzbuzz = require('fizzbuzz')
const fb = fizzbuzz()
fb.take(5)
// [ '1', '2', 'Fizz', '4', 'Buzz' ]

fb.from(3)
  .to(10)
  .take()
// [ 'Fizz', '4', 'Buzz', 'Fizz', '7', '8', 'Fizz', 'Buzz' ]

const t = fb.it()
t.next().value
// '1'
t.next().value
// '2'

fb.rules([{ name: 'test', n: 3 }]).take(5)
// [ '1', '2', 'test', '4', '5' ]

fb.addRule({ name: 'hey', n: 2 }).take(6)
// [ '1', 'hey', 'Fizz', 'hey', 'Buzz', 'Fizzhey' ]

API

fizzbuzz = (arg?: Arguments) => FizzBuzz

type FizzBuzz = {|
  from: (to: number) => FizzBuzz,
  to: (to: number) => FizzBuzz,
  rules: (rules: Rule[]) => FizzBuzz,
  addRule: (rule: Rule) => FizzBuzz,
  take: (to?: number, from?: number) => string[],
  at: (n: number) => string,
  it: MakeIterator,
|}

License

MIT © elzup

Contributors

Thanks goes to these wonderful people (emoji key):


elzup

💻 📖 ⚠️ 🚇

This project follows the all-contributors specification. Contributions of any kind welcome!