JSPM

get-integer

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q47368F
  • License MIT

Function will convert incoming value as integer. If argument is not a number, function will return 0.

Package Exports

  • get-integer

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (get-integer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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

License

MIT License