smartsocket/ts/smartsocket.helpers.ts

33 lines
1.2 KiB
TypeScript
Raw Normal View History

2016-08-07 12:58:20 +00:00
import * as plugins from "./smartsocket.plugins";
2016-08-08 16:20:00 +00:00
// classes
import { Smartsocket } from "./smartsocket.classes.smartsocket";
2016-08-12 01:22:36 +00:00
import { SocketFunction, allSocketFunctions } from "./smartsocket.classes.socketfunction";
2016-08-08 16:20:00 +00:00
import { SocketConnection } from "./smartsocket.classes.socketconnection";
2016-08-12 03:17:13 +00:00
import { SocketRequest, allSocketRequests, TSocketRequestSide } from "./smartsocket.classes.socketrequest";
2016-08-08 16:20:00 +00:00
import { SocketRole, allSocketRoles } from "./smartsocket.classes.socketrole";
2016-08-07 12:58:20 +00:00
2016-08-12 01:22:36 +00:00
// SocketFunction helpers
2016-08-12 03:17:13 +00:00
export let getSocketFunctionByName = (functionNameArg: string):SocketFunction => {
return allSocketFunctions.find((socketFunctionArg) => { return socketFunctionArg.name === functionNameArg });
2016-08-12 01:22:36 +00:00
}
2016-08-12 03:17:13 +00:00
// SocketRequest helpers
/**
* get corresponding Socketrequest instance by shortId
*/
export let getSocketRequestById = (shortIdArg:string,requestSide?:TSocketRequestSide):SocketRequest => {
return allSocketRequests.find((socketRequestArg) => {return socketRequestArg.shortid === shortIdArg})
}
2016-08-07 12:58:20 +00:00
2016-08-08 16:20:00 +00:00
// SocketRole helpers
2016-08-12 01:22:36 +00:00
/**
2016-08-12 03:17:13 +00:00
* get corresponding SocketRole instance by name
2016-08-12 01:22:36 +00:00
*/
export let getSocketRoleByName = (socketRoleNameArg: string): SocketRole => {
2016-08-08 16:20:00 +00:00
return allSocketRoles.find((socketRoleArg) => { return socketRoleArg.name === socketRoleNameArg })
};
2016-08-07 12:58:20 +00:00