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

danbooru

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

danbooru - npm Package Compare versions

Comparing version 1.0.2 to 1.0.6

.travis.yml

84

lib/index.js
// Generated by LiveScript 1.4.0
(function(){
var https, request, exports, slice$ = [].slice;
var https, request, deepExtend, argsJs, exports, slice$ = [].slice;
https = require('https');
request = require('request');
deepExtend = require('deep-extend');
argsJs = require('args-js');
module.exports = function(it){

@@ -11,3 +13,3 @@ return importAll$(it, it());

exports.displayName = 'exports';
var danbooruErrors, stackTracer, parsePath, doRequest, optional_args, prototype = exports.prototype, constructor = exports;
var danbooruErrors, stackTracer, parsePath, doRequest, optionalArgs, prototype = exports.prototype, constructor = exports;
function exports(params, key){

@@ -30,3 +32,3 @@ params == null && (params = {});

} else {
this.defaultParameters = import$({}, params);
this.defaultParameters = deepExtend({}, params);
}

@@ -58,8 +60,9 @@ }

doRequest = function(self, method, body, path, params, callback){
var stacktrace;
stacktrace = stackTracer(doRequest);
(function(){
var data, dataName, uri, stacktrace, ref$;
data = import$(import$({}, this.defaultParameters), params);
var data, dataName, uri, ref$;
data = deepExtend({}, this.defaultParameters, params);
dataName = body ? 'form' : 'qs';
uri = parsePath(path);
stacktrace = stackTracer(doRequest);
request((ref$ = {

@@ -69,42 +72,52 @@ uri: uri,

}, ref$[dataName] = data, ref$.json = true, ref$), function(e, response, body){
var error;
if (e != null) {
return callback(e);
try {
if (e != null) {
throw e;
}
if (response.statusCode !== 200) {
throw new Error(danbooruErrors[response.statusCode]);
}
return callback(void 8, body);
} catch (e$) {
e = e$;
e.stack = stacktrace;
return callback(e, body);
}
if (response.statusCode !== 200) {
error = new Error(danbooruErrors[response.statusCode]);
error.stack = stacktrace;
return callback(error, body);
}
return callback(void 8, body);
});
}.call(self));
};
optional_args = function(path, params, callback){
var ref$;
path == null && (path = '');
params == null && (params = {});
callback == null && (callback = function(){});
if (typeof params !== 'object') {
ref$ = [{}, params], params = ref$[0], callback = ref$[1];
optionalArgs = function(){
var stacktrace, ref$, path, params, callback, e;
stacktrace = stackTracer(optionalArgs);
try {
ref$ = argsJs([
{
path: argsJs.STRING | argsJs.Optional,
_default: ''
}, {
params: argsJs.OBJECT | argsJs.Optional,
_default: {}
}, {
callback: argsJs.FUNCTION | argsJs.Optional,
_default: function(){}
}
], arguments), path = ref$.path, params = ref$.params, callback = ref$.callback;
return [path, params, callback];
} catch (e$) {
e = e$;
e.stack = stacktrace;
throw e;
}
if (typeof path !== 'string') {
ref$ = ['', path], path = ref$[0], params = ref$[1];
}
if (typeof params !== 'object') {
ref$ = [{}, params], params = ref$[0], callback = ref$[1];
}
return [path, params, callback];
};
prototype.get = function(path, params, callback){
return doRequest.apply(null, [this, 'GET', false].concat(slice$.call(optional_args.apply(this, arguments))));
return doRequest.apply(null, [this, 'GET', false].concat(slice$.call(optionalArgs.apply(this, arguments))));
};
prototype.post = function(path, params, callback){
return doRequest.apply(null, [this, 'POST', true].concat(slice$.call(optional_args.apply(this, arguments))));
return doRequest.apply(null, [this, 'POST', true].concat(slice$.call(optionalArgs.apply(this, arguments))));
};
prototype.put = function(path, params, callback){
return doRequest.apply(null, [this, 'PUT', true].concat(slice$.call(optional_args.apply(this, arguments))));
return doRequest.apply(null, [this, 'PUT', true].concat(slice$.call(optionalArgs.apply(this, arguments))));
};
prototype['delete'] = function(path, params, callback){
return doRequest.apply(null, [this, 'DELETE', true].concat(slice$.call(optional_args.apply(this, arguments))));
return doRequest.apply(null, [this, 'DELETE', true].concat(slice$.call(optionalArgs.apply(this, arguments))));
};

@@ -117,7 +130,2 @@ return exports;

}
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
}).call(this);
{
"name": "danbooru",
"version": "1.0.2",
"version": "1.0.6",
"description": "danbooru api wrapper",

@@ -38,4 +38,6 @@ "main": "lib/index.js",

"dependencies": {
"args-js": "^0.10.11",
"deep-extend": "^0.4.1",
"request": "^2.69.0"
}
}
# danbooru-node
danbooru api wrapper
I couldn't find one on [npmjs.com](https://www.npmjs.com/), so I thought I'd try making my own!
[![NPM](https://nodei.co/npm/danbooru.png?mini=true)](https://nodei.co/npm/danbooru/)
[![Build Status](https://travis-ci.org/stawberri/danbooru-node.svg?branch=master)](https://travis-ci.org/stawberri/danbooru-node)
```
npm i danbooru -S
```
My api wrapper is super simple! First, you require it:

@@ -28,4 +25,5 @@ ```javascript

### Danbooru.get(path, [params], [callback])
### Danbooru.method(path, [params], [callback])
Perform a `GET` request on Danbooru's api!
* `method` _property_. One of `get`, `post`, `put`, or `delete`, depending on what type of request you would like to make.
* `path` _string_. The API documentation mentions a base URL. You put that here! The slash and `.json` are optional.

@@ -37,11 +35,2 @@ * `params` _object_. Just provide your parameters as an object!

### Danbooru.post(path, [params], [callback])
Perform a `POST` request on Danbooru's api! As far as you needta be concerned, it works exactly like `GET`!
### Danbooru.put(path, [params], [callback])
Perform a `PUT` request on Danbooru's api! Works exactly like `POST`!
### Danbooru.delete(path, [params], [callback])
Perform a `DELETE` request on Danbooru's api! Works exactly like `POST`.
## Authentication

@@ -63,5 +52,5 @@ You know what's a pain? Having to type the same stuff over and over again. You know what you hafta do if you want to be authenticated on Danbooru? Send your `login` and `api_key` over and over again.

### [new] Danbooru(object, api_key)
### [new] Danbooru(object, [api_key])
Save parameters for later. Returns a new Danbooru object that you can use to make requests with those saved parameters.
* `object` _object_. _string_. If you provide an object, it'll be used as default parameters for all requests you make! If you provide a string, it'll set your default `login` parameter to whatever you provide!
* `api_key` _string_. If (and only if) you provided a string for `object`, this will be used as your default `api_key` parameter!
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