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-shanking-friendly. Your favorite module bundler can easily inline the functionality you need with no extra configuration, instead of bundling the whole Ponyfills package.
Execute npm install ponyfills
to install ponyfills and its dependencies into your project directory.
The assign
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 assign from 'ponyfills/lib/assign';
const test = assign({}, { test: true });
console.log(`Result: ${test}`);
console.log(`Is Native: ${assign === Object.assign}`);
Alternative usage I:
import { assign } from 'ponyfills';
const test = ponyfills.assign({}, { test: true });
Alternative usage II:
import * as ponyfills from 'ponyfills';
const test = assign({}, { test: true });
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.