AtoraSuunva / booru

Searches boorus for images using some js magic
https://www.npmjs.com/package/booru
MIT License
79 stars 19 forks source link

Move to full OOP #11

Closed AtoraSuunva closed 6 years ago

AtoraSuunva commented 6 years ago

Essentially rewrite the whole thing to make it more easily extensible in terms of supporting different boorus, with the final goal of adding more functionality than just searching boorus (Things like fetching the comments or allowing for login use to favorite pics or whatever.)

Backwards compatibility will still remain in some form, but might be removed in later releases so don't depend on it.

If you have any questions/comments/suggestions reply to this issue and I'll get back to you.

A very basic schema of what is going to happen is here:

Also coming is better JSDoc, for better intellisense :)

Yeah intellisense!

AtoraSuunva commented 6 years ago

https://github.com/AtlasTheBot/booru/tree/classes holds the in-dev version

Also, if someone knows how to refer to @typedef in other files help

nvm I fixy

AtoraSuunva commented 6 years ago
// Another example, where we instantiate a booru and then use it
// instantiating a booru allows for you to do more complex things,
// like favoriting a post (if you provide an api token) or posting/viewing comments, etc.
async function example() {
  const e9 = new Booru('e9', {token: 'goes here'})
  let imgs = await e9.search(['cat', 'cute'], {limit: 1, random: true})

  // Log the post url to the first image
  console.log(imgs[0].postView)

  // In the future, things like `e9.favorite(BooruImage)` or `e9.fetchComments(BooruImage)`
  // Will be available (and maybe even <BooruImage>.favorite())
}

That was fast

Above is valid code for booru v0.5.0

Creating Boorus and .postView on BooruImages might be the only really new things, but with the new structure for the module get ready to see some cool features :)

AtoraSuunva commented 6 years ago

Changelog

Breaking Changes

What's new

tl;dr

This update is only really exciting if you love JSDoc or are me, because now I can fix bugs and tweak parts more easily and stay sane :)

AtoraSuunva commented 6 years ago

I won't be releasing this until I test it out for a while.

For the curious (or adventurous), you can install the dev version (this one) with npm install --save booru@dev

Nothing should break, but it's better to be careful

AtoraSuunva commented 6 years ago

this is done heck yea