New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@4bitlabs/quadtree

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@4bitlabs/quadtree - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

dist/q-tree-no-cache.d.ts

5

dist/q-tree.d.ts

@@ -1,2 +0,1 @@

import { BoundsCache } from './bounds-cache';
import { Bounds } from './bounds';

@@ -12,3 +11,3 @@ export interface qTreeOptions {

private readonly items;
private readonly boundsCache;
private readonly boundsFn;
private readonly quadCache;

@@ -18,3 +17,3 @@ private readonly childAreas;

private isSplit;
constructor([x0, y0, x1, y1]: Readonly<Bounds>, options: qTreeOptions, boundsCache: BoundsCache<T>, quadCache: WeakMap<T, qTree<T>>, depth?: number);
constructor([x0, y0, x1, y1]: Readonly<Bounds>, options: qTreeOptions, boundFn: (item: T) => Bounds, quadCache: WeakMap<T, qTree<T>>, depth?: number);
clear(): void;

@@ -21,0 +20,0 @@ insert(item: Readonly<T>): void;

13

dist/q-tree.js

@@ -6,7 +6,7 @@ "use strict";

class qTree {
constructor([x0, y0, x1, y1], options, boundsCache, quadCache, depth = 0) {
constructor([x0, y0, x1, y1], options, boundFn, quadCache, depth = 0) {
const { maxDepth = 7, maxChildren = 10 } = options;
this.maxDepth = maxDepth;
this.maxChildren = maxChildren;
this.boundsCache = boundsCache;
this.boundsFn = boundFn;
this.quadCache = quadCache;

@@ -53,7 +53,7 @@ this.depth = depth;

const childRect = this.childAreas[i];
const rect = this.boundsCache.get(item);
const rect = this.boundsFn(item);
if ((0, bounds_1.contains)(childRect, rect)) {
let child = this.children[i];
if (!child) {
this.children[i] = child = new qTree(childRect, { maxDepth: this.maxDepth }, this.boundsCache, this.quadCache, this.depth + 1);
this.children[i] = child = new qTree(childRect, { maxDepth: this.maxDepth }, this.boundsFn, this.quadCache, this.depth + 1);
}

@@ -70,3 +70,2 @@ child.insert(item);

this.quadCache.delete(item);
this.boundsCache.delete(item);
// TODO handle cleanup

@@ -93,3 +92,3 @@ return true;

for (const item of this.items) {
const rect = this.boundsCache.get(item);
const rect = this.boundsFn(item);
if ((0, bounds_1.overlaps)(area, rect))

@@ -121,3 +120,3 @@ result.push(item);

for (const item of this.items) {
const rect = this.boundsCache.get(item);
const rect = this.boundsFn(item);
if ((0, bounds_1.overlaps)(area, rect))

@@ -124,0 +123,0 @@ yield item;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.quadtree = quadtree;
const bounds_cache_1 = require("./bounds-cache");
const q_tree_1 = require("./q-tree");
function quadtree(area, boundsFn, options = {}) {
const boundsCache = new bounds_cache_1.BoundsCache(boundsFn);
const quadCache = new WeakMap();
return new q_tree_1.qTree(area, options, boundsCache, quadCache);
return new q_tree_1.qTree(area, options, boundsFn, quadCache);
}
//# sourceMappingURL=quadtree.js.map
{
"name": "@4bitlabs/quadtree",
"version": "1.0.2",
"version": "1.0.3",
"description": "A basic 2D quadtree (2×2 spatial division) for fast, efficient spatial queries",

@@ -25,3 +25,3 @@ "main": "./dist/index.js",

],
"gitHead": "5fdb0f62ef5c23c803e05e1a0c7d5c4be454c158"
"gitHead": "5905f9410eff2aa2dad3d5ac16143b6b4acf958f"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc