Make classes in ol/ available as named exports from ol

This commit is contained in:
ahocevar
2018-06-21 17:53:45 +02:00
parent 15d116b3c1
commit 28409486a5
218 changed files with 334 additions and 330 deletions

55
src/ol/util.js Normal file
View File

@@ -0,0 +1,55 @@
/**
* @module ol/util
*/
/**
* Inherit the prototype methods from one constructor into another.
*
* Usage:
*
* function ParentClass(a, b) { }
* ParentClass.prototype.foo = function(a) { }
*
* function ChildClass(a, b, c) {
* // Call parent constructor
* ParentClass.call(this, a, b);
* }
* inherits(ChildClass, ParentClass);
*
* var child = new ChildClass('a', 'b', 'see');
* child.foo(); // This works.
*
* @param {!Function} childCtor Child constructor.
* @param {!Function} parentCtor Parent constructor.
* @function module:ol.inherits
* @api
*/
export function inherits(childCtor, parentCtor) {
childCtor.prototype = Object.create(parentCtor.prototype);
childCtor.prototype.constructor = childCtor;
}
/**
* Counter for getUid.
* @type {number}
* @private
*/
let uidCounter_ = 0;
/**
* Gets a unique ID for an object. This mutates the object so that further calls
* with the same object as a parameter returns the same value. Unique IDs are generated
* as a strictly increasing sequence. Adapted from goog.getUid.
*
* @param {Object} obj The object to get the unique ID for.
* @return {number} The unique ID for the object.
*/
export function getUid(obj) {
return obj.ol_uid || (obj.ol_uid = ++uidCounter_);
}
/**
* OpenLayers version.
* @type {string}
*/
export const VERSION = '5.0.0-beta.14';