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

discogs

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discogs - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

node_modules/.npm/.cache/compress/.cache.json

85

discogs.js
(function() {
var Discogs, compress, querystring, request;
var compress, exports, querystring, request;
var __indexOf = Array.prototype.indexOf || function(item) {

@@ -12,22 +12,21 @@ for (var i = 0, l = this.length; i < l; i++) {

compress = require('compress');
Discogs = (function() {
function Discogs(config) {
var _base, _ref;
this.config = config;
(_ref = (_base = this.config).f) != null ? _ref : _base.f = this.config.format || 'json';
this.params = querystring.stringify(config);
this.gunzip = new compress.Gunzip();
this.gunzip.init();
}
Discogs.prototype.getUrl = function(url) {
exports = module.exports = function(config) {
var discogsRequest, getUrl, gunzip, params, responseHandler, _config;
_config = {};
_config.api_key = config.api_key;
_config.f = config.f || 'json';
params = querystring.stringify(_config);
gunzip = new compress.Gunzip();
gunzip.init();
getUrl = function(url) {
var sep;
if (url.substr(0, 7) !== 'http://') {
url = "http://www.discogs.com/" + url;
url = "http://www.discogs.com/" + (encodeURIComponent(url));
}
sep = __indexOf.call(url, "?") >= 0 ? "&" : "?";
return "" + url + sep + this.params;
return "" + url + sep + params;
};
Discogs.prototype.request = function(url, next) {
discogsRequest = function(url, next) {
return request({
uri: this.getUrl(url),
uri: getUrl(url),
headers: {

@@ -42,5 +41,5 @@ 'accept-encoding': 'gzip'

if (__indexOf.call(res.headers['content-type'], 'gzip') >= 0) {
body = this.gunzip.inflate(body);
body = gunzip.inflate(body);
}
if (__indexOf.call(res.headers['content-type'], 'json') >= 0 || this.config.f === 'json') {
if (__indexOf.call(res.headers['content-type'], 'json') >= 0 || _config.f === 'json') {
body = JSON.parse(body);

@@ -55,25 +54,3 @@ }

};
Discogs.prototype.get = function(url, next) {
return this.request(url, next);
};
Discogs.prototype.release = function(id, next) {
return this.request('release/' + id, Discogs.responseHandler('release', next));
};
Discogs.prototype.artist = function(name, next) {
return this.request('artist/' + name, Discogs.responseHandler('artist', next));
};
Discogs.prototype.label = function(name, next) {
return this.request('label/' + name, Discogs.responseHandler('label', next));
};
Discogs.prototype.search = function(query, type, next) {
if (type instanceof Function) {
next = type;
type = 'all';
}
return this.request('search?' + querystring.stringify({
type: type,
q: query
}), Discogs.responseHandler('search', next));
};
Discogs.responseHandler = function(type, next) {
responseHandler = function(type, next) {
return function(err, res) {

@@ -86,7 +63,27 @@ if (err || !(res instanceof Object) || !(type in (res != null ? res.resp : void 0))) {

};
return Discogs;
})();
exports.discogs = function(config) {
return new Discogs(config);
return {
get: function(url, next) {
return discogsRequest(url, next);
},
release: function(id, next) {
return discogsRequest('release/' + id, responseHandler('release', next));
},
artist: function(name, next) {
return discogsRequest('artist/' + name, responseHandler('artist', next));
},
label: function(name, next) {
return discogsRequest('label/' + name, responseHandler('label', next));
},
search: function(query, type, next) {
if (type instanceof Function) {
next = type;
type = 'all';
}
return discogsRequest('search?' + querystring.stringify({
type: type,
q: query
}), responseHandler('search', next));
}
};
};
}).call(this);
{
"name": "discogs",
"description": "Simple client for Discogs API",
"version": "0.1.1",
"version": "0.2.0",
"author": "Linus G Thiel <linus@hanssonlarsson.se> (http://hanssonlarsson.se/)",

@@ -6,0 +6,0 @@ "contributors": [

@@ -7,3 +7,3 @@ Discogs: A simple JavaScript wrapper for the Discogs API

## Version
0.1.1
0.2.0

@@ -26,6 +26,6 @@ ## Requirements

var client = discogs.discogs({api_key: 'foo4711'});
var client = discogs({api_key: 'foo4711'});
client.artist('Jay-Z', function(err, artist) {
console.log(artist.realname); // Shawn Corey Carter
client.artist('Marcus Price', function(err, artist) {
console.log(artist.name); // Marcus Price
});

@@ -32,0 +32,0 @@

Sorry, the diff of this file is not supported yet

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