index.js 296 B

12345678910111213
  1. export default function toInteger(dirtyNumber) {
  2. if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
  3. return NaN;
  4. }
  5. var number = Number(dirtyNumber);
  6. if (isNaN(number)) {
  7. return number;
  8. }
  9. return number < 0 ? Math.ceil(number) : Math.floor(number);
  10. }