-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
73 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,7 @@ callouts: | |
warning: | ||
title: Warning | ||
color: red | ||
note: | ||
title: Note | ||
color: yellow | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
layout: default | ||
title: Dynamic Polyfills | ||
nav_order: 9 | ||
parent: Documentation | ||
--- | ||
|
||
## Dynamic Polyfills | ||
|
||
{: .note } | ||
This is an experimental feature. To use it, install the alpha version by running `npm install --global generator-ssjs@alpha`. | ||
|
||
Dynamic Polyfills enable you to use modern JS functions without importing the polyfills. Instead the polyfills will be added from the plugin if the functions are detected. the dynamic polyfills also don't break the core lobrary, as they will transform the functions to prevent updating the prototype. | ||
|
||
**example:** | ||
input: | ||
```javascript | ||
[1,2,3].map(e => e * 2); | ||
``` | ||
|
||
output: | ||
```javascript | ||
function arrayMap(array, callbackFn) { | ||
var arr = []; | ||
for (var i = 0; i < array.length; i++) { | ||
arr.push(callbackFn(array[i], i, array)); | ||
} | ||
return arr; | ||
} | ||
; | ||
/******/(function () { | ||
// webpackBootstrap | ||
var __webpack_exports__ = {}; | ||
arrayMap([1, 2, 3], function (e) { | ||
return e * 2; | ||
}); | ||
/******/ | ||
})(); | ||
``` | ||
|
||
**available polyfills:** | ||
* array | ||
* filter | ||
* forEach | ||
* includes | ||
* map | ||
* reduce | ||
* object | ||
* keys | ||
* values | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters