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

grille

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grille - npm Package Compare versions

Comparing version 0.6.1 to 0.6.2

150

lib/worksheet.js

@@ -82,10 +82,14 @@ 'use strict';

case 'array':
try {
row[column] = JSON.parse(row[column]);
} catch(e) {
throw new ValidationError("Unable to parse JSON: " + row[column]);
}
if (row[column]) {
try {
row[column] = JSON.parse(row[column]);
} catch(e) {
throw new ValidationError("Unable to parse JSON: " + row[column]);
}
if (!Array.isArray(row[column])) {
throw new ValidationError("Data is not of type array: " + column);
if (!Array.isArray(row[column])) {
throw new ValidationError("Data is not of type array: " + column);
}
} else {
row[column] = [];
}

@@ -96,82 +100,102 @@

case 'array.integer':
try {
row[column] = JSON.parse(row[column]);
} catch(e) {
throw new ValidationError("Unable to parse JSON: " + row[column]);
}
if (row[column]) {
try {
row[column] = JSON.parse(row[column]);
} catch(e) {
throw new ValidationError("Unable to parse JSON: " + row[column]);
}
if (!Array.isArray(row[column])) {
throw new ValidationError("Data is not of type array: " + column);
if (!Array.isArray(row[column])) {
throw new ValidationError("Data is not of type array: " + column);
}
row[column].forEach(function(value) {
if (typeof value !== 'number' || value % 1 !== 0) {
throw new ValidationError("Not an array of integers");
}
});
} else {
row[column] = [];
}
row[column].forEach(function(value) {
if (typeof value !== 'number' || value % 1 !== 0) {
throw new ValidationError("Not an array of integers");
}
});
break;
case 'array.string':
try {
row[column] = JSON.parse(row[column]);
} catch(e) {
throw new ValidationError("Unable to parse JSON: " + row[column]);
}
if (row[column]) {
try {
row[column] = JSON.parse(row[column]);
} catch(e) {
throw new ValidationError("Unable to parse JSON: " + row[column]);
}
if (!Array.isArray(row[column])) {
throw new ValidationError("Data is not of type array: " + column);
if (!Array.isArray(row[column])) {
throw new ValidationError("Data is not of type array: " + column);
}
row[column].forEach(function(value) {
if (typeof value !== 'string') {
throw new ValidationError("Not an array of strings");
}
});
} else {
row[column] = [];
}
row[column].forEach(function(value) {
if (typeof value !== 'string') {
throw new ValidationError("Not an array of strings");
}
});
break;
case 'array.boolean':
try {
row[column] = JSON.parse(row[column]);
} catch(e) {
throw new ValidationError("Unable to parse JSON: " + row[column]);
}
if (row[column]) {
try {
row[column] = JSON.parse(row[column]);
} catch(e) {
throw new ValidationError("Unable to parse JSON: " + row[column]);
}
if (!Array.isArray(row[column])) {
throw new ValidationError("Data is not of type array: " + column);
if (!Array.isArray(row[column])) {
throw new ValidationError("Data is not of type array: " + column);
}
row[column].forEach(function(value) {
if (typeof value !== 'boolean') {
throw new ValidationError("Not an array of booleans");
}
});
} else {
row[column] = [];
}
row[column].forEach(function(value) {
if (typeof value !== 'boolean') {
throw new ValidationError("Not an array of booleans");
}
});
break;
case 'array.float':
try {
row[column] = JSON.parse(row[column]);
} catch(e) {
throw new ValidationError("Unable to parse JSON: " + row[column]);
}
if (row[column]) {
try {
row[column] = JSON.parse(row[column]);
} catch(e) {
throw new ValidationError("Unable to parse JSON: " + row[column]);
}
if (!Array.isArray(row[column])) {
throw new ValidationError("Data is not of type array: " + column);
if (!Array.isArray(row[column])) {
throw new ValidationError("Data is not of type array: " + column);
}
row[column].forEach(function(value) {
if (typeof value !== 'number') {
throw new ValidationError("Not an array of floats");
}
});
} else {
row[column] = [];
}
row[column].forEach(function(value) {
if (typeof value !== 'number') {
throw new ValidationError("Not an array of floats");
}
});
break;
case 'json':
try {
row[column] = JSON.parse(row[column]);
} catch(e) {
throw new ValidationError("Unable to parse JSON: " + row[column]);
if (row[column]) {
try {
row[column] = JSON.parse(row[column]);
} catch(e) {
throw new ValidationError("Unable to parse JSON: " + row[column]);
}
} else {
row[column] = {};
}

@@ -178,0 +202,0 @@

{
"name": "grille",
"version": "0.6.1",
"version": "0.6.2",
"description": "Simple CMS using Google Spreadsheets",

@@ -5,0 +5,0 @@ "main": "lib/grille.js",

@@ -358,2 +358,52 @@ 'use strict';

it("converts empty cells of type arrays to empty arrays", function() {
var descriptors = {
items: 'array',
integers: 'array.integer',
strings: 'array.string',
flags: 'array.boolean',
floats: 'array.float'
};
var row = {
items: '',
integers: '',
strings: '',
flags: '',
floats: ''
};
var result = Worksheet.convertKeys(descriptors, row);
assert(Array.isArray(result.items));
assert.strictEqual(result.items.length, 0);
assert(Array.isArray(result.integers));
assert.strictEqual(result.integers.length, 0);
assert(Array.isArray(result.strings));
assert.strictEqual(result.strings.length, 0);
assert(Array.isArray(result.flags));
assert.strictEqual(result.flags.length, 0);
assert(Array.isArray(result.floats));
assert.strictEqual(result.floats.length, 0);
});
it("converts empty cells of type json to empty objects", function() {
var descriptors = {
blob: 'json'
};
var row = {
blob: ''
};
var result = Worksheet.convertKeys(descriptors, row);
assert.equal(typeof result.blob, 'object');
assert.deepEqual(result.blob, {});
});
describe("integration tests", function() {

@@ -360,0 +410,0 @@ this.timeout(10 * 1000);

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