You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
381 B
14 lines
381 B
8 years ago
|
export function checkedIndexOf<T>(o: T | number, arr: T[], type: string = "object"): number {
|
||
8 years ago
|
const idx = (typeof o === "number")
|
||
|
? o
|
||
|
: arr.indexOf(o);
|
||
8 years ago
|
if (idx < 0 || idx > arr.length) {
|
||
|
throw new Error(`Invalid ${type} specified: ${o}`);
|
||
|
}
|
||
|
return idx;
|
||
|
}
|
||
7 years ago
|
|
||
|
export function getRandomId() {
|
||
|
return Math.floor(Math.random() * 1000000000);
|
||
|
}
|