mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 15:24:52 +09:00
Fix incorrect JSDoc async return annotations
The return type of an async function should be documented as a Promise of what the function returns as this is what JSDoc expects.
This commit is contained in:
1 parent
a7dedcd3b7
commit
2d8b35291d
12 files changed
+33
-33
No files matched your search
@@ -142,7 +142,7 @@ class CommandTree {
|
||||
*
|
||||
* @param {module:lib/link.Link} client - link to master server to query slave on.
|
||||
* @param {string} slaveName - string with name or id of slave.
|
||||
* @returns {number} slave ID.
|
||||
* @returns {Promise<number>} slave ID.
|
||||
* @static
|
||||
*/
|
||||
async function resolveSlave(client, slaveName) {
|
||||
@@ -174,7 +174,7 @@ async function resolveSlave(client, slaveName) {
|
||||
*
|
||||
* @param {module:lib/link.Link} client - link to master server to query instance on.
|
||||
* @param {string} instanceName - string with name or id of instance.
|
||||
* @returns {number} instance ID.
|
||||
* @returns {Promise<number>} instance ID.
|
||||
* @static
|
||||
*/
|
||||
async function resolveInstance(client, instanceName) {
|
||||
@@ -239,7 +239,7 @@ async function resolveModPack(client, modPackName) {
|
||||
*
|
||||
* @param {module:lib/link.Link} client - link to master server to query role on.
|
||||
* @param {string} roleName - string with name or id of role.
|
||||
* @returns {Object} Role info.
|
||||
* @returns {Promise<object>} Role info.
|
||||
* @static
|
||||
*/
|
||||
async function retrieveRole(client, roleName) {
|
||||
|
||||
@@ -67,7 +67,7 @@ async function loadZip(server, modVersions, mod) {
|
||||
* The server to load the file from.
|
||||
* @param {Map<string, string>} modVersions - Mapping of mod to version used.
|
||||
* @param {string} modPath - Factorio style path to the file to load.
|
||||
* @returns {?Buffer} The content of the file or null if not found.
|
||||
* @returns {Promise<?Buffer>} The content of the file or null if not found.
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
* @inner
|
||||
@@ -255,7 +255,7 @@ function filterItems(prototypes) {
|
||||
* @param {Map<string, string>} modVersions -
|
||||
* Mapping of mod name to versions to get icons from.
|
||||
* @param {Array<Object>} items - Array of item prototypes.
|
||||
* @return {{itemSheet: Jimp, itemData: Map<string,Object>}}
|
||||
* @return {Promise<{itemSheet: Jimp, itemData: Map<string,Object>}>}
|
||||
* Item spritesheet and metadata.
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
@@ -327,7 +327,7 @@ async function exportItems(server, modVersions, items) {
|
||||
* Mapping of mod name to version to export locale from.
|
||||
* @param {Array<string>} modOrder - Load order of the mods.
|
||||
* @param {string} languageCode - Language to export locale for.
|
||||
* @returns {Map<string, string>} merged locale information
|
||||
* @returns {Promise<Map<string, string>>} merged locale information
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
* @inner
|
||||
@@ -379,7 +379,7 @@ async function exportLocale(server, modVersions, modOrder, languageCode) {
|
||||
*
|
||||
* @param {module:lib/factorio.FactorioServer} server -
|
||||
* The server to export the data from.
|
||||
* @returns {JSZip} zip file with exported data.
|
||||
* @returns {Promise<JSZip>} zip file with exported data.
|
||||
* @memberof module:lib/factorio
|
||||
*/
|
||||
async function exportData(server) {
|
||||
|
||||
@@ -86,7 +86,7 @@ function versionOrder(a, b) {
|
||||
* @param {string} targetVersion -
|
||||
* Version to look for, supports the special value "latest" for the
|
||||
* latest version available.
|
||||
* @returns {Array} Array with path to data dir and version found.
|
||||
* @returns {Promise<Array>} Array with path to data dir and version found.
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
* @inner
|
||||
@@ -163,7 +163,7 @@ function randomDynamicPort() {
|
||||
* the given length.
|
||||
*
|
||||
* @param {number} length - the length of the password to generate.
|
||||
* @return {string} password of the given length
|
||||
* @return {Promise<string>} password of the given length
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
* @inner
|
||||
@@ -902,7 +902,7 @@ class FactorioServer extends events.EventEmitter {
|
||||
* @param {boolean} expectEmpty -
|
||||
* if true throw if the response is not empty. Useful for detecting
|
||||
* errors that might have been sent in response.
|
||||
* @returns {string} response from server.
|
||||
* @returns {Promise<string>} response from server.
|
||||
*/
|
||||
async sendRcon(message, expectEmpty) {
|
||||
this._check(["running", "stopping"]);
|
||||
@@ -1036,7 +1036,7 @@ class FactorioServer extends events.EventEmitter {
|
||||
* Ensures achievements are disabled on the save that's running. This is
|
||||
* necessary in order to run any commands at all.
|
||||
*
|
||||
* @returns {boolean}
|
||||
* @returns {Promise<boolean>}
|
||||
* True if acheivements got disabled and false if they already where
|
||||
* disabled.
|
||||
*/
|
||||
@@ -1104,7 +1104,7 @@ class FactorioServer extends events.EventEmitter {
|
||||
*
|
||||
* Loads server-settings.example.json from the data dir.
|
||||
*
|
||||
* @returns {object} the parsed server-settings.
|
||||
* @returns {Promise<object>} the parsed server-settings.
|
||||
*/
|
||||
async exampleSettings() {
|
||||
return JSON.parse(await fs.readFile(this.dataPath("server-settings.example.json"), "utf-8"));
|
||||
|
||||
@@ -13,7 +13,7 @@ const crypto = require("crypto"); // needed for getTempFile
|
||||
* @param {function(string): boolean} filter -
|
||||
* Optional function to filter out files to ignore. Should return true
|
||||
* if the file is to be considered.
|
||||
* @returns {?string}
|
||||
* @returns {Promise<?string>}
|
||||
* Name of the file with the newest timestamp or null if the
|
||||
* directory contains no files.
|
||||
*/
|
||||
@@ -80,8 +80,8 @@ async function directorySize(directory) {
|
||||
* @param {string} directory - directory to check in.
|
||||
* @param {string} name - file name to check for, may have extension.
|
||||
* @param {string} extension - dot extension used for the file name.
|
||||
* @returns {string} modified name with extension that likely does not exist
|
||||
* in the folder
|
||||
* @returns {Promise<string>} modified name with extension that likely does
|
||||
* not exist in the folder
|
||||
*/
|
||||
async function findUnusedName(directory, name, extension = "") {
|
||||
if (extension && name.endsWith(extension)) {
|
||||
|
||||
@@ -63,7 +63,7 @@ async function timeout(promise, time, timeoutResult) {
|
||||
* returns all the data which was read from the stream.
|
||||
*
|
||||
* @param {Readable} stream - byte stream to read to the end.
|
||||
* @returns {Buffer} content of the stream.
|
||||
* @returns {Promise<Buffer>} content of the stream.
|
||||
* @static
|
||||
*/
|
||||
async function readStream(stream) {
|
||||
|
||||
@@ -255,7 +255,7 @@ class Request extends Message {
|
||||
*
|
||||
* @param {module:lib/link.Link} link - Link to send request over.
|
||||
* @param {Object} data - Data to send with the request.
|
||||
* @returns {object} response data
|
||||
* @returns {Promise<object>} response data
|
||||
*/
|
||||
async send(link, data = {}) {
|
||||
// XXX validate link target/source?
|
||||
|
||||
@@ -205,7 +205,7 @@ class LogIndex {
|
||||
* module:lib/logging_utils.LogIndex#save}.
|
||||
*
|
||||
* @param {string} logDirectory - Path to directory to load from.
|
||||
* @returns {module:lib/logging_utils.LogIndex} loaded or created log index.
|
||||
* @returns {Promise<module:lib/logging_utils.LogIndex>} loaded or created log index.
|
||||
*/
|
||||
static async load(logDirectory) {
|
||||
try {
|
||||
@@ -391,7 +391,7 @@ function logFilter({ all, master, slave_ids, instance_ids, max_level }) {
|
||||
* Filter to limit logs by.
|
||||
* @param {module:lib/logging_utils.LogIndex=} index -
|
||||
* Index to speed up query with.
|
||||
* @returns {Array<Object>} log entries matching the filter
|
||||
* @returns {Promise<Array<Object>>} log entries matching the filter
|
||||
*/
|
||||
async function queryLog(logDirectory, filter, index) {
|
||||
let files = (await fs.readdir(logDirectory)).filter(entry => logFileGlob.test(entry));
|
||||
|
||||
@@ -812,7 +812,7 @@ function attachPluginMessages(link, plugin) {
|
||||
* Mapping of plugin names to plugins to invoke the hook on.
|
||||
* @param {string} hook - Name of hook to invoke.
|
||||
* @param {...*} args - Arguments to pass on to the hook.
|
||||
* @returns {Array} Non-empty return values from the hooks.
|
||||
* @returns {Promise<Array>} Non-empty return values from the hooks.
|
||||
*/
|
||||
async function invokeHook(plugins, hook, ...args) {
|
||||
let results = [];
|
||||
|
||||
@@ -19,7 +19,7 @@ const path = require("path");
|
||||
*
|
||||
* @param {Map<string, string>} pluginList -
|
||||
* Mapping of plugin name to require path for the plugins to load.
|
||||
* @returns {Array<Object>} Array of plugin info modules.
|
||||
* @returns {Promise<Array<Object>>} Array of plugin info modules.
|
||||
* @static
|
||||
*/
|
||||
async function loadPluginInfos(pluginList) {
|
||||
@@ -71,7 +71,7 @@ function loadPluginClass(entrypointName, className, pluginClass, pluginInfo) {
|
||||
* @param {Object} pluginInfo -
|
||||
* Plugin info object returned from {@link
|
||||
* module:lib/plugin_loader.loadPluginInfos} to load class from.
|
||||
* @returns {function} plugin class
|
||||
* @returns {Promise<function>} plugin class
|
||||
* @static
|
||||
*/
|
||||
async function loadMasterPluginClass(pluginInfo) {
|
||||
@@ -84,7 +84,7 @@ async function loadMasterPluginClass(pluginInfo) {
|
||||
* @param {Object} pluginInfo -
|
||||
* Plugin info object returned from {@link
|
||||
* module:lib/plugin_loader.loadPluginInfos} to load class from.
|
||||
* @returns {function} plugin class
|
||||
* @returns {Promise<function>} plugin class
|
||||
* @static
|
||||
*/
|
||||
async function loadInstancePluginClass(pluginInfo) {
|
||||
@@ -97,7 +97,7 @@ async function loadInstancePluginClass(pluginInfo) {
|
||||
* @param {Object} pluginInfo -
|
||||
* Plugin info object returned from {@link
|
||||
* module:lib/plugin_loader.loadPluginInfos} to load class from.
|
||||
* @returns {function} plugin class
|
||||
* @returns {Promise<function>} plugin class
|
||||
* @static
|
||||
*/
|
||||
async function loadControlPluginClass(pluginInfo) {
|
||||
|
||||
@@ -484,7 +484,7 @@ class Master {
|
||||
* @param {module:lib/logging_utils~QueryLogFilter} filter -
|
||||
* Filter to limit entries with. Note that only the master log can
|
||||
* be queried from this function.
|
||||
* @returns {Array<Object>} log entries matching the filter
|
||||
* @returns {Promise<Array<Object>>} log entries matching the filter
|
||||
*/
|
||||
async queryMasterLog(filter) {
|
||||
return await libLoggingUtils.queryLog(
|
||||
@@ -497,7 +497,7 @@ class Master {
|
||||
*
|
||||
* @param {module:lib/logging_utils~QueryLogFilter} filter -
|
||||
* Filter to limit entries with.
|
||||
* @returns {Array<Object>} log entries matching the filter
|
||||
* @returns {Promise<Array<Object>>} log entries matching the filter
|
||||
*/
|
||||
async queryClusterLog(filter) {
|
||||
return await libLoggingUtils.queryLog(
|
||||
@@ -811,7 +811,7 @@ class Master {
|
||||
* @param {object} data - Data to pass with the request.
|
||||
* @param {number} data.instance_id -
|
||||
* ID of instance to send this request towards
|
||||
* @returns {object} data returned from the request.
|
||||
* @returns {Promise<object>} data returned from the request.
|
||||
*/
|
||||
async forwardRequestToInstance(request, data) {
|
||||
let instance = this.getRequestInstance(data.instance_id);
|
||||
|
||||
@@ -193,7 +193,7 @@ class Instance extends libLink.Link {
|
||||
|
||||
/**
|
||||
* Mod pack currently running on this instance
|
||||
* @type {module:lib/data.ModPack>}
|
||||
* @type {module:lib/data.ModPack}
|
||||
*/
|
||||
this.activeModPack = undefined;
|
||||
|
||||
@@ -538,7 +538,7 @@ rcon.print(game.table_to_json(players))`.replace(/\r?\n/g, " ");
|
||||
* entries from the given settings object.
|
||||
*
|
||||
* @param {Object} overrides - Server settings to override.
|
||||
* @returns {Object}
|
||||
* @returns {Promise<Object>}
|
||||
* server example settings with the given settings applied over it.
|
||||
*/
|
||||
async resolveServerSettings(overrides) {
|
||||
@@ -699,10 +699,10 @@ rcon.print(game.table_to_json(players))`.replace(/\r?\n/g, " ");
|
||||
*
|
||||
* Creates a new save if no save is passed and patches it with modules.
|
||||
*
|
||||
* @param {String|null} saveName -
|
||||
* @param {string|null} saveName -
|
||||
* Save to prepare from the instance saves directory. Creates a new
|
||||
* save if null.
|
||||
* @returns {String} Name of the save prepared.
|
||||
* @returns {Promise<string>} Name of the save prepared.
|
||||
*/
|
||||
async prepareSave(saveName) {
|
||||
// Use latest save if no save was specified
|
||||
|
||||
@@ -41,7 +41,7 @@ function checkRequestSaveName(name) {
|
||||
* instanceInfo objects.
|
||||
*
|
||||
* @param {string} instancesDir - Directory containing instances
|
||||
* @returns {Map<integer, Object>}
|
||||
* @returns {Promise<Map<integer, Object>>}
|
||||
* mapping between instance id and information about this instance.
|
||||
* @private
|
||||
*/
|
||||
@@ -379,7 +379,7 @@ class Slave extends libLink.Link {
|
||||
* Initialize and connect an unloaded instance
|
||||
*
|
||||
* @param {number} instanceId - ID of instance to initialize.
|
||||
* @returns {module:slave/slave~InstanceConnection} connection to instance.
|
||||
* @returns {Promise<module:slave/slave~InstanceConnection>} connection to instance.
|
||||
*/
|
||||
async _connectInstance(instanceId) {
|
||||
let instanceInfo = this.getRequestInstanceInfo(instanceId);
|
||||
|
||||
Reference in new issue
Block a user