0.13.5 • Published 5 years ago

ponyfills v0.13.5

Weekly downloads
40
License
Apache-2.0
Repository
github
Last release
5 years ago

🦄 ponyfills

build status npm version npm download dependencies coverage status license

What is the Ponyfills?

Ponyfills provides a set of modules, which work natively in modern node.js runtime and modern browsers, however, it needs extra fallback code in order to run in some environments.

It simply tests the availability of native functionality first, then delivers the closest/best alternative implementation if native ones are not available.

Compared to its alternatives, ponyfills doesn't assign its modules anywhere or doesn't patch anything in the runtime environment. Instead, it just delivers the required functionality with ES6 modules or commonjs.

Plus, as a library, Ponyfills is completely tree-shaking-friendly. Your favorite module bundler can easily inline the functionality you need with no extra configuration, instead of bundling the whole Ponyfills package.

Quick start

Execute npm install ponyfills or yarn add ponyfills to install ponyfills and its dependencies into your project directory.

Usage of modules

arrayFrom(source, mapFn?, thisArg?) (Array.From)

The Array.from method creates a new, shallow-copied Array instance from an array-like or iterable object. (Source: MDN)

For example, to ensure Array.from will be work:

import arrayFrom from 'ponyfills/arrayFrom';

const test = arrayFrom(new Set(1, 2, 3));

console.log(`Result: ${test}`);
console.log(`Is Native: ${arrayFrom === Array.from}`);

Alternative usage I:

import { arrayFrom } from 'ponyfills';

const test = arrayFrom(new Set(1, 2, 3));

Alternative usage II:

import * as ponyfills from 'ponyfills';

const test = ponyfills.arrayFrom(new Set(1, 2, 3));

objectAssign(target, ...sources) (Object.assign)

The objectAssign method is used to copy the values of all enumerable own properties from one or more source objects to a target object. It will return the target object. (Source: MDN)

For example, to ensure Object.assign will be work:

import objectAssign from 'ponyfills/objectAssign';

const test = objectAssign({}, { test: true });

console.log(`Result: ${test}`);
console.log(`Is Native: ${objectAssign === Object.assign}`);

objectEntries(source) (Object.entries)

The Object.entries method returns an array of a given object's own enumerable string-keyed property key, value pairs, in the same order as that provided by a for...in loop. (Source: MDN)

For example, to ensure Object.entries will be work:

import objectEntries from 'ponyfills/objectEntries';

const test = objectEntries({ a: 1, b: 2, c: 3 });

console.log(`Result: ${test}`);
console.log(`Is Native: ${objectEntries === Object.entries}`);

objectValues(source) (Object.values)

The Object.values method returns an array of a given object's own enumerable property values, in the same order as that provided by a for...in loop. (Source: MDN)

For example, to ensure Object.values will be work:

import objectValues from 'ponyfills/objectValues';

const test = objectValues({ a: 1, b: 2, c: 3 });

console.log(`Result: ${test}`);
console.log(`Is Native: ${objectValues === Object.values}`);

reflectOwnKeys(source) (Reflect.ownKeys)

The static Reflect.ownKeys method returns an array of the target object's own property keys. (Source: MDN)

For example, to ensure Reflect.ownKeys will be work:

import reflectOwnKeys from 'ponyfills/reflectOwnKeys';

const test = reflectOwnKeys({ a: 1, b: 2, c: 3 });

console.log(`Result: ${test}`);
console.log(`Is Native: ${reflectOwnKeys === Reflect.ownKeys}`);

Todo List

See GitHub Projects for more.

Requirements

License

Apache 2.0, for further details, please see LICENSE file

Contributing

See contributors.md

It is publicly open for any contribution. Bugfixes, new features and extra modules are welcome.

  • To contribute to code: Fork the repo, push your changes to your fork, and submit a pull request.
  • To report a bug: If something does not work, please report it using GitHub Issues.

To Support

Visit my patreon profile at patreon.com/eserozvataf

0.13.5

5 years ago

0.13.3

5 years ago

0.13.2

5 years ago

0.13.0

5 years ago

0.12.6

5 years ago

0.12.5

5 years ago

0.12.4

5 years ago

0.12.3

5 years ago

0.12.2

5 years ago

0.12.1

5 years ago

0.12.0

5 years ago

0.11.0

5 years ago

0.10.7

5 years ago

0.10.6

5 years ago

0.10.5

5 years ago

0.10.4

5 years ago

0.10.3

5 years ago

0.10.2

5 years ago

0.10.1

5 years ago

0.10.0

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.8.4

7 years ago

0.8.2

7 years ago

0.8.1

7 years ago

0.8.0

7 years ago

0.7.5

7 years ago

0.7.4

7 years ago

0.7.3

7 years ago

0.7.2

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago