to-integer
Converts the given value to an integer.
Install
$ npm install --save to-integer
Usage
For more use-cases see the tests
var toInteger = require('to-integer');
toInteger(1);
toInteger();
toInteger(null);
toInteger(Number.MAX_VALUE);
toInteger(Infinity);
toInteger(true);
toInteger(false);
toInteger('1');
toInteger('0');
toInteger('-1');
toInteger('1.1000');
toInteger('-1.100');
toInteger('01');
toInteger('0.10');
toInteger('1a');
toInteger('a1');
toInteger('0b01');
toInteger('0b10');
toInteger('0b11');
toInteger('0b02');
toInteger('0o01');
toInteger('0o07');
toInteger('0o10');
toInteger('0o08');
toInteger('0x01');
toInteger('0x0F');
toInteger('0x0G');
toInteger('-0x01');
toInteger('+0x01');
toInteger(new Object(1));
toInteger(new Number(1));
toInteger(new Number(1.1));
toInteger(function () {});
toInteger(new Object());
Related
- to-num - Converts the given value to a number.
- to-str - Converts the given value to a string.
- to-length - Converts value to an integer suitable for use as the length of an array-like object.
- to-lower - Converts string, as a whole, to lower case.
- to-upper - Converts string, as a whole, to upper case.
- to-path - Converts value to a property path array.
- to-source-code - Converts function to its source code.
Contributing
Pull requests and stars are highly welcome.
For bugs and feature requests, please create an issue.