1.1.1 • Published 11 months ago
extendscript-ponyfills v1.1.1
extendscript-ponyfills
Why
ExtendScript is stuck in ES3, but we like our simple ES6 methods. A common solution is to polyfill these methods, but I'll let sindresorhus and hyperbrew explain why that's not a good idea, especially so in Adobe-land.
Usage
npm i extendscript-ponyfillsimport { arrayFrom, forEach } from "extendscript-ponyfills";
(function script() {
const comp = app.project.activeItem;
if (!(comp && comp instanceof CompItem)) {
return alert("No comp found.");
}
const layers: Layer[] = arrayFrom(comp.layers);
if (layers.length) {
forEach(layers, (layer) => alert(layer.name));
} else {
alert("No layers found.");
}
})();Or, download the latest release to #include in your .jsx script.
// @include "path/to/extendscript-ponyfills-vX.X.X.jsx"
(function script() {
var comp = app.project.activeItem;
if (!(comp && comp instanceof CompItem)) {
return alert("No comp found.");
}
var layers = PONIES.arrayFrom(comp.layers);
if (layers.length) {
PONIES.forEach(layers, function (layer) {
alert(layer.name);
});
} else {
alert("No layers found.");
}
})();By default the ponyfills are namespaced to
PONIES—you can change this name on the first line of the .jsx, or remove the IIFE entirely.
Ponyfills
Array
arrayFromdifferencedifferenceWitheveryfillfilterfindfindIndexflatflatMapforEachgroupByincludesindexOfintersectionintersectionWithisArraylastIndexOfmapreducesome
String
padEndendsWithincludespadStartrepeatstartsWithtrim
Object
assignentries
Function
bind
Similar Projects
- klustre's
extender