{"name":"kdbush","version":"2.0.1","description":"A very fast static 2D index for points based on kd-tree.","module":"src/index.js","main":"kdbush.js","jsdelivr":"dist/kdbush.min.js","unpkg":"dist/kdbush.min.js","repository":{"type":"git","url":"git://github.com/mourner/kdbush.git"},"devDependencies":{"eslint":"^4.19.1","eslint-config-mourner":"^2.0.1","esm":"^3.0.48","rollup":"^0.60.0","rollup-plugin-uglify":"^4.0.0","tape":"^4.6.2"},"scripts":{"pretest":"eslint test.js src","test":"tape -r esm test.js","bench":"node -r esm bench.js","build":"rollup -c"},"eslintConfig":{"extends":"mourner","parserOptions":{"sourceType":"module"}},"keywords":["index","points","kd-tree","data structures","algorithms","spatial","geometry"],"files":["kdbush.js","kdbush.min.js","src"],"author":{"name":"Vladimir Agafonkin"},"license":"ISC","gitHead":"1e4879151c30c32f84a5c797a59480bbf719cb4d","bugs":{"url":"https://github.com/mourner/kdbush/issues"},"homepage":"https://github.com/mourner/kdbush#readme","_id":"kdbush@2.0.1","_npmVersion":"6.1.0","_nodeVersion":"8.11.2","_npmUser":{"name":"mourner","email":"agafonkin@gmail.com"},"dist":{"integrity":"sha512-9KqSdmWCkBIisFIGclT0FRagKhI7IVbMyUjsxCFG0Ly1Dg6whlxJ7b9lrq8ifk3X/fGeJzok1R75LQfZTfA5zQ==","shasum":"90c6128e3001ac68c550d7c9e2f222c0269666f1","tarball":"http://registry-npm.ywwl.com/kdbush/download/kdbush-2.0.1.tgz","fileCount":9,"unpackedSize":16867,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbGVu/CRA9TVsSAnZWagAA168P/j6cI6gPjaEb624UuwRn\nHUExemFA2kopzTX0D/1qEQgxzg1oIW1ztc4bd45ubuYcLl5N5mcIQlhUd1QG\nO3G385AR53MFs8Nk5x+CB7Nb6BU93//IBw+nyJ9ZdcZAmVdbR8cU3KjZaErc\n8AzkyVpCuB1RuFA2rbn3K+4S0uA8OIvuJCAytWcM3KvZOAJISs7OIdUA5tQq\nz5HvwTXkz4+5QJsDZ3gDjcT+QtEaz2iDImhbsjtncIrftKUJGYXNS3I0dFfu\nU3IpG0e4T+KA8wExgi41Phe/cWspQn5pkm6uaztIEDk6KWj8ZTZf4uMvWlAR\nd6B4w4fGp5MZQUdpl/GMtsckcESh/V9HoYX9pXA4tCPJf18jSCVlkY3zNzdV\nt6ltXKyGM2ycfIwfjOmQjjHC0oOS65Zt6OKzw5DbaobuyU1ftoZtK3c4pPXE\nUqEzqm2eC3LCq6albahq4hDSaLhpTVUxxwNRRUKK/iPZTRCAgjwnvzuh9QmY\nRETBemVGXmUJPUC0OioNQXp+MsOyphZlKkJksscc0mixSA6aSQ3E5eh2Oe7U\nOYv6HCFPRrWmWvhFMuOvAcCjqGdCNWnrZU2L7O624mg1KbDabM7SuFU4CkOA\nHtVUDCxe2jckqo3NNhFZPiIv84x4jY8mag1vr39Xu5xTSUv+6d2pBlTzwVj+\n1Vqj\r\n=z9xV\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFa8w790hX++JgHip6kooDu8p0UpFC+/mI5UcGXN4HRQAiEA5D2YFjZ0sUJHJoWkmZNrl9g/7N9mILyHNz2WaGmfZGs="}],"size":4642,"noattachment":false,"key":"/kdbush/-/kdbush-2.0.1.tgz"},"maintainers":[{"name":"mourner","email":"agafonkin@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/kdbush_2.0.1_1528388542446_0.4293094961336368"},"_hasShrinkwrap":false,"readme":"## KDBush\n\nA very fast static spatial index for 2D points based on a flat KD-tree.\nCompared to [RBush](https://github.com/mourner/rbush):\n\n- **Points only** — no rectangles.\n- **Static** — you can't add/remove items after initial indexing.\n- **Faster** indexing and search, with lower **memory** footprint.\n- Index is stored as a single **array buffer** (so you can [transfer](https://developer.mozilla.org/en-US/docs/Glossary/Transferable_objects) it between threads or store it as a compact file).\n\n\nIf you need a static index for rectangles, not only points, see [Flatbush](https://github.com/mourner/flatbush). When indexing points, KDBush has the advantage of taking ~2x less memory than Flatbush.\n\n[![Build Status](https://github.com/mourner/kdbush/workflows/Node/badge.svg?branch=master)](https://github.com/mourner/kdbush/actions)\n[![Simply Awesome](https://img.shields.io/badge/simply-awesome-brightgreen.svg)](https://github.com/mourner/projects)\n\n## Usage\n\n```js\n// initialize KDBush for 1000 items\nconst index = new KDBush(1000);\n\n// fill it with 1000 points\nfor (const {x, y} of items) {\n    index.add(x, y);\n}\n\n// perform the indexing\nindex.finish();\n\n// make a bounding box query\nconst foundIds = index.range(minX, minY, maxX, maxY);\n\n// map ids to original items\nconst foundItems = foundIds.map(i => items[i]);\n\n// make a radius query\nconst neighborIds = index.within(x, y, 5);\n\n// instantly transfer the index from a worker to the main thread\npostMessage(index.data, [index.data]);\n\n// reconstruct the index from a raw array buffer\nconst index = KDBush.from(e.data);\n```\n\n## Install\n\nInstall with NPM: `npm install kdbush`, then import as a module:\n\n```js\nimport KDBush from 'kdbush';\n```\n\nOr use as a module directly in the browser with [jsDelivr](https://www.jsdelivr.com/esm):\n\n```html\n<script type=\"module\">\n    import KDBush from 'https://cdn.jsdelivr.net/npm/kdbush/+esm';\n</script>\n```\n\nAlternatively, there's a browser bundle with a `KDBush` global variable:\n\n```html\n<script src=\"https://cdn.jsdelivr.net/npm/kdbush\"></script>\n```\n\n## API\n\n#### new KDBush(numItems[, nodeSize, ArrayType])\n\nCreates an index that will hold a given number of points (`numItems`). Additionally accepts:\n\n- `nodeSize`: Size of the KD-tree node, `64` by default. Higher means faster indexing but slower search, and vise versa.\n- `ArrayType`: Array type to use for storing coordinate values. `Float64Array` by default, but if your coordinates are integer values, `Int32Array` makes the index faster and smaller.\n\n#### index.add(x, y)\n\nAdds a given point to the index. Returns a zero-based, incremental number that represents the newly added point.\n\n#### index.range(minX, minY, maxX, maxY)\n\nFinds all items within the given bounding box and returns an array of indices that refer to the order the items were added (the values returned by `index.add(x, y)`).\n\n#### index.within(x, y, radius)\n\nFinds all items within a given radius from the query point and returns an array of indices.\n\n#### `KDBush.from(data)`\n\nRecreates a KDBush index from raw `ArrayBuffer` data\n(that's exposed as `index.data` on a previously indexed KDBush instance).\nVery useful for transferring or sharing indices between threads or storing them in a file.\n\n### Properties\n\n- `data`: array buffer that holds the index.\n- `numItems`: number of stored items.\n- `nodeSize`: number of items in a KD-tree node.\n- `ArrayType`: array type used for internal coordinates storage.\n- `IndexArrayType`: array type used for internal item indices storage.\n","publish_time":1528388542538,"_cnpm_publish_time":1528388542538,"dist-tags":{"latest":"4.1.0"}}