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

furkot-driving-log

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

furkot-driving-log - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

5

History.md
2.0.1 / 2017-09-02
==================
* implement generator as a Readable stream
2.0.0 / 2017-07-18

@@ -3,0 +8,0 @@ ==================

50

lib/driving-log.js

@@ -0,1 +1,2 @@

var Readable = require('stream').Readable;
var format = require('./format');

@@ -12,8 +13,8 @@

function write(out, line) {
line = line.map(function(item) {
if(typeof item === 'number') {
function prepare(line) {
return line.map(function(item) {
if (typeof item === 'number') {
return '' + item;
}
if(typeof item === 'string') {
if (typeof item === 'string') {
// quote strings

@@ -24,4 +25,3 @@ return '"' + item.replace(/"/g, '""') + '"';

return '';
}).join(',');
out.write(line + '\n');
}).join(',') + '\n';
}

@@ -58,6 +58,12 @@

write(out, header);
var steps = options.routes[0].points;
options.routes[0].points.forEach(function (step, i, steps) {
var line = [], next = steps[i + 1], travel;
function getLine(i) {
if (i < 0) {
return prepare(header);
}
var step = steps[i];
var next = steps[i + 1];
if (!next) {

@@ -72,2 +78,3 @@ return;

var travel;
if (mode === next.mode || next.mode === undefined) {

@@ -79,5 +86,8 @@ travel = next;

}
totals.driving += travel.driving;
totals.distance += travel.distance;
var line = [];
line.push(step.name);

@@ -97,5 +107,23 @@ line.push(step.address);

write(out, line);
return prepare(line);
}
var maxLine = steps.length - 1;
var currentLine = -1;
var stream = new Readable({
read: function read() {
while (currentLine < maxLine) {
if (!this.push(getLine(currentLine++))) {
break;
}
}
if (currentLine >= maxLine) {
this.push(null);
}
}
});
out.end();
stream.pipe(out);
}
{
"name": "furkot-driving-log",
"version": "2.0.0",
"version": "2.0.1",
"description": "Generate CSV driving log from Furkot trip data.",

@@ -5,0 +5,0 @@ "homepage": "https://trips.furkot.com",

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