Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

tointeger

yefremov6MIT0.0.2

Convert value to an integer value

test, tointeger, integer, browser, node

readme

tointeger Build Status Coverage Status npm version

Convert value to an integer value.

Please note that this is not an ecma262 "tointeger" implementation, but just a safer version of what you usually want from parseInt() to a value to integer value.

Installation

$ npm install tointeger

API

import toInteger from 'tointeger';

toInteger(1.9);
// => 1

toInteger('5.5');
// => 5

toInteger(NaN);
// => 0

toInteger(Infinity);
// => 0

Running tests

$ npm test

License

MIT