parseinteger
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

NPM version

parseInteger

Parse Exclusively Safe Integer From String

import { parseInteger } from "parseinteger";

const number = parseInteger("42");
console.log(`The answer is ${number}`); // The answer is 42

try {
  const number = parseInteger("17.5");
} catch (e) {
  if (e instanceof TypeError) {
    // Handle the TypeError
    console.log(e.message);
  } else if (e instanceof RangeError) {
    // Handle the RangeError
    console.log(e.message);
  }
}

License

This plugin is issued under the MIT license.

Package Sidebar

Install

npm i parseinteger

Weekly Downloads

3

Version

1.1.1

License

MIT

Unpacked Size

4.62 kB

Total Files

6

Last publish

Collaborators

  • styledkitten