Introduction
Welcome to Nuance.js! This simple and easy-to-use library is designed to save you time, and make your code look cleaner and more readable.
What is Nuance.js?
This JavaScript (and TypeScript) library has all those pesky functions that you need in your project, but isn't offered in the base JavaScript API.
Let's look at a simple example below:
Say you want to generate a random amount of particles. You can use JavaScript's Math.random() function, but you don't want to generate 0 or 1 or 1.67457456 particles, instead, it would make more sense to generate an amount of particles that fall within a range of your choosing.
Well, JavaScript doesn't let you do that without writing some annoying code first.
Let's look at what you'd need to write in order to make a function that would let you generate 10-20 particles.
Math.floor(Math.random() * (20 - 10 + 1) + 10);
It's really not pretty, and if you want to change something down the line (like whether it be inclusive or exclusive) you have to go rework the formula directly.
With Nuance's randomInRange function, this becomes dead simple. Here's an example:
randomInRange({ min: 10, max: 20 })
Not only does this look much prettier, it's also readable in english so anybody reading the code knows exactly what this function does. This will generate a random integer between 10 and 20, and defaults to be inclusive for both min and max. The function also accepts different parameters to tweak, but we'll check those out when we get there.
For now, let's look at how to install