@nerdware/ddb-single-table
Version:
A schema-based DynamoDB modeling tool, high-level API, and type-generator built to supercharge single-table designs!⚡
12 lines (11 loc) • 420 B
JavaScript
import { hasKey } from "@nerdware/ts-type-safety-utils";
/**
* A type-guard which returns a boolean indicating whether the following are all true:
*
* 1. `obj` is a truthy object
* 2. `obj` has the provided `key` as an own-property
* 3. `obj[key]` is neither `null` nor `undefined`
*/
export const hasDefinedProperty = (obj, key) => {
return hasKey(obj, key) && obj[key] !== null && obj[key] !== undefined;
};