npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-polyfill

v1.2.1

Published

Polyfill newer JS features. Primarily targeted at older phones (for example, iOS 8) that will still run React Native. This library mutates JavaScript's built-in objects and should be used judiciously.

Downloads

277

Readme

react-native-polyfill

Overview

Some JS engines that are targeted by React Native, particularly iOS 8 and, to a lesser extent, Android 6, are missing some of the new ES2015 functions and they may not be polyfilled by a typical build system.

This leads to errors that look like this:

Unhandled JS Exception: undefined is not a function (evaluating ‘Number.parseInt’)

A lot of these functions are the ones that existed in prior versions of JavaScript but were added to the Number object to namespace them. For example:

parseInt('20', 10); // existing JavaScript function
Number.parseInt('20', 10); // the 'new' way of accessing the same function as of ES2015

Installing

npm install --save react-native-polyfill

To use the entire package and mutate the base objects, simply import or require the package:

import 'react-native-polyfill';
require('react-native-polyfill');

If you only want the Array or Number polyfills, you can include just one:

import 'react-native-polyfill/src/Array';
require('react-native-polyfill/src/Array');

If you just want a single function or you want to limit the number of changes to the base object, you can access the functions directly:

const includes = require('react-native-polyfill/src/Array/includes');

Methodology

Where available, this project has used the MDN polyfills or a close variation.

Warning

Importing this package into your project will mutate the prototype of JavaScript's base objects, if those objects do not already support the functionality. The decision to mutate these base objects in your code base should not be taken lightly. The polyfills in this package should be relatively low risk as they do not change prototypes in JavaScript engines that already implement the functions.

Polyfilled Functions

Array

  • includes

Number

  • isInteger
  • isNaN
  • isSafeInteger
  • parseFloat
  • parseInt

String

  • codePointAt
  • fromCodePoint
  • normalize // Uses the unorm library for a polyfill

Resources

More information about this topic can be found at: http://mcculloughwebservices.com/2016/11/29/adding-support-es2015-number-methods/