Skip to main content
Module

x/nameable/deps.ts>props

Cross-check whether it can be used as a package name or domain name
Latest
variable props
import { props } from "https://deno.land/x/nameable@v1.1.0-beta.4/deps.ts";

Returns a function that when supplied an object returns the indicated property of that object, if it exists.

Examples

Example 1

props('x', { x: 'hello' }) // 'hello'
props(1, { 1: 100 }) // 100
props('x', {}) // undefined

type

<T extends string | number, U extends Record<PropertyKey, unknown>>(val: T, obj: U) => U extends Record<T, unknown> ? U[T] : undefined