From dbf9048d8f55366b03ccdd417b34e9985797a191 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 3 Aug 2018 16:07:30 +0200 Subject: [PATCH 1/3] Expose the getUid function It is often useful in application code to have a way to uniquely identify and object. Exposing the OpenLayers mechanism allows for best performance and avoid unneccessary dirt. --- src/ol/util.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ol/util.js b/src/ol/util.js index beecbdc9fa..2eee713b3d 100644 --- a/src/ol/util.js +++ b/src/ol/util.js @@ -44,6 +44,7 @@ let uidCounter_ = 0; * * @param {Object} obj The object to get the unique ID for. * @return {number} The unique ID for the object. + * @api */ export function getUid(obj) { return obj.ol_uid || (obj.ol_uid = ++uidCounter_); From a4178d05efa854b2c9dee5e8419ecf3d0002f694 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 3 Aug 2018 16:12:02 +0200 Subject: [PATCH 2/3] Expose the stableSort function This is a low level function, essential to OpenLayers so it is always shipped with OpenLayers. --- src/ol/array.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ol/array.js b/src/ol/array.js index 47dc5d0876..1ed24b0a96 100644 --- a/src/ol/array.js +++ b/src/ol/array.js @@ -196,6 +196,7 @@ export function equals(arr1, arr2) { /** * @param {Array<*>} arr The array to sort (modifies original). * @param {Function} compareFnc Comparison function. + * @api */ export function stableSort(arr, compareFnc) { const length = arr.length; From abbfb5c653053afcc37da7e4ac69008678fa3327 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 6 Aug 2018 10:46:54 +0200 Subject: [PATCH 3/3] Document the stableSort function --- src/ol/array.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ol/array.js b/src/ol/array.js index 1ed24b0a96..bb9796c096 100644 --- a/src/ol/array.js +++ b/src/ol/array.js @@ -194,8 +194,10 @@ export function equals(arr1, arr2) { /** + * Sort the passed array such that the relative order of equal elements is preverved. + * See https://en.wikipedia.org/wiki/Sorting_algorithm#Stability for details. * @param {Array<*>} arr The array to sort (modifies original). - * @param {Function} compareFnc Comparison function. + * @param {!function(*, *): number} compareFnc Comparison function. * @api */ export function stableSort(arr, compareFnc) {