1.0.113 • Published 7 days ago

@anansi/polyfill v1.0.113

Weekly downloads
200
License
BSD-3-Clause
Repository
github
Last release
7 days ago

@anansi/polyfill

This ensures support for Intl localization object, requestIdleCallback and fetch. It does so using feature detection and dynamic imports, allowing browsers that support the features to immediately progress.

Usage

With React:

import ReactDOM from 'react-dom';
import loadPolyfills from '@anansi/polyfill';

import MyApp from './App';

async function init() {
  await loadPolyfills();
  ReactDOM.createRoot(document.body).render(<MyApp />);
}
init();

It's important to delay initilization of your app until these polyfills are loaded. This is provided by the promise returned by loadPolyfills(). Once that promise resolves all polyfills will be loaded into the global object.

Arguments

include: intl, ric, fetch | 'all' = 'all'

By default all three polyfills are loaded, but if you don't use a feature (like fetch) you may want to avoid loading it. Do this by passing an array of features you want to include from intl, ric, fetch.

loadPolyfills(['intl', 'ric']); // fetch won't be loaded

Supporting locales

To support locales other than english, you'll need to import them as well. They weren't included to help with build times for sites that don't need it.

Support spanish and german:

for (const locale of ['es', 'de']) {
  import(
    /* webpackChunkName: "locale-request" */ `intl/locale-data/jsonp/${locale}.js`
  );
}

Detect locale of browser:

import localeFinder from 'browser-locale';

async function init() {
  await loadPolyfills();
  if (
    !global.Intl ||
    typeof global.Intl.DateTimeFormat.prototype.formatToParts !== 'function'
  ) {
    const locale = localeFinder();
    await import(
      /* webpackChunkName: "locale-request" */ `intl/locale-data/jsonp/${locale}.js`
    );
  }
  ReactDOM.createRoot(document.body).render(<MyApp />);
}
1.0.109

27 days ago

1.0.110

23 days ago

1.0.112

9 days ago

1.0.111

9 days ago

1.0.113

7 days ago

1.0.107

1 month ago

1.0.106

2 months ago

1.0.108

1 month ago

1.0.103

2 months ago

1.0.102

3 months ago

1.0.105

2 months ago

1.0.104

2 months ago

1.0.101

3 months ago

1.0.100

3 months ago

1.0.88

5 months ago

1.0.89

5 months ago

1.0.91

4 months ago

1.0.90

4 months ago

1.0.95

4 months ago

1.0.94

4 months ago

1.0.93

4 months ago

1.0.92

4 months ago

1.0.99

3 months ago

1.0.98

3 months ago

1.0.97

4 months ago

1.0.96

4 months ago

1.0.87

6 months ago

1.0.86

7 months ago

1.0.85

7 months ago

1.0.84

9 months ago

1.0.83

9 months ago

1.0.80

9 months ago

1.0.82

9 months ago

1.0.81

9 months ago

1.0.79

9 months ago

1.0.78

9 months ago

1.0.77

9 months ago

1.0.76

10 months ago

1.0.75

10 months ago

1.0.74

10 months ago

1.0.73

11 months ago

1.0.72

11 months ago

1.0.71

11 months ago

1.0.70

11 months ago

1.0.69

11 months ago

1.0.68

11 months ago

1.0.67

11 months ago

1.0.66

11 months ago

1.0.65

12 months ago

1.0.64

12 months ago

1.0.63

12 months ago

1.0.62

12 months ago

1.0.61

12 months ago

1.0.60

12 months ago

1.0.59

12 months ago

1.0.58

12 months ago

1.0.55

1 year ago

1.0.57

12 months ago

1.0.56

12 months ago

1.0.54

1 year ago

1.0.51

1 year ago

1.0.50

1 year ago

1.0.53

1 year ago

1.0.52

1 year ago

1.0.44

1 year ago

1.0.43

1 year ago

1.0.48

1 year ago

1.0.47

1 year ago

1.0.46

1 year ago

1.0.45

1 year ago

1.0.49

1 year ago

1.0.42

1 year ago

1.0.40

1 year ago

1.0.41

1 year ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.4.5

2 years ago

0.4.4

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.37

3 years ago

0.3.36

3 years ago

0.3.35

3 years ago

0.3.32

3 years ago

0.3.31

3 years ago

0.3.29

3 years ago

0.3.28

3 years ago

0.3.27

3 years ago

0.3.26

3 years ago

0.3.24

3 years ago

0.3.23

3 years ago

0.3.22

3 years ago

0.3.21

3 years ago

0.3.20

3 years ago

0.3.19

3 years ago

0.3.18

3 years ago

0.3.17

3 years ago

0.3.16

3 years ago

0.3.15

3 years ago

0.3.14

3 years ago

0.3.13

3 years ago

0.3.13-alpha.0

3 years ago

0.3.12

3 years ago

0.3.11

3 years ago

0.3.10

3 years ago

0.3.9

3 years ago

0.3.7

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.1

3 years ago