ctan
Version:
CTAN (Comprehensive TeX Archive Network) API client for Node.js
14 lines (13 loc) • 750 B
JavaScript
import { ClientBase, buildParams } from "../../client-base.js";
import { SearchPaginator } from "./paginator.js";
import { SearchResult as Schema } from "./schemas.js";
export class Searchable extends ClientBase {
async search(params, config) {
params = typeof params === 'string' ? { phrase: params } : params;
const result = await this.get('/search/json', buildParams(params, ["phrase", "offset", "max", "ext", "PKG", "AUTHORS", "TOPICS", "FILES", "PORTAL", "wildcard"]), Schema, config);
return new SearchPaginator(result, this, params, config);
}
static mixin(derived) {
Object.defineProperty(derived.prototype, 'search', Object.getOwnPropertyDescriptor(Searchable.prototype, 'search') ?? {});
}
}