@elzup/fizzbuzz
v0.0.2
Published
elzup's rich fizz buzz
Downloads
1
Readme
fizzbuzz
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):
This project follows the all-contributors specification. Contributions of any kind welcome!