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.1.0 to 1.2.0

83

lib/search.js

@@ -11,3 +11,3 @@ // Generated by LiveScript 1.4.0

out$.search = search = function(){
var ref$, tags, params, callback, stacktrace, tagsArray, i$, len$, tag, e;
var ref$, tags, params, callback, stacktrace, tagsArray, i$, len$, tag, e, helpers, helperify;
ref$ = argsJs([

@@ -54,9 +54,5 @@ {

}
return (function(dScope){
return dScope.get('posts', params, function(e, data){
if (e != null) {
e.stack = stacktrace;
return callback(e, data);
}
data.load = function(){
(function(self){
helpers = {
load: function(){
var ref$, page, callback, myParams, stacktrace;

@@ -76,3 +72,3 @@ ref$ = argsJs([

stacktrace = util.stacktrace;
return dScope.search(this.tags, myParams, function(e, data){
return self.search(this.tags, myParams, function(e, data){
if (e != null) {

@@ -83,4 +79,4 @@ e.stack = stacktrace;

});
};
data.next = function(){
},
next: function(){
var ref$, modifier, callback, stacktrace;

@@ -103,4 +99,4 @@ ref$ = argsJs([

});
};
data.prev = function(){
},
prev: function(){
var ref$, modifier, callback, stacktrace;

@@ -123,4 +119,4 @@ ref$ = argsJs([

});
};
data.add = function(){
},
add: function(){
var ref$, tagMod, callback, myParams, stacktrace;

@@ -140,3 +136,3 @@ ref$ = argsJs([

stacktrace = util.stacktrace;
return dScope.search(this.tags + (" " + tagMod), myParams, function(e, data){
return self.search(this.tags + (" " + tagMod), myParams, function(e, data){
if (e != null) {

@@ -147,4 +143,4 @@ e.stack = stacktrace;

});
};
data.rem = function(){
},
rem: function(){
var ref$, tagMod, callback, newTags, tags, i$, len$, tag, myParams, stacktrace;

@@ -174,3 +170,3 @@ ref$ = argsJs([

stacktrace = util.stacktrace;
return dScope.search(newTags, myParams, function(e, data){
return self.search(newTags, myParams, function(e, data){
if (e != null) {

@@ -181,20 +177,30 @@ e.stack = stacktrace;

});
};
Object.defineProperty(data, 'page', {
get: function(){
return params.page;
},
configurable: true,
enumerable: true
});
Object.defineProperty(data, 'tags', {
get: function(){
return params.tags;
},
configurable: true,
enumerable: true
});
return callback(void 8, data);
});
}
};
}.call(this, this));
helperify = function(it){
var ref$;
return ref$ = import$(it, helpers), Object.defineProperty(ref$, 'page', {
get: function(){
return params.page;
},
configurable: true,
enumerable: true
}), Object.defineProperty(ref$, 'tags', {
get: function(){
return params.tags;
},
configurable: true,
enumerable: true
}), ref$;
};
this.get('posts', params, function(e, data){
if (e != null) {
e.stack = stacktrace;
return callback(e, data);
}
helperify(data);
return callback(void 8, data);
});
return helperify({});
};

@@ -206,2 +212,7 @@ function in$(x, xs){

}
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.1.0",
"version": "1.2.0",
"description": "danbooru api wrapper",

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

@@ -57,3 +57,3 @@ # danbooru-node

"But wait," you say, "APIs are supposed to help make my life easier! Why do I still have to type so much?" Well, I made a helper function called `search` for you, and as a bonus, its data object even gives you extra helper functions to get around more easily!
"But wait," you say, "APIs are supposed to help make my life easier! Why do I still have to type so much?" Well, I made a helper function called `.search()` for you, and as a bonus, its data object even gives you extra helper functions to get around more easily! The helper functions are also returned by `.search()`, so you can chain more nicely!

@@ -64,11 +64,8 @@ ```javascript

console.log(page1); // Foxgirls!
page1.next(function(err, page2) {
}).next(function(err, page2) {
if(err) throw err;
console.log(page2); // More foxgirls!
page2.next(function(err, page3) {
if(err) throw err;
console.log(page2); // More foxgirls!
page2.next(function(err, page3) {
if(err) throw err;
console.log(page3); // So many foxgirls~ ♥
});
console.log(page3); // So many foxgirls~ ♥
});

@@ -78,6 +75,4 @@ });

It might be a lot of callback nesting, but you can easily get around that with a nice package like [async](https://www.npmjs.com/package/async) or something that converts callbacks to promises, right? You might notice that I use LiveScript, which has a really nice way of dealing with callback nesting. I know some other languages have their own methods too, so you might wannya try one or some of them!
### Danbooru.search([tags], [params], [callback])
Perform a search on Danbooru. A shortcut for `Danbooru.get('posts', {tags: tags, limit: 100, ...params}, callback)`, but also adds on extra methods to the data object you get. Visit [an api result](https://danbooru.donmai.us/posts.json?tags=fox_ears&limit=2) in your browser to inspect the data object returned.
Perform a search on Danbooru. A shortcut for `Danbooru.get('posts', {tags: tags, limit: 100, ...params}, callback)`, but also adds on extra methods to the data object you get. Visit [an api result](https://danbooru.donmai.us/posts.json?tags=fox_ears&limit=2) in your browser to inspect the data object provided.
* `tags` _string_. A space separated list of tags, and basically your Danbooru search query. You can try out your query visually on [Danbooru](https://danbooru.donmai.us/) or look up their [searching reference](https://danbooru.donmai.us/wiki_pages/43049) if you're not sure what to type.

@@ -88,5 +83,6 @@ * `params` _object_. These are just parameters that will be directly passed to Danbooru's API. It will contain `limit: 100`

- `err` _Error_. Like always, an error object if there was one.
- `data` _Object_. Whatever Danbooru's API returns, but with some extra methods and properties. More details below!
- `searchData` _object_. Whatever Danbooru's API returns, but with some extra methods and properties. More details below!
* **returns** _object_. Contains only my extra helper methods and properties from `searchData`. Also details below~
### Danbooru.search() > callback data
### Danbooru.search -> [callback] -> data
Like I've said probably three times already, this data object is the one that Danbooru's api gives you, but with some nice helper functions! You can see sample API output by [visiting Danbooru](https://danbooru.donmai.us/posts.json?tags=fox_ears&limit=2). I haven't told you what the methods are yet, so~

@@ -93,0 +89,0 @@

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