get-integer
v1.0.0
Published
Function will convert incoming value as integer. If argument is not a number, function will return 0.
Downloads
3
Readme
Synopsis
Easy lib for converting variables to integer. For cases, when module can not convert data type, it will return 0.
Code Example
const getInteger = require('get-integer');
const stringToInt = getInteger('123');
console.log(stringToInt); // 123
const floatToInt = getInteger(1.23);
console.log(floatToInt); // 1
const NaNToInt = getInteger('string');
console.log(NaNToInt); // 0
Installation
via npm:
npm install get-integer
or you can clone github repository:
git clone https://github.com/antishov/get-integer
Tests
./node_modules/.bin/_mocha ./test -R spec
or simple npm test