Comparing version 5.4.0 to 5.4.1
@@ -0,1 +1,5 @@ | ||
## 5.4.1 | ||
* Fix liststream by switching to Transform-based stream | ||
## 5.4.0 | ||
@@ -2,0 +6,0 @@ |
@@ -7,7 +7,9 @@ var sm = new (require('sphericalmercator'))(); | ||
var multiread = require('./stream-util').multiread; | ||
var setConcurrency = require('./stream-util').setConcurrency; | ||
var stream = require('stream'); | ||
var util = require('util'); | ||
var queue = require('queue-async'); | ||
module.exports = List; | ||
util.inherits(List, stream.Duplex); | ||
util.inherits(List, stream.Transform); | ||
@@ -31,8 +33,11 @@ function List(source, options) { | ||
stream.Duplex.call(this, { objectMode:true }); | ||
stream.Transform.call(this, {}); | ||
this._writableState.objectMode = false; | ||
this._readableState.objectMode = true; | ||
} | ||
List.prototype._write = function(obj, encoding, callback) { | ||
List.prototype._transform = function(obj, encoding, callback) { | ||
this.buffer += obj.toString('utf8'); | ||
var list = this; | ||
var stream = this; | ||
@@ -66,15 +71,10 @@ function pushTile(str) { | ||
this.emit('length', this.length); | ||
callback(); | ||
}; | ||
List.prototype._read = function(size) { | ||
var stream = this; | ||
if (!this.bufferzxy.length) return callback(); | ||
multiread(stream, function get(push) { | ||
if (!stream.bufferzxy.length && stream.done && !stream.pending) { | ||
return push(null) && false; | ||
} else if (!stream.bufferzxy.length) { | ||
return setTimeout(function() { get(push); }, 1) && false; | ||
} | ||
var zxy = stream.bufferzxy.shift(); | ||
var q = queue(setConcurrency()); | ||
while (this.bufferzxy.length) q.defer(toTile, this.bufferzxy.shift()); | ||
q.awaitAll(function(err) { callback(err); }); | ||
function toTile(zxy, done) { | ||
stream.stats.ops++; | ||
@@ -87,3 +87,3 @@ | ||
if (err && !(/does not exist$/).test(err.message)) { | ||
stream.emit('error', err); | ||
done(err); | ||
} else if (err || isEmpty(buffer)) { | ||
@@ -93,3 +93,4 @@ skip(); | ||
stream.stats.done++; | ||
push(new Tile(zxy.z, zxy.x, zxy.y, buffer)); | ||
stream.push(new Tile(zxy.z, zxy.x, zxy.y, buffer)); | ||
done(); | ||
} | ||
@@ -104,7 +105,6 @@ }); | ||
stream.emit('length', stream.length); | ||
get(push); | ||
done(); | ||
} | ||
} | ||
}; | ||
return true; | ||
}); | ||
}; |
@@ -208,3 +208,4 @@ var concurrency = Math.ceil(require('os').cpus().length * 16); | ||
function setConcurrency(c) { | ||
concurrency = c; | ||
if (c) concurrency = c; | ||
return concurrency; | ||
} |
{ | ||
"name": "tilelive", | ||
"version": "5.4.0", | ||
"version": "5.4.1", | ||
"main": "./lib/tilelive.js", | ||
@@ -5,0 +5,0 @@ "description": "API for various map tile backends", |
58701