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

multi-bin-packer

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multi-bin-packer - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

test/efficiency.spec.js

2

lib/binary_tree_bin.js

@@ -13,3 +13,3 @@ "use strict";

add(width, height, data) {
let node = this.findNode(this.rootNode, width, height)
let node = this.findNode(this.rootNode, width + this.padding, height + this.padding)
if (node) {

@@ -16,0 +16,0 @@ node.children = this.createChildren(node, width + this.padding, height + this.padding);

{
"name": "multi-bin-packer",
"version": "1.1.1",
"version": "1.1.2",
"description": "A 2d bin packer for the special purpose of creating spritesheets for CSS and games",

@@ -20,2 +20,3 @@ "main": "lib/multi_bin_packer.js",

"devDependencies": {
"ascii-table": "0.0.9",
"chai": "^3.5.0",

@@ -22,0 +23,0 @@ "eslint": "^2.9.0",

@@ -110,3 +110,42 @@ "use strict";

});
it("monkey testing", () => {
bin = new BinaryTreeBin(1024, 1024, 40);
let rects = [];
while (true) {
let width = Math.floor(Math.random() * 200);
let height = Math.floor(Math.random() * 200);
let position = bin.add(width, height);
if (position) {
expect(position.width).to.equal(width);
expect(position.height).to.equal(height);
rects.push(position);
} else {
break;
}
}
expect(bin.width).to.not.be.above(1024);
expect(bin.height).to.not.be.above(1024);
rects.forEach(rect1 => {
// Make sure rects are not overlapping
rects.forEach(rect2 => {
if (rect1 !== rect2) {
let intersect =
(rect1.x < rect2.x + rect2.width &&
rect2.x < rect1.x + rect1.width &&
rect1.y < rect2.y + rect2.height &&
rect2.y < rect1.y + rect1.height);
expect(intersect).to.equal(false, "intersection detected: " + JSON.stringify(rect1) + " " + JSON.stringify(rect2));
}
});
// Make sure no rect is outside bounds
expect(rect1.x + rect1.width).to.not.be.above(bin.width);
expect(rect1.y + rect1.height).to.not.be.above(bin.height);
});
});
});
});
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