Remove opt_this param in ol/extent

This commit is contained in:
Frederic Junod
2019-04-08 13:39:42 +02:00
parent c20bdedcac
commit 187f58c1c3
3 changed files with 8 additions and 16 deletions

View File

@@ -400,26 +400,25 @@ export function extendXY(extent, x, y) {
* callback returns a truthy value the function returns that value * callback returns a truthy value the function returns that value
* immediately. Otherwise the function returns `false`. * immediately. Otherwise the function returns `false`.
* @param {Extent} extent Extent. * @param {Extent} extent Extent.
* @param {function(this:T, import("./coordinate.js").Coordinate): S} callback Callback. * @param {function(import("./coordinate.js").Coordinate): S} callback Callback.
* @param {T=} opt_this Value to use as `this` when executing `callback`.
* @return {S|boolean} Value. * @return {S|boolean} Value.
* @template S, T * @template S
*/ */
export function forEachCorner(extent, callback, opt_this) { export function forEachCorner(extent, callback) {
let val; let val;
val = callback.call(opt_this, getBottomLeft(extent)); val = callback(getBottomLeft(extent));
if (val) { if (val) {
return val; return val;
} }
val = callback.call(opt_this, getBottomRight(extent)); val = callback(getBottomRight(extent));
if (val) { if (val) {
return val; return val;
} }
val = callback.call(opt_this, getTopRight(extent)); val = callback(getTopRight(extent));
if (val) { if (val) {
return val; return val;
} }
val = callback.call(opt_this, getTopLeft(extent)); val = callback(getTopLeft(extent));
if (val) { if (val) {
return val; return val;
} }

View File

@@ -143,7 +143,7 @@ class Circle extends SimpleGeometry {
return true; return true;
} }
return forEachCorner(extent, this.intersectsCoordinate, this); return forEachCorner(extent, this.intersectsCoordinate.bind(this));
} }
return false; return false;

View File

@@ -239,13 +239,6 @@ describe('ol.extent', function() {
} }
); );
it('calls the callback with given scope', function() {
const extent = [1, 2, 3, 4];
const scope = {humpty: 'dumpty'};
_ol_extent_.forEachCorner(extent, callbackTrue, scope);
expect(callbackTrue.calledOn(scope)).to.be(true);
});
}); });
describe('getArea', function() { describe('getArea', function() {