mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-03-31 20:02:30 +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 request = require('request');
|
||||||
|
const SteamID = require('steamid');
|
||||||
const xml2js = require('xml2js');
|
const xml2js = require('xml2js');
|
||||||
|
|
||||||
|
const EResult = require('../resources/EResult.js');
|
||||||
|
|
||||||
exports.isSteamID = function(input) {
|
exports.isSteamID = function(input) {
|
||||||
var keys = Object.keys(input);
|
var keys = Object.keys(input);
|
||||||
if (keys.length != 4) {
|
if (keys.length != 4) {
|
||||||
@ -106,3 +108,21 @@ exports.resolveVanityURL = function(url, callback) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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