misskey-awawa/src/prelude/ensure.ts

11 lines
265 B
TypeScript
Raw Normal View History

2019-04-13 05:45:51 +00:00
/**
* null undefined
*/
export function ensure<T>(x: T): NonNullable<T> {
if (x == null) {
2019-04-13 19:17:24 +00:00
throw new Error('ぬるぽ');
} else {
return x!;
}
}