Skip to content

Commit 6b968a0

Browse files
committed
Deep cloning of cluster properties. Closes #215
1 parent fff7326 commit 6b968a0

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,11 @@ export default class Supercluster {
369369
_map(data, i, clone) {
370370
if (data[i + OFFSET_NUM] > 1) {
371371
const props = this.clusterProps[data[i + OFFSET_PROP]];
372-
return clone ? Object.assign({}, props) : props;
372+
return clone ? structuredClone(props) : props;
373373
}
374374
const original = this.points[data[i + OFFSET_ID]].properties;
375375
const result = this.options.map(original);
376-
return clone && result === original ? Object.assign({}, result) : result;
376+
return clone && result === original ? structuredClone(result) : result;
377377
}
378378
}
379379

@@ -395,8 +395,8 @@ function getClusterProperties(data, i, clusterProps) {
395395
count >= 10000 ? `${Math.round(count / 1000) }k` :
396396
count >= 1000 ? `${Math.round(count / 100) / 10 }k` : count;
397397
const propIndex = data[i + OFFSET_PROP];
398-
const properties = propIndex === -1 ? {} : Object.assign({}, clusterProps[propIndex]);
399-
return Object.assign(properties, {
398+
const properties = propIndex === -1 ? {} : structuredClone(clusterProps[propIndex]);
399+
return Object.assign(properties ?? {}, {
400400
cluster: true,
401401
cluster_id: data[i + OFFSET_ID],
402402
point_count: count,

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"name": "supercluster",
33
"version": "8.0.1",
44
"description": "A very fast geospatial point clustering library.",
5+
"engines": {
6+
"node": ">=17.0.0"
7+
},
58
"main": "dist/supercluster.js",
69
"type": "module",
710
"exports": "./index.js",

0 commit comments

Comments
 (0)