Skip to content

fnatte/fix-unusable-parse-number-polyfill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fix unusable parseInt and parseFloat

A modern parseInt for the 2️1️st Century.

Does 💯 look like NaN to you? Of course not.

parseInt and parseNumber is currently broken in ALL major web browsers. To make things worse, browser vendors have not shown any public signals fixing this critical issue. This polyfill will make life tolerable.

Installation

You know the drill:

npm install --save fix-unusable-parse-number-polyfill

# or

yarn add fix-unusable-parse-number-polyfill

Usage

Simply require/import the package early in your application:

import 'fix-unusable-parse-number-polyfill';

// or

require('fix-unusable-parse-number-polyfill');

And then safely parse your strings:

parseInt("3️⃣");  // 3
parseInt("💯");  // 100
parseFloat('0.🥇'); // 0.1

TODO

  • Fix parseInt
  • Fix parseFloat
  • Handle unicode better
  • Make ponyfill
  • RFC

License

MIT

About

A modern parseInt and parseFloat for the 2️1️st Century.

Resources

License

Stars

Watchers

Forks

Releases

No releases published