Socket
Socket
Sign inDemoInstall

google-books-search-2

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-books-search-2 - npm Package Compare versions

Comparing version 0.1.8 to 0.2.0

67

lib/google-books-search.js

@@ -48,3 +48,3 @@ /**

*/
var search = function(query, options) {
var search = function (query, options) {

@@ -57,3 +57,3 @@ // Validate options

if ( options.offset < 0) {
if (options.offset < 0) {
reject(new Error("Offset cannot be below 0"));

@@ -63,3 +63,3 @@ return;

if ( options.limit < 1 || options.limit > 40 ) {
if (options.limit < 1 || options.limit > 40) {
reject(new Error("Limit must be between 1 and 40"));

@@ -92,15 +92,15 @@ return;

return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
// Send Request
https.get(uri, function(response){
https.get(uri, function (response) {
if ( response.statusCode && response.statusCode === 200 ) {
if (response.statusCode && response.statusCode === 200) {
var body = '';
response.on('data', function(data) {
response.on('data', function (data) {
body += data;
});
response.on('end', function() {
response.on('end', function () {

@@ -114,5 +114,5 @@ // Parse response body

// Extract useful data
if ( data.items ) {
if (data.items) {
for(var i = 0; i < data.items.length; i++) {
for (var i = 0; i < data.items.length; i++) {

@@ -122,29 +122,26 @@ var book = data.items[i].volumeInfo;

// ID
if (data.items[i].id) push.id = data.items[i].id;
// Title
if (book.title) push.title = book.title;
// Authors
if (book.authors) push.authors = book.authors;
// Description
if (book.description) push.description = book.description;
// Publisher
if (book.publisher) push.publisher = book.publisher;
// Date Published
if (book.publishedDate) push.publishedDate = book.publishedDate;
// Page Count
if (book.pageCount) push.pageCount = book.pageCount;
// Publication Type
if (book.printType) push.printType = book.printType;
// Categories
if (book.categories) push.categories = book.categories;
push = _.pick(book, [
'title',
'authors',
'publisher',
'publishedDate',
'pageCount',
'printType',
'categories',
'language',
'infoLink',
'description',
'averageRating',
'ratingsCount',
'previewLink'
]);
// Thumbnail
if (book.imageLinks && book.imageLinks.thumbnail) push.thumbnail = book.imageLinks.thumbnail;
// Language
if (book.language) push.language = book.language;
// Link
if (book.infoLink) push.link = book.infoLink;
if (book.imageLinks && book.imageLinks.thumbnail) {
push.thumbnail = book.imageLinks.thumbnail;
}
// ISBN
if (book.industryIdentifiers && book.industryIdentifiers.length > 0) {
var isbn13 = _.find(book.industryIdentifiers, function(item) {
var isbn13 = _.find(book.industryIdentifiers, function (item) {
return item.type == "ISBN_13";

@@ -173,3 +170,3 @@ }, 'identifier');

}).on('error', function(error) {
}).on('error', function (error) {
return reject(error);

@@ -176,0 +173,0 @@ });

{
"name": "google-books-search-2",
"version": "0.1.8",
"version": "0.2.0",
"description": "A node wrapper for the Google Books API. Based on the original project google-books-search.",

@@ -5,0 +5,0 @@ "main": "./lib/google-books-search.js",

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