Skip to content

Instantly share code, notes, and snippets.

View jakeorr's full-sized avatar

Jake Orr jakeorr

View GitHub Profile
@boneskull
boneskull / README.md
Last active April 10, 2024 12:47
example of how to debug mocha v4 if hanging

Here's an example of how to debug Mocha v4 if it hangs.

Ensure you're using a Node.js 8 or newer (or any version with async_hooks support).

If you run your test, you'll notice it hangs:

$ mocha test.js
@IceCreamYou
IceCreamYou / bucketNumbers.js
Last active October 28, 2020 16:36
Put numbers into buckets either by bucket size or range size.
/**
* Utility method to round numbers to a given number of decimal places.
*
* Usage:
* 3.5.round(0) // 4
* Math.random().round(4) // 0.8179
* var a = 5532; a.round(-2) // 5500
* Number.prototype.round(12345.6, -1) // 12350
* 32..round(-1) // 30 (two dots required since the first one is a decimal)
*/