@google/earthengine 1.7.10 → 1.7.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/earthengine",
3
- "version": "1.7.10",
3
+ "version": "1.7.12",
4
4
  "description": "JavaScript client for Google Earth Engine API.",
5
5
  "author": "Google LLC",
6
6
  "license": "Apache-2.0",
package/src/apiclient.js CHANGED
@@ -24,7 +24,7 @@ const {trustedResourceUrl} = goog.require('safevalues.index');
24
24
  /** @namespace */
25
25
  const apiclient = {};
26
26
 
27
- const API_CLIENT_VERSION = '1.7.10';
27
+ const API_CLIENT_VERSION = '1.7.12';
28
28
 
29
29
  exports.VERSION = apiVersion.VERSION;
30
30
  exports.API_CLIENT_VERSION = API_CLIENT_VERSION;
@@ -167,11 +167,11 @@ ee.ApiFunction.lookup = function(name) {
167
167
  * Looks up an API function by name, but doesn't throw an error.
168
168
  *
169
169
  * @param {string} name The name of the function to get.
170
- * @return {!ee.ApiFunction} The requested function or null if it's not found.
170
+ * @return {!ee.ApiFunction|null} The requested function or null if it's not found.
171
171
  */
172
172
  ee.ApiFunction.lookupInternal = function(name) {
173
173
  ee.ApiFunction.initialize();
174
- return ee.ApiFunction.api_[name] || null;
174
+ return ee.ApiFunction.api_.hasOwnProperty(name) ? ee.ApiFunction.api_[name] : null;
175
175
  };
176
176
 
177
177
 
@@ -244,49 +244,63 @@ ee.ApiFunction.reset = function() {
244
244
  ee.ApiFunction.importApi = function(target, prefix, typeName, opt_prepend) {
245
245
  ee.ApiFunction.initialize();
246
246
  const prepend = opt_prepend || '';
247
- goog.object.forEach(ee.ApiFunction.api_, function(apiFunc, name) {
248
- const parts = name.split('.');
249
- if (parts.length == 2 && parts[0] == prefix) {
250
- const fname = prepend + parts[1];
251
- const signature = apiFunc.getSignature();
252
-
253
- // Mark signatures as used.
254
- ee.ApiFunction.boundSignatures_[name] = true;
255
-
256
- // Decide whether this is a static or an instance function.
257
- let isInstance = false;
258
- if (signature['args'].length) {
259
- const firstArgType = signature['args'][0]['type'];
260
- isInstance = firstArgType != 'Object' &&
261
- ee.Types.isSubtype(firstArgType, typeName);
262
- }
263
- // Assume we have a constructor Function if we get an instance method.
264
- const destination =
265
- isInstance ? /** @type {!Function} */(target).prototype : target;
247
+ const api = ee.ApiFunction.api_;
248
+ for (const name in api) {
249
+ // "names" in API either look like:
250
+ // - `Array` (base constructor), or
251
+ // - `Array.method` (methods)
252
+
253
+ // Ignore properties inherited from the prototype chain.
254
+ if (!Object.prototype.hasOwnProperty.call(api, name)) {
255
+ continue;
256
+ }
257
+ const apiFunc = api[name];
258
+ const parts = name.split('.'); // Should be api group and api method.
259
+ if (parts.length !== 2 || parts[0] !== prefix) {
260
+ continue;
261
+ }
266
262
 
267
- if (fname in destination && !destination[fname]['signature']) {
268
- // Don't overwrite client-defined functions.
269
- return;
270
- }
263
+ const apiMethod = parts[1];
264
+
265
+ const fname = prepend + apiMethod;
266
+ const signature = apiFunc.getSignature();
267
+
268
+ // Mark signatures as used.
269
+ ee.ApiFunction.boundSignatures_[name] = true;
271
270
 
272
- // Add the actual function
273
- /**
274
- * @param {*} var_args
275
- * @return {!ee.ComputedObject}
276
- * @this {*}
277
- **/
278
- destination[fname] = function(var_args) {
279
- return apiFunc.callOrApply(
280
- isInstance ? this : undefined,
281
- Array.prototype.slice.call(arguments, 0));
282
- };
283
- // Add a friendly formatting.
284
- destination[fname].toString =
285
- goog.bind(apiFunc.toString, apiFunc, fname, isInstance);
286
- // Attach the signature object for documentation generators.
287
- destination[fname]['signature'] = signature;
271
+ // Decide whether this is a static or an instance function.
272
+ let isInstance = false;
273
+ if (signature['args'].length) {
274
+ const firstArgType = signature['args'][0]['type'];
275
+ isInstance = firstArgType != 'Object' &&
276
+ ee.Types.isSubtype(firstArgType, typeName);
288
277
  }
289
- });
278
+ // Assume we have a constructor Function if we get an instance method.
279
+ const destination =
280
+ isInstance ? /** @type {!Function} */ (target).prototype : target;
281
+
282
+ if (fname in destination && !destination[fname]['signature']) {
283
+ // Don't overwrite client-defined functions.
284
+ continue;
285
+ }
286
+
287
+ // Add the actual function
288
+ /**
289
+ * @param {*} var_args
290
+ * @return {!ee.ComputedObject}
291
+ * @this {*}
292
+ **/
293
+ destination[fname] = function(var_args) {
294
+ return apiFunc.callOrApply(
295
+ isInstance ? this : undefined,
296
+ Array.prototype.slice.call(arguments, 0));
297
+ };
298
+ // Add a friendly formatting.
299
+ destination[fname].toString =
300
+ goog.bind(apiFunc.toString, apiFunc, fname, isInstance);
301
+ // Attach the signature object for documentation generators.
302
+ destination[fname]['signature'] = signature;
303
+ }
290
304
  };
291
305
 
292
306