UNPKG

mwn

Version:

JavaScript & TypeScript MediaWiki bot framework for Node.js

46 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; function default_1(bot) { class File extends bot.Page { /** @inheritDoc */ constructor(name) { super(name, 6); if (this.namespace !== 6) { throw new Error('not a file'); } } /** @inheritDoc */ getName() { let ext = this.getExtension(); if (ext === null) { return this.getMain(); } return this.getMain().slice(0, -ext.length - 1); } /** @inheritDoc */ getNameText() { return this.getName().replace(/_/g, ' '); } /** @inheritDoc */ usages(options) { return bot .query({ titles: this.toString(), prop: 'fileusage', fuprop: 'pageid|title|redirect', ...options, }) .then((data) => { return data.query.pages[0].fileusage || []; }); } // TODO: Add wrapper for prop=imageinfo /** @inheritDoc */ download(localname) { return bot.download(this.toString(), localname); } } return File; } //# sourceMappingURL=file.js.map