This package has been archived, and as such it is read-only.
@ph/reflection@1.0.5Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
Works with
•JSR Score100%•This package works with Node.js, Deno, BunIt is unknown whether this package works with Cloudflare Workers, Browsers




Publisheda year ago (1.0.5)
Type representing the target object type
Reflection
A lightweight TypeScript reflection utility for accessing object properties, including private and static members.
Installation
import { Reflection } from "@ph/reflection";
Features
- Access instance and static properties
- Type-safe property access
- Simple and intuitive API
- Support for private members
- Zero dependencies
- Lightweight implementation
Usage
Basic Example
import { Reflection } from "@ph/reflection"; class User { private static name: string; public readonly age: number; constructor(name: string, age: number) { User.name = name; this.age = age; } } const user = new User("John", 30); const reflection = Reflection.of(user); console.log(reflection.getPropertyValue<string>("name")); // Output: "John" console.log(reflection.getPropertyValue<number>("age")); // Output: 30
Advanced Usage
import { Reflection } from "@ph/reflection"; class Database { private static connection: string; private config: Record<string, unknown>; constructor(config: Record<string, unknown>) { Database.connection = "mysql://localhost:3306"; this.config = config; } public static setConnection(url: string): void { Database.connection = url; } } const db = new Database({ timeout: 5000 }); Database.setConnection("postgres://localhost:5432"); const reflection = Reflection.of(db); console.log(reflection.getPropertyValue<string>("connection")); // Output: "postgres://localhost:5432" console.log(reflection.getPropertyValue<Record<string, unknown>>("config")); // Output: { timeout: 5000 }
License
MIT
Built and signed on
GitHub Actions
Add Package
deno add jsr:@ph/reflection
Import symbol
import * as reflection from "@ph/reflection";
Import directly with a jsr specifier
import * as reflection from "jsr:@ph/reflection";
Add Package
pnpm i jsr:@ph/reflection
pnpm dlx jsr add @ph/reflection
Import symbol
import * as reflection from "@ph/reflection";
Add Package
yarn add jsr:@ph/reflection
yarn dlx jsr add @ph/reflection
Import symbol
import * as reflection from "@ph/reflection";
Add Package
vlt install jsr:@ph/reflection
Import symbol
import * as reflection from "@ph/reflection";
Add Package
npx jsr add @ph/reflection
Import symbol
import * as reflection from "@ph/reflection";
Add Package
bunx jsr add @ph/reflection
Import symbol
import * as reflection from "@ph/reflection";