Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

layout

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

layout - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

lib/algorithms/binary-tree.algorithm.js

3

lib/layout.js

@@ -10,3 +10,3 @@ // Load in packing.smith (from spritesmith) and create algorithm store

* @param {String|Function} [algorithm="top-down"] Name of algorithm or custom algorithm to use
* Algorithms available: top-down, left-right, diagonal, alt-diagonal
* Algorithms available: top-down, left-right, diagonal, alt-diagonal, binary-tree
*/

@@ -51,2 +51,3 @@ function Layout(algorithmName) {

addAlgorithm('alt-diagonal', require('./algorithms/alt-diagonal.algorithm.js'));
addAlgorithm('binary-tree', require('./algorithms/binary-tree.algorithm.js'));

@@ -53,0 +54,0 @@ // /**

{
"name": "layout",
"description": "Organize and layout items based on various algorithms",
"version": "1.2.1",
"version": "1.3.0",
"homepage": "https://github.com/twolfson/layout",

@@ -40,3 +40,6 @@ "author": {

"algorithm"
]
}
],
"dependencies": {
"binpacking": "0.0.1"
}
}

@@ -56,3 +56,3 @@ # layout

* @param {String|Function} [algorithm="top-down"] Name of algorithm or custom algorithm to use
* Algorithms available: top-down, left-right, diagonal, alt-diagonal
* Algorithms available: top-down, left-right, diagonal, alt-diagonal, binary-tree
*/

@@ -59,0 +59,0 @@ ```

@@ -24,6 +24,2 @@ var layout = require('../lib/layout.js');

exports['layout'] = {
setUp: function(done) {
// setup here
done();
},
'addItem': function (test) {

@@ -130,23 +126,26 @@ test.expect(4);

test.done();
// },
// 'bottom-up': function (test) {
// test.expect(6);
},
'binary-tree': function (test) {
test.expect(9);
// // A bottom-up layout
// var layer = layout('bottom-up');
// // with multiple items
// layer.addItem({'height': 20, 'width': 10, 'meta': 'medium'}); // 20 x 10
// layer.addItem({'height': 10, 'width': 10, 'meta': 'small'}); // 30 x 10
// layer.addItem({'height': 50, 'width': 40, 'meta': 'large'}); // 80 x 40
// // organizes them in a top-down manner
// var result = layer['export']();
// test.equal(result.height, 80, 'Result has a height of 80');
// test.equal(result.width, 40, 'Result has a width of 40');
// test.equal(result.items.length, 3, 'Result has 3 items');
// test.equal(result.items[1].x, 0, 'Second item is 0 pixels from the left');
// test.equal(result.items[1].y, 50, 'Second item is 50 pixels from the top');
// test.equal(result.items[2].y, 70, 'Third item is 70 pixels from the top');
// A alt-diagonal layout
var layer = layout('binary-tree');
// with multiple items
layer.addItem({'height': 20, 'width': 10, 'meta': 'medium'});
layer.addItem({'height': 10, 'width': 10, 'meta': 'small'});
layer.addItem({'height': 50, 'width': 40, 'meta': 'large'});
// organizes them in a a well packed manner
var result = layer['export']();
test.equal(result.height, 50, 'Result has a height of 80');
test.equal(result.width, 50, 'Result has a width of 60');
test.equal(result.items.length, 3, 'Result has 3 items');
test.equal(typeof result.items[0].y, 'number');
test.equal(typeof result.items[0].x, 'number');
test.equal(typeof result.items[1].y, 'number');
test.equal(typeof result.items[1].x, 'number');
test.equal(typeof result.items[2].y, 'number');
test.equal(typeof result.items[2].x, 'number');
// test.done();
test.done();
}
};
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