signal-desktop/ts/util/getOwn.ts

12 lines
298 B
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2020 Signal Messenger, LLC
2020-11-04 19:56:49 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import { has } from 'lodash';
export function getOwn<TObject extends object, TKey extends keyof TObject>(
obj: TObject,
key: TKey
): TObject[TKey] | undefined {
return has(obj, key) ? obj[key] : undefined;
}