diff options
Diffstat (limited to 'node_modules/is-odd/index.js')
-rw-r--r-- | node_modules/is-odd/index.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/node_modules/is-odd/index.js b/node_modules/is-odd/index.js new file mode 100644 index 000000000..c8950c17b --- /dev/null +++ b/node_modules/is-odd/index.js @@ -0,0 +1,20 @@ +/*! + * is-odd <https://github.com/jonschlinkert/is-odd> + * + * Copyright (c) 2015-2017, Jon Schlinkert. + * Released under the MIT License. + */ + +'use strict'; + +var isNumber = require('is-number'); + +module.exports = function isOdd(i) { + if (!isNumber(i)) { + throw new TypeError('is-odd expects a number.'); + } + if (Number(i) !== Math.floor(i)) { + throw new RangeError('is-odd expects an integer.'); + } + return !!(~~i & 1); +}; |