packageDocumentation module import { BooruError } from '../Constants' ; import SearchParameters from '../structures/SearchParameters' ; import SearchResults from '../structures/SearchResults' ; import Site from '../structures/Site' ; import Booru , { BooruCredentials } from './Booru' ; private extends Booru inheritDoc export default class Derpibooru extends Booru { param site param credentials constructor ( site , credentials ? ) { super ( site , credentials ) ; } inheritDoc public override search ( tags , { limit = 1 , random = false , page = 0 } = { } ) { if ( ! Array . isArray ( tags ) ) { tags = [ tags ] ; } if ( tags [ 0 ] === undefined ) { tags [ 0 ] = '*' ; } page += 1 ; const uri = this . getSearchUrl ( { tags , limit , page } ) + ( random && this . site . random === 'string' ? `&${ this . site . random }` : '' ) + ( this . credentials ? `&key=${ this . credentials . token }` : '' ) ; return super . doSearchRequest ( tags , { limit , random , page , uri } ) . then ( ( r ) => super . parseSearchResult ( r , { fakeLimit : 0 , tags , limit , random , page } ) ) . catch ( ( e ) => Promise . reject ( new BooruError ( e ) ) ) ; } }