Socket
Socket
Sign inDemoInstall

edit-google-spreadsheet

Package Overview
Dependencies
4
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.2 to 0.1.3

87

lib/index.js

@@ -9,3 +9,2 @@

var auth = require("./auth");
var xml = require("./xml");
var util = require("./util");

@@ -83,21 +82,26 @@

method: 'GET',
url: 'https://spreadsheets.google.com/feeds/'+type+'sheets'+spreadsheetUrlId+'/private/full',
url: 'https://spreadsheets.google.com/feeds/'+type+'sheets'+spreadsheetUrlId+'/private/full?alt=json',
headers: this.authHeaders
}, function(err, response, body) {
if(err) return callback(err, null);
xml.parseEntries(body, function(err, entries) {
var entry = _.find(entries, function(entry) {
return entry.title === name;
});
var m = null;
if(entry)
m = entry.id.match(/[^\/]+$/);
if(!m)
return callback(type+" '"+name+"' not found");
_this[id] = m[0];
var result = JSON.parse(body);
var entries = result.feed.entry || [];
_this.log(("Tip: Use option '"+type+"sheetId: \"" + _this[id] + "\"' for improved performance").yellow);
callback(null);
var entry = _.find(entries, function(entry) {
return entry.title.$t === name;
});
var m = null;
if(entry)
m = entry.id.$t.match(/[^\/]+$/);
if(!m)
return callback(type+" '"+name+"' not found");
_this[id] = m[0];
_this.log(("Tip: Use option '"+type+"sheetId: \"" + _this[id] + "\"' for improved performance").yellow);
callback(null);
});

@@ -321,3 +325,3 @@ };

method: 'GET',
url: this.baseUrl(),
url: this.baseUrl()+'?alt=json',
headers: this.authHeaders

@@ -328,3 +332,5 @@ }, function(err, response, body) {

if(body.indexOf("success='0'") >= 0) {
var result = JSON.parse(body);
if(!result.feed) {
err = "Error Reading Spreadsheet";

@@ -335,39 +341,32 @@ _this.log(err.red.underline + ("\nResponse:\n" + body));

}
var entries = result.feed.entry || [];
var rows = {};
var info = {
totalRows: 0,
totalCells: entries.length
};
var maxRow = 0;
_this.log("Parsing Rows from Spreadsheet...".green);
_this.log(("Found " + entries.length + " cells").green);
xml.parseEntries(body, function(err, entries) {
_.each(entries, function(entry) {
if(err) return callback(err, null);
var cell = entry.gs$cell,
r = cell.row, c = cell.col;
var rows = {};
var info = {
totalRows: 0,
totalCells: entries.length
};
var maxRow = 0;
if(!rows[r])
info.totalRows++, rows[r] = {};
rows[r][c] = util.gcell2cell(cell);
info.lastRow = util.num(r);
});
// no rows - return empty
if(!entries)
return callback(null, rows);
info.nextRow = info.lastRow+1;
_.each(entries, function(entry) {
_this.log(("Retrieved "+info.totalRows+" Rows").green);
var cell = entry['gs:cell']['@'],
r = cell.row, c = cell.col;
callback(null,rows,info);
if(!rows[r])
info.totalRows++, rows[r] = {};
rows[r][c] = util.gcell2cell(cell);
info.lastRow = util.num(r);
});
info.nextRow = info.lastRow+1;
_this.log(("Retrieved "+info.totalRows+" Rows").green);
callback(null,rows,info);
});
});

@@ -374,0 +373,0 @@

//parse number

@@ -20,3 +18,2 @@ exports.num = function(obj) {

//convert '=RC[-2]+R[3]C[-1]' (on r:5 c:4) to '=B5+C8'

@@ -36,3 +33,2 @@ exports.gcell2cell = function(cell) {

});
};
{
"name": "edit-google-spreadsheet",
"version": "0.1.2",
"version": "0.1.3",
"dependencies": {

@@ -8,5 +8,4 @@ "colors": "~0.6.0-1",

"lodash": "~1.2.1",
"request": "~2.21.0",
"xml2js": "~0.2.7"
"request": "~2.21.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc