Skip to main content
Module

x/is_valid_package_name/deps.ts>props

Validation for package name
Latest
variable props
import { props } from "https://deno.land/x/is_valid_package_name@v1.0.0/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