Steamid typings

This commit is contained in:
Edward Sammut Alessi
2018-03-22 12:08:08 +01:00
parent 55a1b5699f
commit 94588ea50d
4 changed files with 177 additions and 0 deletions
+134
View File
@@ -0,0 +1,134 @@
// Type definitions for steamid 1.1
// Project: https://github.com/DoctorMcKay/node-steamid
// Definitions by: My Self <https://github.com/me>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/**
* Render this SteamID into Steam2 textual format
* @param newerFormat [newerFormat=false] - true if you want to use 1 in place of the leading 0 for the public universe
*/
type getSteam2RenderedID = (newerFormat?: boolean) => string;
/**
* Render this SteamID into Steam3 textual format
*/
type getSteam3RenderedID = () => string;
/**
* Render this SteamID into 64-bit numeric format
*/
type getSteamID64 = () => string;
declare class SteamID {
universe: SteamID.Universe;
type: SteamID.Type;
instance: SteamID.Instance;
accountid: number;
/**
* You can create a SteamID object from a Steam2 rendered ID, a Steam3 rendered ID, a SteamID64, or from the four parts that make up a SteamID.
* @param input SteamID string
*/
constructor(input: string);
/**
* Check whether this SteamID is valid (according to Steam's rules)
*/
isValid(): boolean;
/**
* Check whether this chat SteamID is tied to a Steam group.
*/
isGroupChat(): boolean;
/**
* Check whether this chat SteamID is a Steam lobby.
*/
isLobby(): boolean;
getSteam2RenderedID: getSteam2RenderedID;
steam2: getSteam2RenderedID;
getSteam3RenderedID: getSteam3RenderedID;
steam3: getSteam3RenderedID;
getSteamID64: getSteamID64;
toString: getSteamID64;
}
declare namespace SteamID {
// Universe constants
enum Universe {
INVALID = 0,
PUBLIC = 1,
BETA = 2,
INTERNAL = 3,
DEV = 4,
}
// Type constants
enum Type {
INVALID = 0,
INDIVIDUAL = 1,
MULTISEAT = 2,
GAMESERVER = 3,
ANON_GAMESERVER = 4,
PENDING = 5,
CONTENT_SERVER = 6,
CLAN = 7,
CHAT = 8,
P2P_SUPER_SEEDER = 9,
ANON_USER = 10,
}
// Instance constants
enum Instance {
ALL = 0,
DESKTOP = 1,
CONSOLE = 2,
WEB = 4,
}
// Type chars
enum TypeChars {
I = Type.INVALID,
U = Type.INDIVIDUAL,
M = Type.MULTISEAT,
G = Type.GAMESERVER,
A = Type.ANON_GAMESERVER,
P = Type.PENDING,
C = Type.CONTENT_SERVER,
g = Type.CLAN,
T = Type.CHAT,
a = Type.ANON_USER,
}
const AccountIDMask = 0xFFFFFFFF;
const AccountInstanceMask = 0x000FFFFF;
enum ChatInstanceFlags {
/**
* (AccountInstanceMask + 1) >> 1
*/
Clan = (0x000FFFFF + 1) >> 1,
/**
* (AccountInstanceMask + 1) >> 2
*/
Lobby = (0x000FFFFF + 1) >> 2,
/**
* (AccountInstanceMask + 1) >> 3
*/
MMSLobby = (0x000FFFFF + 1) >> 3,
}
/**
* Create an individual SteamID in the public universe given an accountid
* @param accountid - The user's account ID
*/
function fromIndividualAccountID(accountid: number | string): SteamID;
}
export = SteamID;
+19
View File
@@ -0,0 +1,19 @@
import SteamID = require("steamid");
let sid: SteamID;
sid = new SteamID("76561198006409530");
sid = SteamID.fromIndividualAccountID(46143802);
sid.universe = SteamID.Universe.PUBLIC;
sid.type = SteamID.Type.INDIVIDUAL;
sid.instance = SteamID.Instance.DESKTOP;
sid.accountid = 46143802;
sid.isValid();
sid.isGroupChat();
sid.isLobby();
sid.getSteam2RenderedID();
sid.getSteam2RenderedID(true);
sid.getSteam3RenderedID();
sid.getSteamID64();
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"steamid-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }