/
function-id.ts
41 lines (37 loc) · 881 Bytes
/
function-id.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* @module parallel
*/
/** */
/**
* Identifier for a serialized function
*/
export interface IFunctionId {
/**
* The globally unique identifier
*/
identifier: string;
/**
* Flag that indicates that this is a function id
*/
_______isFunctionId: boolean;
}
/**
* Creates a function id
* @param namespace the namespace of the id
* @param id the unique id for this namespace
* @returns the function id
*/
export function functionId(namespace: string, id: number): IFunctionId {
return {
_______isFunctionId: true,
identifier: `${namespace}-${id}`
};
}
/**
* Tests if the given object is a function id
* @param obj the object to test for
* @returns true if the object is a function id
*/
export function isFunctionId(obj: any): obj is IFunctionId {
return !!obj && obj._______isFunctionId === true;
}