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

tilelive

Package Overview
Dependencies
Maintainers
22
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.3.3 to 5.4.0

5

CHANGELOG.md

@@ -0,1 +1,6 @@

## 5.4.0
* Expose copy function as an API
* Fix handling of paths with spaces
## 5.3.3

@@ -2,0 +7,0 @@

94

lib/tilelive.js
var tilelive = exports;
var fs = require('fs');
var path = require('path');
var url = require('url');
var qs = require('querystring');
var util = require('util');

@@ -8,2 +10,4 @@ var os = require('os');

var stream = require('stream');
var progress = require('progress-stream');
var queue = require("queue-async");

@@ -78,3 +82,6 @@ global.tileliveProtocols = global.tileliveProtocols || {};

if (typeof uri === 'string') uri = url.parse(uri, true);
if (typeof uri === 'string') {
uri = url.parse(uri, true);
uri.pathname = qs.unescape(uri.pathname);
}

@@ -99,2 +106,3 @@ // Handle uris in the format /path/to/dir?id=bar

uri = url.parse(uri);
uri.pathname = qs.unescape(uri.pathname);

@@ -299,2 +307,86 @@ // Attempt to load any modules that may match keyword pattern.

tilelive.copy = function(src, dst, options, callback) {
callback = callback || function() {};
if (options.type === 'list' && !options.listStream) {
return callback(new Error('You must provide a listStream'));
}
if (!dst && !options.outStream) {
return callback(new Error('You must provide either a dsturi or an output stream'));
}
if (options.concurrency) tilelive.stream.setConcurrency(options.concurrency);
var prog = progress({
objectMode: true,
time: 100
});
// Load source and destination if URIs are strings
var q = queue();
if (typeof src === 'string') q.defer(function(next) {
var uri = tilelive.auto(src);
tilelive.load(uri, function(err, loaded) {
if (err) return next(err);
src = loaded;
next();
});
});
if (typeof dst === 'string') q.defer(function(next) {
var uri = tilelive.auto(dst);
tilelive.load(uri, function(err, loaded) {
if (err) return next(err);
dst = loaded;
next();
});
});
q.await(function(err) {
if (err) return callback(err);
copy(src, dst, options, callback);
});
function copy(src, dst, opts, callback) {
// copy to outStream, if present. This is done after the src is loaded
if (!dst && opts.outStream) return out(opts, callback);
// Copy
var get = tilelive.createReadStream(src, opts);
var put = tilelive.createWriteStream(dst);
get.on('error', callback);
put.on('error', callback);
get.on('length', prog.setLength);
if (options.progress) prog.on('progress', function(p) { options.progress(get.stats, p); });
if (opts.type === 'list') {
var file = opts.listStream;
file.pipe(get).pipe(prog).pipe(put);
} else {
get.pipe(prog).pipe(put);
}
put.on('stop', callback);
}
function out(options, callback) {
var get = tilelive.createReadStream(src, options);
var put = options.outStream;
get.on('error', callback);
put.on('error', callback);
put.on('finish', callback);
get.on('length', prog.setLength);
if (options.progress) prog.on('progress', function(p) { options.progress(get.stats, p); });
if (options.type === 'list') {
var file = options.listStream;
file.pipe(get).pipe(tilelive.serialize()).pipe(prog).pipe(put);
} else {
get.pipe(tilelive.serialize()).pipe(prog).pipe(put);
}
}
};
// tilelive implementation of node readable/writable stream.

@@ -301,0 +393,0 @@ tilelive.createReadStream = function(source, options) {

8

package.json
{
"name": "tilelive",
"version": "5.3.3",
"version": "5.4.0",
"main": "./lib/tilelive.js",

@@ -36,3 +36,4 @@ "description": "API for various map tile backends",

"progress-stream": "~0.5.x",
"sphericalmercator": "~1.0.1"
"sphericalmercator": "~1.0.1",
"queue-async": "~1.0.7"
},

@@ -45,3 +46,4 @@ "devDependencies": {

"tilejson": "~0.8.0",
"tilelive-http": "^0.3.0"
"tilelive-http": "^0.3.0",
"concat-stream": "1.4.x"
},

@@ -48,0 +50,0 @@ "bin": {

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