signal-desktop/ts/util/getOwn.ts

10 lines
277 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
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;
2020-11-04 19:56:49 +00:00
}