Wondering what’s next for npm?Check out our public roadmap! »

    TypeScript icon, indicating that this package has built-in type declarations

    0.13.5 • Public • Published

    🦄 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.


    • node.js (https://nodejs.org/)


    Apache 2.0, for further details, please see LICENSE file


    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


    npm i ponyfills

    DownloadsWeekly Downloads






    Unpacked Size

    41.4 kB

    Total Files


    Last publish


    • avatar