Skip to content

Commit

Permalink
Use native Number.MAX_SAFE_INTEGER value
Browse files Browse the repository at this point in the history
  • Loading branch information
fredj committed Aug 31, 2021
1 parent 4c8bf72 commit 55ad0bf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/data/feature_position_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,9 @@ export default class FeaturePositionMap {
}
}

const MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;

function getNumericId(value: unknown) {
const numValue = +value;
if (!isNaN(numValue) && numValue <= MAX_SAFE_INTEGER) {
if (!isNaN(numValue) && numValue <= Number.MAX_SAFE_INTEGER) {
return numValue;
}
return murmur3(String(value));
Expand Down
4 changes: 2 additions & 2 deletions src/style/style_layer/line_style_layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import LineBucket from '../../data/bucket/line_bucket';
import {polygonIntersectsBufferedMultiLine} from '../../util/intersection_tests';
import {getMaximumPaintValue, translateDistance, translate} from '../query_utils';
import properties, {LayoutPropsPossiblyEvaluated, PaintPropsPossiblyEvaluated} from './line_style_layer_properties';
import {extend, MAX_SAFE_INTEGER} from '../../util/util';
import {extend} from '../../util/util';
import EvaluationParameters from '../evaluation_parameters';
import {Transitionable, Transitioning, Layout, PossiblyEvaluated, DataDrivenProperty} from '../properties';

Expand Down Expand Up @@ -58,7 +58,7 @@ class LineStyleLayer extends StyleLayer {
if (name === 'line-gradient') {
const expression: ZoomConstantExpression<"source"> = (this._transitionablePaint._values['line-gradient'].value.expression as any);
this.stepInterpolant = expression._styleExpression.expression instanceof Step;
this.gradientVersion = (this.gradientVersion + 1) % MAX_SAFE_INTEGER;
this.gradientVersion = (this.gradientVersion + 1) % Number.MAX_SAFE_INTEGER;
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import Point from '../symbol/point';

import type {Callback} from '../types/callback';

// Number.MAX_SAFE_INTEGER not available in IE
export const MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;

/**
* @module util
* @private
Expand Down

0 comments on commit 55ad0bf

Please sign in to comment.