Skip to content

MintedKitten/parseInteger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPM version

parseInteger

Parse Exclusively Safe Integer From String

Example

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.

About

Parse Exclusively Safe Integer From String

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published