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

tilelive

Package Overview
Dependencies
Maintainers
23
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tilelive - npm Package Compare versions

Comparing version 5.9.1 to 5.10.0

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## 5.10.0
* Add option for slow tile logging in `tilelive.copy()`
## 5.9.1

@@ -2,0 +6,0 @@

2

lib/stream-list.js

@@ -76,3 +76,3 @@ var Stats = require('./stream-util').Stats;

getTileRetry(stream.source, zxy.z, zxy.x, zxy.y, stream.retry, function(err, buffer) {
getTileRetry(stream.source, zxy.z, zxy.x, zxy.y, stream.retry, stream, function(err, buffer) {
if (err && !(/does not exist$/).test(err.message)) {

@@ -79,0 +79,0 @@ done(err);

@@ -61,3 +61,3 @@ var Stats = require('./stream-util').Stats;

stream.stats.ops++;
return putTileRetry(stream.source, obj.z, obj.x, obj.y, obj.buffer, stream.retry, function(err) {
return putTileRetry(stream.source, obj.z, obj.x, obj.y, obj.buffer, stream.retry, stream, function(err) {
if (err) return done(err);

@@ -64,0 +64,0 @@ stream.stats.done++;

@@ -110,3 +110,3 @@ var sm = new (require('sphericalmercator'))();

stream.stats.ops++;
getTileRetry(stream.source, z, x, y, stream.retry, done);
getTileRetry(stream.source, z, x, y, stream.retry, stream, done);
// Do not repeat buffers in a pyramid fashion for now as

@@ -129,3 +129,3 @@ // there are possible false positives in upstream solid

stream.stats.ops++;
getTileRetry(stream.source, z, x, y, stream.retry, done);
getTileRetry(stream.source, z, x, y, stream.retry, stream, done);
return true;

@@ -132,0 +132,0 @@ } else {

@@ -99,3 +99,3 @@ var sm = new (require('sphericalmercator'))();

getTileRetry(stream.source, z, x, y, stream.retry, function(err, buffer) {
getTileRetry(stream.source, z, x, y, stream.retry, stream, function(err, buffer) {
if (err && !(/does not exist$/).test(err.message)) {

@@ -102,0 +102,0 @@ stream.emit('error', err);

@@ -22,2 +22,3 @@ var concurrency = Math.ceil(require('os').cpus().length * 16);

module.exports.retryBackoff = 1000;
module.exports.slowTime = 10e3;

@@ -219,2 +220,3 @@ function DeserializationError(msg) {

/**

@@ -240,5 +242,17 @@ * Limit a bounding box to the [-180, -90, 180, 90] limits

function getTileRetry(source, z, x, y, tries, callback) {
tries = typeof tries === 'number' ? { max:tries, num:0 } : tries;
function getTileRetry(source, z, x, y, tries, stream, callback) {
tries = typeof tries === 'number' ? {
max: tries,
num: 0,
startTime: new Date(),
logged: false
} : tries;
source.getTile(z, x, y, function(err /*, tile, headers */) {
// Get time taken and emit slow event if over the slowTime threshold.
var time = new Date() - tries.startTime;
if (!tries.logged && module.exports.slowTime && time > module.exports.slowTime) {
tries.logged = true;
stream.emit('slow', 'get', z, x, y, time);
}
if (err && err.message === 'Tile does not exist') {

@@ -248,3 +262,3 @@ callback.apply(this, arguments);

setTimeout(function() {
getTileRetry(source, z, x, y, tries, callback);
getTileRetry(source, z, x, y, tries, stream, callback);
}, Math.pow(2, tries.num) * module.exports.retryBackoff);

@@ -257,8 +271,20 @@ } else {

function putTileRetry(source, z, x, y, data, tries, callback) {
tries = typeof tries === 'number' ? { max:tries, num:0 } : tries;
function putTileRetry(source, z, x, y, data, tries, stream, callback) {
tries = typeof tries === 'number' ? {
max: tries,
num: 0,
startTime: new Date(),
logged: false
} : tries;
source.putTile(z, x, y, data, function(err) {
// Get time taken and emit slow event if over the slowTime threshold.
var time = new Date() - tries.startTime;
if (!tries.logged && module.exports.slowTime && time > module.exports.slowTime) {
tries.logged = true;
stream.emit('slow', 'put', z, x, y, time);
}
if (err && tries.num++ < tries.max) {
setTimeout(function() {
putTileRetry(source, z, x, y, data, tries, callback);
putTileRetry(source, z, x, y, data, tries, stream, callback);
}, Math.pow(2, tries.num) * module.exports.retryBackoff);

@@ -265,0 +291,0 @@ } else {

@@ -313,2 +313,3 @@ var tilelive = exports;

}
if (!dst && !options.outStream) {

@@ -319,2 +320,5 @@ return callback(new Error('You must provide either a dsturi or an output stream'));

// set up slow tile logging threshold
if (options.slow) tilelive.stream.slowTime = options.slow;
// if (options.transform && (!options.transform._write || !options.transform._read)) {

@@ -397,2 +401,7 @@ if (options.transform && !(options.transform instanceof stream.Transform)) {

if (options.onslow) {
get.on('slow', options.onslow);
put.on('slow', options.onslow);
}
if (options.progress)

@@ -399,0 +408,0 @@ prog.on('progress', function(p) { options.progress(get.stats, p); });

{
"name": "tilelive",
"version": "5.9.1",
"version": "5.10.0",
"main": "./lib/tilelive.js",

@@ -5,0 +5,0 @@ "description": "API for various map tile backends",

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