{"name":"supercluster","version":"9.0.0","keywords":["clustering","geospatial","markers"],"author":{"name":"Vladimir Agafonkin"},"license":"ISC","_id":"supercluster@9.0.0","maintainers":[{"name":"mapbox-npm-01","email":"accounts+npmjs-01@mapbox.com"},{"name":"mapbox-npm-02","email":"accounts+npmjs-02@mapbox.com"},{"name":"mapbox-npm-07","email":"accounts+npmjs-07@mapbox.com"},{"name":"mapbox-npm-03","email":"accounts+npmjs-03@mapbox.com"},{"name":"mapbox-npm-04","email":"accounts+npmjs-04@mapbox.com"},{"name":"mapbox-npm-09","email":"accounts+npmjs-09@mapbox.com"},{"name":"mapbox-npm-05","email":"accounts+npmjs-05@mapbox.com"},{"name":"mapbox-npm-06","email":"accounts+npmjs-06@mapbox.com"},{"name":"mapbox-npm-08","email":"accounts+npmjs-08@mapbox.com"},{"name":"mapbox-npm-advanced-actions","email":"accounts+npmjs-advanced-actions@mapbox.com"},{"name":"mapbox-npm-ci","email":"accounts+npmjs-npm-ci@mapbox.com"},{"name":"mapbox-npm","email":"accounts+npmjs@mapbox.com"},{"name":"mapbox-admin","email":"accounts@mapbox.com"},{"name":"mapbox-machine-user","email":"accounts+npm-mapbox-machine-user@mapbox.com"},{"name":"mbx-npm-ci-staging","email":"yannick.meeus+npm+staging+ci@mapbox.com"},{"name":"mbx-npm-ci-production","email":"yannick.meeus+npm+production+ci@mapbox.com"},{"name":"mbx-npm-01-production","email":"yannick.meeus+npm+prod+01@mapbox.com"},{"name":"mbx-npm-02-production","email":"yannick.meeus+npm+prod+02@mapbox.com"},{"name":"mbx-npm-03-production","email":"yannick.meeus+npm+prod+03@mapbox.com"},{"name":"mbx-npm-04-production","email":"yannick.meeus+npm+prod+04@mapbox.com"},{"name":"mbx-npm-05-production","email":"yannick.meeus+npm+prod+05@mapbox.com"},{"name":"mbx-npm-06-production","email":"yannick.meeus+npm+prod+06@mapbox.com"},{"name":"mbx-npm-07-production","email":"yannick.meeus+npm+prod+07@mapbox.com"},{"name":"mbx-npm-08-production","email":"yannick.meeus+npm+prod+08@mapbox.com"},{"name":"mbx-npm-09-production","email":"yannick.meeus+npm+prod+09@mapbox.com"},{"name":"mbx-npm-02-staging","email":"yannick.meeus@mapbox.com"},{"name":"mbx-npm-advanced-actions-staging","email":"yannick.meeus+npm+staging+advanced+actions@mapbox.com"},{"name":"mbx-npm-advanced-actions-production","email":"yannick.meeus+npm+prod+advanced+actions@mapbox.com"},{"name":"mourner","email":"agafonkin@gmail.com"}],"homepage":"https://github.com/mapbox/supercluster#readme","bugs":{"url":"https://github.com/mapbox/supercluster/issues"},"dist":{"shasum":"0af9154283af452bee0df1d64c14bbb36c1f3757","tarball":"http://registry-npm.ywwl.com/supercluster/download/supercluster-9.0.0.tgz","fileCount":6,"integrity":"sha512-SaU8dQaxagTXr8+a1f67Pxg5CiRcZsq+LPQsZoV2r+FD8EF3Wpg5v7Zl8STPhml3oWHF1CQ8YaJGf8Uo8zS5qg==","signatures":[{"sig":"MEQCIAsaE+vS2Sg+xHIWHUwszQztcptLgBLJwkRaGAkMbunBAiBtE9oRpIx1IfvsvU6/lxJYBWF+16pYop+npgIEy18ZMg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIAR0FKTB5ZmTLTczCE1vCYTiftwmtSXoBJTSxXlI07lSAiEA0JQSBlpW7exHhBRcVmmU9/zx7mgu/YBikQbFIajS0s0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":67060,"size":19337,"noattachment":false,"key":"/supercluster/-/supercluster-9.0.0.tgz"},"main":"dist/supercluster.js","type":"module","unpkg":"dist/supercluster.min.js","module":"index.js","exports":"./index.js","gitHead":"5071bca748eddfd295ad2c2cdd8e490128acce76","scripts":{"cov":"node --test --experimental-test-coverage","test":"node --test","bench":"node --expose-gc bench.js","build":"mkdirp dist && rollup -c","pretest":"eslint index.js bench.js test/test.js demo/index.js demo/worker.js","prepublishOnly":"npm run test && npm run build"},"_npmUser":{"name":"mourner","email":"agafonkin@gmail.com"},"jsdelivr":"dist/supercluster.min.js","repository":{"url":"git://github.com/mapbox/supercluster.git","type":"git"},"_npmVersion":"12.0.2","description":"A very fast geospatial point clustering library.","directories":{},"sideEffects":false,"_nodeVersion":"24.18.1","allowScripts":{"fsevents@2.3.3":true},"dependencies":{"kdbush":"^4.1.0"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^10.8.0","mkdirp":"^3.0.1","rollup":"^4.62.4","@rollup/plugin-terser":"^1.0.0","eslint-config-mourner":"^5.0.1","@rollup/plugin-node-resolve":"^16.0.3"},"_npmOperationalInternal":{"tmp":"tmp/supercluster_9.0.0_1786355059877_0.30196397205718783","host":"s3://npm-registry-packages-npm-production"},"readme":"# supercluster [![Simply Awesome](https://img.shields.io/badge/simply-awesome-brightgreen.svg)](https://github.com/mourner/projects) [![Node](https://github.com/mapbox/supercluster/actions/workflows/node.yml/badge.svg)](https://github.com/mapbox/supercluster/actions/workflows/node.yml)\n\nA very fast JavaScript library for geospatial point clustering for browsers and Node.\n\n```js\nconst index = new Supercluster({radius: 40, maxZoom: 16});\nindex.load(points);\n\nconst clusters = index.getClusters([-180, -85, 180, 85], 2);\n```\n\nClustering 6 million points in Leaflet:\n\n![clustering demo on an interactive Leaflet map](https://cloud.githubusercontent.com/assets/25395/11857351/43407b46-a40c-11e5-8662-e99ab1cd2cb7.gif)\n\nSupercluster was built to power clustering in [Mapbox GL JS](https://www.mapbox.com/mapbox-gljs). Read about how it works [on the Mapbox blog](https://blog.mapbox.com/clustering-millions-of-points-on-a-map-with-supercluster-272046ec5c97).\n\n## Install\n\nInstall using NPM (`npm install supercluster`) or Yarn (`yarn add supercluster`), then:\n\n```js\n// import as a ES module in Node\nimport Supercluster from 'supercluster';\n\n// import from a CDN in the browser:\nimport Supercluster from 'https://esm.run/supercluster';\n```\n\nOr use it with an ordinary script tag in the browser:\n\n```html\n<script src=\"https://unpkg.com/supercluster@8.0.0/dist/supercluster.min.js\"></script>\n```\n\n## Methods\n\n#### `load(points)`\n\nLoads an array of [GeoJSON Feature](https://tools.ietf.org/html/rfc7946#section-3.2) objects. Each feature's `geometry` must be a [GeoJSON Point](https://tools.ietf.org/html/rfc7946#section-3.1.2) or [MultiPoint](https://tools.ietf.org/html/rfc7946#section-3.1.3) — a MultiPoint is clustered as an individual point per coordinate, each inheriting the feature's `properties` and `id`. Once loaded, index is immutable.\n\n#### `getClusters(bbox, zoom)`\n\nFor the given `bbox` array (`[westLng, southLat, eastLng, northLat]`) and integer `zoom`, returns an array of clusters and points as [GeoJSON Feature](https://tools.ietf.org/html/rfc7946#section-3.2) objects.\n\n#### `getTile(z, x, y)`\n\nFor a given zoom and x/y coordinates, returns a [geojson-vt](https://github.com/mapbox/geojson-vt)-compatible JSON tile object with cluster/point features, or `null` where there's no data.\n\n#### `getTileRaw(z, x, y)`\n\nThe same tile, but with each feature flat &mdash; `{type: 4, x, y, tags}`, coords inline instead of\nwrapped in a nested `geometry` array. Every clustered feature is a single point, so this is exactly\ngeojson-vt's `getTileRaw` shape narrowed to its lone-point (`type: 4`) variant.\n\n#### `getChildren(clusterId)`\n\nReturns the children of a cluster (on the next zoom level) given its id (`cluster_id` value from feature properties).\n\n#### `getLeaves(clusterId, limit = 10, offset = 0)`\n\nReturns all the points of a cluster (given its `cluster_id`), with pagination support:\n`limit` is the number of points to return (set to `Infinity` for all points),\nand `offset` is the amount of points to skip (for pagination).\n\n#### `getClusterExpansionZoom(clusterId)`\n\nReturns the zoom on which the cluster expands into several children (useful for \"click to zoom\" feature) given the cluster's `cluster_id`.\n\n## Options\n\n| Option     | Default | Description                                                       |\n|------------|---------|-------------------------------------------------------------------|\n| minZoom    | 0       | Minimum zoom level at which clusters are generated.               |\n| maxZoom    | 16      | Maximum zoom level at which clusters are generated. Capped at 30. |\n| minPoints  | 2       | Minimum number of points to form a cluster.                       |\n| radius     | 40      | Cluster radius, in pixels.                                        |\n| extent     | 512     | (Tiles) Tile extent. Radius is calculated relative to this value. |\n| nodeSize   | 64      | Size of the KD-tree leaf node. Affects performance.               |\n| log        | false   | Whether timing info should be logged.                             |\n| generateId | false   | Whether to generate ids for input features in vector tiles.       |\n\n### Property map/reduce options\n\nIn addition to the options above, Supercluster supports property aggregation with the following two options:\n\n- `map`: a function that returns cluster properties corresponding to a single point.\n- `reduce`: a reduce function that merges properties of two clusters into one.\n\nExample of setting up a `sum` cluster property that accumulates the sum of `myValue` property values:\n\n```js\nconst index = new Supercluster({\n    map: (props) => ({sum: props.myValue}),\n    reduce: (accumulated, props) => { accumulated.sum += props.sum; }\n});\n```\n\nThe `map`/`reduce` options must satisfy these conditions to work correctly:\n\n- `map` must return a new object, not existing `properties` of a point, otherwise it will get overwritten.\n- `reduce` must not mutate the second argument (`props`).\n\n## TypeScript\n\nType declarations ship with the library; remove `@types/supercluster` if you have it. The types those\ndeclarations exposed as namespace members are now named exports:\n\n```ts\nimport Supercluster from 'supercluster';\nimport type {Options, PointFeature, ClusterFeature, Tile, RawTile} from 'supercluster';\n```\n\n## Developing Supercluster\n\n```\nnpm install       # install dependencies\nnpm run build     # generate dist/supercluster.js and dist/supercluster.min.js\nnpm test          # run tests\n```\n","publish_time":1786355059950,"_cnpm_publish_time":1786355059950,"dist-tags":{"latest":"9.1.0"}}