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

turf-size

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-size - npm Package Compare versions

Comparing version 0.2.0 to 1.0.0

bench.js

24

index.js
module.exports = function(bbox, factor){
var currentXDistance = (bbox[2] - bbox[0])
var currentYDistance = (bbox[3] - bbox[1])
var newXDistance = currentXDistance * factor
var newYDistance = currentYDistance * factor
var xChange = newXDistance - currentXDistance
var yChange = newYDistance - currentYDistance
var currentXDistance = (bbox[2] - bbox[0]);
var currentYDistance = (bbox[3] - bbox[1]);
var newXDistance = currentXDistance * factor;
var newYDistance = currentYDistance * factor;
var xChange = newXDistance - currentXDistance;
var yChange = newYDistance - currentYDistance;
var lowX = bbox[0] - (xChange / 2)
var lowY = bbox[1] - (yChange / 2)
var highX = (xChange / 2) + bbox[2]
var highY = (yChange / 2) + bbox[3]
var lowX = bbox[0] - (xChange / 2);
var lowY = bbox[1] - (yChange / 2);
var highX = (xChange / 2) + bbox[2];
var highY = (yChange / 2) + bbox[3];
var sized = [lowX, lowY, highX, highY]
return sized
var sized = [lowX, lowY, highX, highY];
return sized;
}
{
"name": "turf-size",
"version": "0.2.0",
"version": "1.0.0",
"description": "turf size module",

@@ -27,4 +27,5 @@ "main": "index.js",

"devDependencies": {
"tape": "^2.12.3"
"benchmark": "^1.0.0",
"tape": "^2.13.4"
}
}

@@ -7,3 +7,24 @@ turf-size

###Install
```sh
npm install turf-size
```
###Parameters
|name|description|
|---|---|
|bbox|[xmin, ymin, xmay, ymax]|
|factor|the factor to increase or decrease size by|
###Usage
```js
size(bbox, factor)
```
###Example
```js
var bbox = [0, 0, 10, 10]

@@ -10,0 +31,0 @@

@@ -1,34 +0,34 @@

var test = require('tape')
var size = require('./')
var test = require('tape');
var size = require('./');
test('size', function(t){
var bbox = [0, 0, 10, 10]
var sized = size(bbox, 2)
t.deepEqual(sized, [-5, -5, 15, 15], 'should double the size of a bbox at 0,0,10,10')
var bbox = [0, 0, 10, 10];
var sized = size(bbox, 2);
t.deepEqual(sized, [-5, -5, 15, 15], 'should double the size of a bbox at 0,0,10,10');
var bbox = [0, 0, 4, 4]
var sized = size(bbox, 1)
t.deepEqual(sized, [0, 0, 4, 4], 'should do nothing to the size of a bbox at 0,0,4,4')
var bbox = [0, 0, 4, 4];
var sized = size(bbox, 1);
t.deepEqual(sized, [0, 0, 4, 4], 'should do nothing to the size of a bbox at 0,0,4,4');
var bbox = [0, 0, 4, 4]
var sized = size(bbox, 2)
t.deepEqual(sized, [-2, -2, 6, 6], 'should double the size of a bbox at 0,0,4,4')
var bbox = [0, 0, 4, 4];
var sized = size(bbox, 2);
t.deepEqual(sized, [-2, -2, 6, 6], 'should double the size of a bbox at 0,0,4,4');
var bbox = [0, 0, 4, 4]
var sized = size(bbox, 0.5)
t.deepEqual(sized, [1, 1, 3, 3], 'should shrink a bbox by 50% at 0,0,4,4')
var bbox = [0, 0, 4, 4];
var sized = size(bbox, 0.5);
t.deepEqual(sized, [1, 1, 3, 3], 'should shrink a bbox by 50% at 0,0,4,4');
var bbox = [-10, -10, 0, 0]
var sized = size(bbox, 2)
t.deepEqual(sized, [-15, -15, 5, 5], 'should double the size of a bbox at -10,-10')
var bbox = [-10, -10, 0, 0];
var sized = size(bbox, 2);
t.deepEqual(sized, [-15, -15, 5, 5], 'should double the size of a bbox at -10,-10');
var bbox = [0, 0, 10, 10]
var sized = size(bbox, 1.5)
t.deepEqual(sized, [-2.5, -2.5, 12.5, 12.5], 'should expand the size of a bbox by 50% at 0,0,10,10')
var bbox = [0, 0, 10, 10];
var sized = size(bbox, 1.5);
t.deepEqual(sized, [-2.5, -2.5, 12.5, 12.5], 'should expand the size of a bbox by 50% at 0,0,10,10');
var bbox = [0, 0, 10, 10]
var sized = size(bbox, 0.5)
t.deepEqual(sized, [2.5, 2.5, 7.5, 7.5], 'should shrink a bbox by 50%')
var bbox = [0, 0, 10, 10];
var sized = size(bbox, 0.5);
t.deepEqual(sized, [2.5, 2.5, 7.5, 7.5], 'should shrink a bbox by 50%');
t.end()
})
t.end();
});
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