Turn numbers into their corresponding fizzbuzz result
Install:
npm install fizzbuzzify
Use:
// es6 style import:
import { fizzbuzzify } from "fizzbuzzify";
// or cjs/node/browserify-style:
var fizzbuzzify = require("fizzbuzzify")
// then:
console.log(fizzbuzzify(15)) // "FizzBuzz"
fizzbuzzify
is a named export because I'm preferring that style these days,
but also a default export for legacy compatibility.
The code is written in es6 and transpiled into the __build
folder as es5 by
babel. This is done automatically before publishing to npm by the prepublish
script config.
If you're working on this package and you want to generate the transpiled output, run:
npm run prepublish
Alternatively to keep babel running in watch mode while you work, run
npm run watch
This code should work fine in node and browsers.
As usual, you can run npm test
to run the tests. This will fire up Karma
and attempt to start a Firefox instance.
When running in a Continuous Integration environment, the Karma configuration will run once and exit. Otherwise it will start up in "watch" mode.
Alternatively you can run npm run mocha
to run the tests directly in Mocha
(not using Karma) or npm run mocha-watch
to keep mocha running the background
and re-running the tests when the code changes.
This package is part of a larger project that's half joke and half genuine demonstration of "cool things in software development". Go see fizzbuzz-cli for the full write-up.