npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rbxts/rblx-object-utils

v1.0.3

Published

RblxObject is a utility library for Roblox-TS (TypeScript for Roblox) that provides robust functions for working with objects, arrays, sets, maps, and tables in a consistent and type-safe manner. This library simplifies common object operations such as it

Readme

RblxObject

RblxObject is a utility library for Roblox-TS (TypeScript for Roblox) that provides robust functions for working with objects, arrays, sets, maps, and tables in a consistent and type-safe manner. This library simplifies common object operations such as iteration, deep copying, comparison, and serialization.


Table of Contents


Introduction

RblxObject provides functions that mimic and extend JavaScript's Object methods but are fully compatible with Roblox tables and TypeScript types. It allows developers to safely interact with objects, arrays, sets, and maps without relying on external dependencies like Object.keys() or Object.assign().

Key features:

  • Type-safe operations on objects and tables
  • Shallow and deep copy utilities
  • Deep equality comparison
  • Conversion between entries and objects
  • JSON serialization compatible with Roblox

Installation

Installing with Npm:

npm i @rbxts/rblx-object-utils

Installing with bun:

bun i @rbxts/rblx-object-utils

Usage:

import RblxObject from "@rbxts/rblx-object-utils";

API Reference

keys

keys(o: ReadonlyArray<T>): number[];
keys(o: ReadonlySet<T>): T[];
keys(o: ReadonlyMap<K, V>): K[];
keys(o: object): Array<keyof typeof o>;

Returns the keys of an object, array, set, or map.

Example:

const arr = [10, 20, 30];
const obj = { name: "Alice", age: 25 };
const set = new Set(["x", "y", "z"]);

RblxObject.keys(arr); // [0, 1, 2]
RblxObject.keys(obj); // ["name", "age"]
RblxObject.keys(set); // ["x", "y", "z"]

values

values(o: ReadonlyArray<T>): Array<NonNullable<T>>;
values(o: ReadonlySet<T>): Array<true>;
values(o: ReadonlyMap<K, V>): Array<NonNullable<V>>;
values(o: object): Array<NonNullable<T[keyof T]>>;

Returns an array of values from an array, set, map, or object.

Example:

const arr = [10, 20, 30];
const obj = { name: "Alice", age: 25 };
const map = new Map([["id", 1], ["score", 100]]);

RblxObject.values(arr); // [10, 20, 30]
RblxObject.values(obj); // ["Alice", 25]
RblxObject.values(map); // [1, 100]

entries

entries(o: ReadonlyArray<T>): Array<[number, NonNullable<T>]>
entries(o: ReadonlySet<T>): Array<[T, true]>
entries(o: ReadonlyMap<K, V>): Array<[K, NonNullable<V>]>
entries(o: object): Array<[keyof T, NonNullable<T[keyof T]>]>;

Returns key/value pairs of an array, set, map, or object.

Example:

const obj = { name: "Alice", age: 25 };
RblxObject.entries(obj); // [["name", "Alice"], ["age", 25]]

assign

assign(target: A, ...sources: Array<B>): A & B;

Copies enumerable properties from one or more source objects to a target object. Returns the modified target.

Example:

const target = { a: 1 };
const source = { b: 2, c: 3 };
RblxObject.assign(target, source); // { a: 1, b: 2, c: 3 }

copy

copy(o: T): T;

Returns a shallow copy of an object.

Example:

const original = { x: 10, y: 20 };
const cloned = RblxObject.copy(original);
cloned.x = 50;
// original.x remains 10

deepCopy

deepCopy(o: T): DeepWritable<T>;

Returns a deep copy of an object, recursively copying nested tables and arrays.

Example:

const obj = { a: { b: 10 } };
const clone = RblxObject.deepCopy(obj);
clone.a.b = 20;
// obj.a.b remains 10

deepEquals

deepEquals(a: object, b: object): boolean;

Checks if two objects or tables are deeply equal, recursively comparing nested tables.

Example:

const a = { x: { y: 5 } };
const b = { x: { y: 5 } };
RblxObject.deepEquals(a, b); // true

deepFreeze

deepFreeze(object: T): DeepReadonly<T>

Deep freezes and returns an original frozen object.

Example:

const object = {
    foo: "foo",
    bar: "bar",
    tar: {
        foo: "oof"
    }
}

const frozenObject = RblxObject.deepFreeze(object);
frozenObject.foo = "bar" // Cannot write; foo property is read-only!
frozenObject.tar = { bar: "bar" } // Cannot write; tar property is read-only!

toString

toString(data: unknown): string;

Converts a value to a JSON string, or returns [Object: type] if conversion fails.

Example:

RblxObject.toString({ name: "Alice" }); // '{"name":"Alice"}'

isEmpty

isEmpty(o: object): boolean;

Returns true if an object has no enumerable properties, otherwise false.

Example:

RblxObject.isEmpty({}); // true
RblxObject.isEmpty({ a: 1 }); // false

fromEntries

fromEntries<K extends PropertyKey, V>(entries: ReadonlyArray<readonly [K, V]>): Record<K, V>;

Creates an object from a list of key/value pairs.

Example:

const entries: [string, number][] = [["a", 1], ["b", 2]];
const obj = RblxObject.fromEntries(entries); // { a: 1, b: 2 }

Examples

import RblxObject from "@rbxts/rblx-object-utils";

// Working with objects
const obj = { name: "Alice", age: 25 };
const keys = RblxObject.keys(obj); // ["name", "age"]
const values = RblxObject.values(obj); // ["Alice", 25]
const entries = RblxObject.entries(obj); // [["name", "Alice"], ["age", 25]]

// Deep copy
const nested = { a: { b: 10 } };
const deepClone = RblxObject.deepCopy(nested);

// Deep freeze
const deepFrozen = RblxObject.deepFreeze(obj);
obj.name = "Mark" // Errors because the property is read only.

// Equality check
const equal = RblxObject.deepEquals({ x: 1 }, { x: 1 }); // true

// From entries
const newObj = RblxObject.fromEntries([["foo", 42]]); // { foo: 42 }