Installation & Quick Start
How to install @visulima/object and get started quickly
Last updated:
Installation & Quick Start
Installation
npm install @visulima/objectpnpm add @visulima/objectyarn add @visulima/objectbun add @visulima/objectImport
import {
getProperty,
setProperty,
deleteProperty,
hasProperty,
pick,
omit,
deepKeys,
isPlainObject
} from "@visulima/object";Quick Start Examples
Access Nested Properties
import { getProperty, setProperty } from "@visulima/object";
const data = { user: { profile: { name: "Alice" } } };
// Get
const name = getProperty(data, "user.profile.name"); // "Alice"
// Set
setProperty(data, "user.profile.age", 30);Filter Objects
import { pick, omit } from "@visulima/object";
const user = { id: 1, name: "Alice", password: "secret", email: "alice@example.com" };
// Keep only specific fields
const publicUser = pick(user, ["id", "name", "email"]);
// Remove sensitive fields
const safeUser = omit(user, ["password"]);Check Property Existence
import { hasProperty } from "@visulima/object";
const config = { api: { key: "abc123" } };
if (hasProperty(config, "api.key")) {
console.log("API key configured");
}TypeScript Support
Full TypeScript support with type inference:
import { getProperty, pick } from "@visulima/object";
interface User {
id: number;
profile: {
name: string;
settings: {
theme: "light" | "dark";
};
};
}
const user: User = { /* ... */ };
// Type-safe access
const theme = getProperty(user, "profile.settings.theme");
// Type: "light" | "dark"
// Type-safe filtering
const filtered = pick(user, ["id", "profile.name"]);