diff --git a/README.md b/README.md index 9aac9b0..9a83189 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Now we can also use Autodoc to quickly race these two implementations against on ![Benchmarks screenshot](http://breakneck.danieltao.com/images/benchmarks_screenshot.png) -All righty. Let's say we're completely delusional and actually think this library is useful, so we want to share it with the world. We'll add some simple comments describing what each function does and wrap the library up in a semi-reasonable way so it runs in either Node or the browser: +All righty. Let's say we're completely delusional and actually think this library is useful, so we want to share it with the world. We'll add some simple comments describing what each function does, remove the `@private` tags, and wrap the library up in a semi-reasonable way so it runs in either Node or the browser: ```javascript /** diff --git a/example/numbers.js b/example/numbers.js index 6316735..30be176 100644 --- a/example/numbers.js +++ b/example/numbers.js @@ -3,12 +3,24 @@ */ (function(Numbers) { + /** + * @private + * @examples + * isInteger(5) // => true + * isInteger(5.0) // => true + * isInteger(-5) // => true + * isInteger(3.14) // => false + * isInteger('foo') // => false + * isInteger(NaN) // => false + */ + function isInteger(x) { + return x === Math.floor(x); + } + /** * Checks if a number is an integer. Returns false for anything that isn't an * integer, including non-numbers. * - * @private - * * @examples * Numbers.isInteger(5) // => true * Numbers.isInteger(5.0) // => true @@ -18,15 +30,23 @@ * Numbers.isInteger(NaN) // => false */ Numbers.isInteger = function(x) { - return x === Math.floor(x); + return isInteger(x); }; + /** + * @private + * @examples + * isIntegerLike(123) // => true + * isIntegerLike(3.14) // => false + */ + function isIntegerLike(x) { + return (/^\d+$/).test(String(x)); + } + /** * Checks if a value looks like an integer. Returns true for both integers and * strings that represent integers, false for everything else. * - * @private - * * @examples * Numbers.isIntegerLike(123) // => true * Numbers.isIntegerLike(3.14) // => false @@ -36,7 +56,7 @@ * Numbers.isIntegerLike(123456789) // using RegExp: ^\d+$ */ Numbers.isIntegerLike = function(x) { - return (/^\d+$/).test(String(x)); + return isIntegerLike(x); }; }(typeof module === 'object' ? (module.exports = {}) : (this.Numbers = {})));