Skip to content

disable deconstruction and assignment #2398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/Class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ class Class {
*/
static addInitHook(fn: Function | string, ...args) {
const init: Function = typeof fn === 'function' ? fn : function () {
this[fn].call(this, ...args);
// eslint-disable-next-line prefer-spread
this[fn].apply(this, args);
};
const proto = this.prototype;
const parentProto = Object.getPrototypeOf(proto);
Expand Down
6 changes: 5 additions & 1 deletion src/core/CollisionIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ class CollisionIndex {
* @returns {Boolean}
*/
collides(box) {
[search.minX, search.minY, search.maxX, search.maxY] = box;
// [search.minX, search.minY, search.maxX, search.maxY] = box;
search.minX = box[0];
search.minY = box[1];
search.maxX = box[2];
search.maxY = box[3];
return this._tree.collides(search);
}

Expand Down
10 changes: 6 additions & 4 deletions src/core/Eventable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export default function <T extends MixinConstructor>(Base: T) {
* @param context - the context of the handler
*/
addEventListener(...args): this {
return this.on.call(this, ...args);
// eslint-disable-next-line prefer-spread
return this.on.apply(this, args);
}

/**
Expand Down Expand Up @@ -228,7 +229,8 @@ export default function <T extends MixinConstructor>(Base: T) {
* @param context - the context of the handler
*/
removeEventListener(...args) {
return this.off.call(this, ...args);
// eslint-disable-next-line prefer-spread
return this.off.apply(this, args);
}

/**
Expand Down Expand Up @@ -322,9 +324,9 @@ export default function <T extends MixinConstructor>(Base: T) {
delete fn[key];
called = true;
if (context) {
handler.call(context, ...args);
handler.apply(context, args);
} else {
handler.call(this, ...args);
handler.apply(this, args);
}
(onceHandler as any)._called = true;
// me.off(evtType, onceHandler, this);
Expand Down
6 changes: 4 additions & 2 deletions src/core/util/bbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ export function bboxIntersect(bbox1: BBOX, bbox2: BBOX) {
}

export function bboxInBBOX(bbox1: BBOX, bbox2: BBOX) {
const [x1, y1, x2, y2] = bbox1;
// const [x1, y1, x2, y2] = bbox1;
const x1 = bbox1[0], y1 = bbox1[1], x2 = bbox1[2], y2 = bbox1[3];
return x1 >= bbox2[0] && x2 <= bbox2[2] && y1 >= bbox2[1] && y2 <= bbox2[3];
}

Expand Down Expand Up @@ -144,7 +145,8 @@ export function bboxInMask(bbox: BBOX, maskGeoJSON: Record<string, any>): boolea
if (result.length > 0) {
let minx = Infinity, maxx = -Infinity, miny = Infinity, maxy = -Infinity;
for (let j = 0, len1 = result.length; j < len1; j++) {
const [x, y] = result[j];
// const [x, y] = result[j];
const x = result[j][0], y = result[j][1];
minx = Math.min(x, minx);
miny = Math.min(y, miny);
maxx = Math.max(x, maxx);
Expand Down
9 changes: 7 additions & 2 deletions src/core/util/marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ export function getMarkerRotationExtent(out: PointExtent, rad: number, width: nu
minx += rx;
miny += ry;
//计算旋转图形后新的图形的BBOX
const [offsetX, offsetY, w, h] = getImageRotateBBOX(width, height, rad);
const bbox = getImageRotateBBOX(width, height, rad);
const offsetX = bbox[0];
const offsetY = bbox[1];
const w = bbox[2];
const h = bbox[3];
// const [offsetX, offsetY, w, h] = getImageRotateBBOX(width, height, rad);
minx += offsetX;
miny += offsetY;
const maxx = minx + Math.max(width, w), maxy = miny + Math.max(height, h);
Expand Down Expand Up @@ -213,7 +218,7 @@ function rotateExtent(fixedExtent: PointExtent, angle: number) {
return ROTATE_EXTENT.convertTo(p => p._rotate(angle), fixedExtent);
}

export function getMarkerRotation(symbol:any, prop = 'markerRotation') {
export function getMarkerRotation(symbol: any, prop = 'markerRotation') {
const r = symbol[prop];
if (!isNumber(r)) {
return 0;
Expand Down
5 changes: 3 additions & 2 deletions src/core/util/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ export function replaceVariable(str: string, props: Object) {
}
return value;
}
const [left, right] = TEMPLATE_CHARS;
// const [left, right] = TEMPLATE_CHARS;
const left = TEMPLATE_CHARS[0], right = TEMPLATE_CHARS[1];
const keys = templateKeys(str);
for (let i = 0, len = keys.length; i < len; i++) {
const key = keys[i];
Expand All @@ -202,7 +203,7 @@ export function replaceVariable(str: string, props: Object) {

function templateKeys(str) {
str += EMPTY_STRING;
const [left, right] = TEMPLATE_CHARS;
const left = TEMPLATE_CHARS[0], right = TEMPLATE_CHARS[1];
const keys = [];
let start = false;
let key = EMPTY_STRING;
Expand Down
4 changes: 3 additions & 1 deletion src/geo/Point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ class Point extends Position {
}

_perp() {
[this.x, this.y] = [-this.y, this.x]
const x = this.x;
this.x = -this.y;
this.y = x;
return this;
}

Expand Down
12 changes: 8 additions & 4 deletions src/geometry/Geometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,11 @@ export class Geometry extends JSONAble(Eventable(Handlerable(Class))) {
const bbox = getDefaultBBOX();
//cal all points center
pointsBBOX(coord, bbox);
const [minx, miny, maxx, maxy] = bbox;
// const [minx, miny, maxx, maxy] = bbox;
const minx = bbox[0];
const miny = bbox[1];
const maxx = bbox[2];
const maxy = bbox[3];
cx = (minx + maxx) / 2;
cy = (miny + maxy) / 2;
}
Expand Down Expand Up @@ -1928,9 +1932,9 @@ export class Geometry extends JSONAble(Eventable(Handlerable(Class))) {
_genMinMaxAlt(): void {
if (this._minAlt === undefined || this._maxAlt === undefined) {
const altitude = this._getAltitude();
const [min, max] = getMinMaxAltitude(altitude);
this._minAlt = min;
this._maxAlt = max;
const minmax = getMinMaxAltitude(altitude);
this._minAlt = minmax[0];
this._maxAlt = minmax[1];
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/geometry/MultiPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class MultiPath extends MultiGeometry {
*/
getCenterInExtent(extent: Extent): null | Coordinate {
const children = this.getGeometries();
let [sumx, sumy, counter] = [0, 0, 0];
let sumx = 0,
sumy = 0,
counter = 0;
children.forEach(l => {
// @ts-expect-error todo
const c = l.getCenterInExtent(extent);
Expand Down
9 changes: 6 additions & 3 deletions src/geometry/Path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ export class Path extends Geometry {
if (clipped.length === 0) {
return null;
}
let [sumx, sumy, counter] = [0, 0, 0];
// let [sumx, sumy, counter] = [0, 0, 0];
let sumx = 0, sumy = 0, counter = 0;
clipped.forEach(part => {
if (Array.isArray(part)) {
part.forEach(c => {
Expand Down Expand Up @@ -420,7 +421,8 @@ export class Path extends Geometry {
}
const rings = [shell];
if (this.hasHoles && this.hasHoles()) {
rings.push.call(rings, ...this.getHoles());
// eslint-disable-next-line prefer-spread
rings.push.apply(rings, this.getHoles());
}
return this._coords2Extent(rings, this._getProjection());
}
Expand All @@ -429,7 +431,8 @@ export class Path extends Geometry {
_computePrjExtent(_?: any): Extent {
const coords = [this._getPrjCoordinates()];
if (this.hasHoles && this.hasHoles()) {
coords.push.call(coords, ...this._getPrjHoles());
// eslint-disable-next-line prefer-spread
coords.push.apply(coords, this._getPrjHoles());
}
return this._coords2Extent(coords);
}
Expand Down
14 changes: 10 additions & 4 deletions src/geometry/Sector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ export class Sector extends Circle {
//@internal
_getShell(): RingCoordinates {

const [startAngle, endAngle] = this._correctAngles();
const angles = this._correctAngles();
const startAngle = angles[0], endAngle = angles[1];
// const [startAngle, endAngle] = this._correctAngles();

const measurer = this._getMeasurer(),
center = this.getCoordinates(),
Expand Down Expand Up @@ -183,7 +185,9 @@ export class Sector extends Circle {
// [0.0, 360.0)
angle = atan2 < 0 ? (atan2 + 2 * Math.PI) * 360 / (2 * Math.PI) :
atan2 * 360 / (2 * Math.PI);
const [startAngle, endAngle] = this._correctAngles();
// const [startAngle, endAngle] = this._correctAngles();
const angles = this._correctAngles();
const startAngle = angles[0], endAngle = angles[1];
const sAngle = startAngle % 360,
eAngle = endAngle % 360;
let between = false;
Expand All @@ -200,7 +204,8 @@ export class Sector extends Circle {
if (isNil(this._radius)) {
return 0;
}
const [startAngle, endAngle] = this._correctAngles();
const angles = this._correctAngles();
const startAngle = angles[0], endAngle = angles[1];
return Math.PI * 2 * this._radius * Math.abs(startAngle - endAngle) / 360 + 2 * this._radius;
}

Expand All @@ -209,7 +214,8 @@ export class Sector extends Circle {
if (isNil(this._radius)) {
return 0;
}
const [startAngle, endAngle] = this._correctAngles();
const angles = this._correctAngles();
const startAngle = angles[0], endAngle = angles[1];
return Math.PI * Math.pow(this._radius, 2) * Math.abs(startAngle - endAngle) / 360;
}

Expand Down
16 changes: 10 additions & 6 deletions src/geometry/editor/GeometryEditor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { INTERNAL_LAYER_PREFIX } from '../../core/Constants';
import { isNil, isNumber, sign, removeFromArray, UID, isFunction } from '../../core/util';
import { isNil, isNumber, sign, removeFromArray, UID, isFunction, extend } from '../../core/util';
import { lowerSymbolOpacity } from '../../core/util/style';
import Class from '../../core/Class';
import Eventable from '../../core/Eventable';
Expand Down Expand Up @@ -1015,7 +1015,7 @@ class GeometryEditor extends Eventable(Class) {
* @property {String} type - handleremove
* @property {Geometry} target - the geometry fires the event
*/
me._geometry.fire('handleremove', Object.assign({}, param, { coordinate: map.containerPointToCoordinate(param.containerPoint), vertex: param.target }));
me._geometry.fire('handleremove', extend({}, param, { coordinate: map.containerPointToCoordinate(param.containerPoint), vertex: param.target }));
}

function moveVertexHandle(handleConatainerPoint: any, index: number, ringIndex: number = 0): void {
Expand Down Expand Up @@ -1384,15 +1384,19 @@ class GeometryEditor extends Eventable(Class) {
record[0].forEach(o => {
const m = o[0],
args = o.slice(1);
geoToEdit[m].call(geoToEdit, ...args);
// eslint-disable-next-line prefer-spread
geoToEdit[m].apply(geoToEdit, args);
if (geoToEdit !== geo) {
geo[m].call(geo, ...args);
// eslint-disable-next-line prefer-spread
geo[m].apply(geo, args);
}
});
} else {
geoToEdit[record[0]].call(geoToEdit, ...record[1]);
// eslint-disable-next-line prefer-spread
geoToEdit[record[0]].apply(geoToEdit, record[1]);
if (geoToEdit !== geo) {
geo[record[0]].call(geo, ...record[1]);
// eslint-disable-next-line prefer-spread
geo[record[0]].apply(geo, record[1]);
}
}
this._updating = updating;
Expand Down
4 changes: 2 additions & 2 deletions src/layer/Layer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Class from '../core/Class';
import { isFunction, isNil, isNumber } from '../core/util';
import { extend, isFunction, isNil, isNumber } from '../core/util';
import Eventable from '../core/Eventable';
import JSONAble from '../core/JSONAble';
import Renderable from '../renderer/Renderable';
Expand Down Expand Up @@ -867,7 +867,7 @@ Layer.prototype.fire = function (eventType: string, param) {
* @property {Layer} target - the layer fires the event
* @property {Boolean} visible - value of visible
*/
this.fire('visiblechange', Object.assign({}, param, { visible: this.options.visible }));
this.fire('visiblechange', extend({}, param, { visible: this.options.visible }));
}
return this;
};
Expand Down
22 changes: 15 additions & 7 deletions src/layer/tile/TileLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
isString,
extend,
Vector3,
Matrix4
Matrix4,
pushIn
} from '../../core/util';
import LRUCache, { ArrayLRUCache } from '../../core/util/LRUCache';
import Browser from '../../core/Browser';
Expand Down Expand Up @@ -495,7 +496,9 @@ class TileLayer extends Layer {
this._disablePyramid = true;
return this.getTiles(z, layer);
}
queue = [...rootNodes.tiles];
// queue = [...rootNodes.tiles];
queue = [];
pushIn(queue, rootNodes.tiles);
}
} else {
const rootNodes = this._getRootNodes(offset0);
Expand All @@ -504,7 +507,9 @@ class TileLayer extends Layer {
this._disablePyramid = true;
return this.getTiles(z, layer);
}
queue = [...rootNodes.tiles];
// queue = [...rootNodes.tiles];
queue = [];
pushIn(queue, rootNodes.tiles);
}
const glRes = map.getGLRes();
const offsets = {
Expand Down Expand Up @@ -618,13 +623,15 @@ class TileLayer extends Layer {
}
if (z === maxZoom) {
if (hasCurrentIn) {
queue.push(...children);
// queue.push(...children);
pushIn(queue, children);
} else {
tiles.push(node);
gridExtent._combine(node.extent2d);
}
} else {
queue.push(...children);
// queue.push(...children);
pushIn(queue, children);
}

}
Expand Down Expand Up @@ -728,7 +735,8 @@ class TileLayer extends Layer {
const renderer = this.getRenderer();
let { xmin, ymin, xmax, ymax } = node.extent2d;
if (node.offset && !isFunction(this.options.offset)) {
const [x, y] = node.offset;
const xyoffset = node.offset;
const x = xyoffset[0], y = xyoffset[1];
xmin += x;
xmax += x;
ymin += y;
Expand Down Expand Up @@ -1349,7 +1357,7 @@ class TileLayer extends Layer {
// offset result can't be cached, as it varies with map's center.
let offset = this.options['offset'];
if (isFunction(offset)) {
offset = offset.call(this, ...params);
offset = offset.apply(this, params);
}
if (isNumber(offset)) {
offset = [offset, offset];
Expand Down
6 changes: 4 additions & 2 deletions src/map/Map.CoordTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,10 @@ Map.include(/** @lends Map.prototype */{
const min2d = extent2D.getMin(),
max2d = extent2D.getMax();
const fullExtent = this.getFullExtent();
const [minx, maxx] = (!fullExtent || fullExtent.left <= fullExtent.right) ? [min2d.x, max2d.x] : [max2d.x, min2d.x];
const [miny, maxy] = (!fullExtent || fullExtent.top > fullExtent.bottom) ? [max2d.y, min2d.y] : [min2d.y, max2d.y];
const minmaxx = (!fullExtent || fullExtent.left <= fullExtent.right) ? [min2d.x, max2d.x] : [max2d.x, min2d.x];
const minmaxy = (!fullExtent || fullExtent.top > fullExtent.bottom) ? [max2d.y, min2d.y] : [min2d.y, max2d.y];
const minx = minmaxx[0], maxx = minmaxx[1];
const miny = minmaxy[0], maxy = minmaxy[1];
const min = min2d.set(minx, maxy);
const max = max2d.set(maxx, miny);
return new Extent(
Expand Down
Loading