Divide the NSFW and SFW functions a bit more
See original GitHub issueDescribe new features you want
Currently, all of the available endpoints are exposed via the NekoClient
class as individual functions. It would be great if you could instantiate the module but say you only want the SFW functions at the moment.
Describe the solution you’d like
The NekoClient
class constructor would have one optional parameter contentType
. If undefined, it would assign all functions as usual so it’s still backward compatible.
If contentType
is SFW or NSFW, then only assign those functions to the class.
Describe alternatives you’ve considered
At first, I thought it would be easier to just export a SFW and NSFW object in the NekoClient
class that you could choose. After tinkering with it some more I realized this would break backward compatibility as any previous code relying on the function calls would then have to add a sfw
or nsfw
prefix to the function call.
Additional context I’ve created a working version of this on my fork, but I’m not entirely sure how to show this new conditional function stuff in TypeScript. So at the moment, when you install my fork it still shows all of the functions exported as usual no matter what.
However, if you do something like the following, you’ll get a function not found error:
const Neko = require('nekos.life')
const neko = new Neko('sfw')
neko.getNSFWBoobs()
.then(res => console.log(res.url))
.catch(err => console.error(err))
A Gif to describe how you feel when you made this request
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Take a look at the npm page 😉
I’ll probably take a better look and update sometime in the next week. The only unfortunate thing about doing so is that it will be a breaking change. It’s okay that it’s a breaking change because with V3 of the API coming, it would have to be a breaking change either way.