signal-desktop/ts/util/getOwn.ts
2023-01-19 11:56:02 -08:00

9 lines
277 B
TypeScript

// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
export function getOwn<TObject extends object, TKey extends keyof TObject>(
obj: TObject,
key: TKey
): TObject[TKey] | undefined {
return Object.hasOwn(obj, key) ? obj[key] : undefined;
}