mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-01-13 12:10:06 +08:00
Added steamID coalescing helper, although currently unused
This commit is contained in:
parent
bf2b4601ee
commit
cf4b474c70
@ -1,7 +1,9 @@
|
||||
const EResult = require('../resources/EResult.js');
|
||||
const request = require('request');
|
||||
const SteamID = require('steamid');
|
||||
const xml2js = require('xml2js');
|
||||
|
||||
const EResult = require('../resources/EResult.js');
|
||||
|
||||
exports.isSteamID = function(input) {
|
||||
var keys = Object.keys(input);
|
||||
if (keys.length != 4) {
|
||||
@ -105,4 +107,22 @@ exports.resolveVanityURL = function(url, callback) {
|
||||
callback(null, {"vanityURL": vanityURL, "steamID": steamID64});
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts `input` into a SteamID object, if it's a parseable string.
|
||||
* @param {SteamID|string} input
|
||||
* @return {SteamID}
|
||||
*/
|
||||
exports.steamID = function(input) {
|
||||
if (exports.isSteamID(input)) {
|
||||
return input;
|
||||
}
|
||||
|
||||
if (typeof input != 'string') {
|
||||
throw new Error(`Input SteamID value "${input}" is not a string`);
|
||||
}
|
||||
|
||||
// This will throw if the input is not a well-formed SteamID
|
||||
return new SteamID(input);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user