├── LICENSE ├── README.md ├── index.js ├── package.json └── polyfills └── globalself.js /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Johannes Lumpe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-browser-polyfill 2 | A collection of polyfills for the react-native JavaScript environment. 3 | 4 | If polyfills are needed to make browser-targeted libraries, which use commonly available functions/variables, work in react-native, this is the place to put them. Issues/PRs welcome. 5 | 6 | ## Usage 7 | `npm install react-native-browser-polyfill` the package and then `require('react-native-browser-polyfill')` it in your main entry file, before any libraries which require the polyfills. 8 | 9 | ## Polyfills available in this package 10 | 11 | ### `global.self` 12 | Currently JavaScriptCore does not provide a `self` reference to the global object, which is utilized by browser libraries (i.e bluebird) to have a reliably reference to the global object which works in browsers and web-workers alike. 13 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | require('./polyfills/globalself'); 2 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-browser-polyfill", 3 | "version": "0.1.2", 4 | "description": "A collection of polyfills for the react-native Javascript environment.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git@github.com:johanneslumpe/react-native-browser-polyfill.git" 12 | }, 13 | "keywords": [ 14 | "react-native" 15 | ], 16 | "author": "Johannes Lumpe (https://github.com/johanneslumpe)", 17 | "license": "MIT", 18 | "author": "Johannes Lumpe", 19 | "license": "MIT" 20 | } 21 | -------------------------------------------------------------------------------- /polyfills/globalself.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Currently JavaScriptCore does not provide a `self` reference 3 | * to the global object, which is utilized by browser libraries (i.e bluebird) 4 | * to have a reliably reference to the global object which works in browsers 5 | * and web-workers alike. 6 | */ 7 | 8 | if (typeof global.self === "undefined") global.self = global; 9 | --------------------------------------------------------------------------------