You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-10-09 22:22:31 +02:00
16 lines
413 B
TypeScript
16 lines
413 B
TypeScript
![]() |
|
||
|
const getProperty = (object: unknown, propertyName: string) => {
|
||
|
if (typeof object !== 'object' || object === null) {
|
||
|
throw new Error(`Cannot access property ${JSON.stringify(propertyName)} on non-object`);
|
||
|
}
|
||
|
|
||
|
if (!(propertyName in object)) {
|
||
|
throw new Error(`No such property ${JSON.stringify(propertyName)} in object`);
|
||
|
}
|
||
|
|
||
|
return object[propertyName as keyof object];
|
||
|
};
|
||
|
|
||
|
export default getProperty;
|
||
|
|