Skip to content

Modern Javascript methods (ES6+) for the Earth Engine Code Editor

License

Notifications You must be signed in to change notification settings

aazuspan/ee-polyfill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ee-polyfill

Earth Engine Javascript Open in Code Editor

Description

ee-polyfill loads newer JavaScript methods (ES6+) into the Earth Engine Code Editor with a single import. Implementations are originally from behnammodi/polyfill, with modifications to ensure Earth Engine compatibility.

Usage

Just import the module with require to load all of the polyfilled methods.

require("users/aazuspan/polyfill:all");

New methods are automatically added to JavaScript objects. A few examples are demonstrated below:

// Array methods
var a = [0, [1, 1], [[8, 9, 9, 9]]];
a.includes(0); // true
a.flat(2); // [0, 1, 1, 8, 9, 9, 9]

// Math methods
var x = 4.05;
Math.sign(x); // 1
Math.trunc(x); // 4

// Number methods
var n = 32768;
Number.isInteger(n); // true

// Object methods
var o = {"a": 42, "b": 12};
Object.values(o); // [42, 12]
Object.entries(o); // [["a", 42], ["b", 12]]

// String methods
var s = "abc";
s.startsWith("b"); // false
s.repeat(3); // abcabcabc

Methods

ee-polyfill includes all of the methods listed at behnammodi/polyfill, plus those listed below:

Object

Object.values();
Object.entries();
Object.fromEntries();

About

Modern Javascript methods (ES6+) for the Earth Engine Code Editor

Topics

Resources

License

Stars

Watchers

Forks