signal-desktop/ts/util/getOwn.ts
2022-06-03 14:07:51 -07:00

11 lines
303 B
TypeScript

// Copyright 2020-2022 Signal Messenger, LLC
// 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;
}