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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rbxts/objecat

v1.1.1

Published

Yet Another Way To Create Instances

Downloads

3

Readme

Objecat is a very simple library coming with only three functions and one variable. It is used to create Instances in a less verbose way. To put it simply, making an Instance on Roblox and setting its properties is ugly. Objecat makes it less ugly.

Objecat uses standard naming conventions when it comes to properties and methods. Property names and method names are in camelCase. This currently does not apply to after it is created, only on creation, this may be changed in a future release.

Installation

Objecat can be installed in these ways:

Installation Using Wally

To install using Wally, you just need to add the following to your wally.toml file:

[dependencies]
Objecat = "alexinite/[email protected]"

Then run wally install in your terminal.

Installation Using NPM

If you're using roblox-ts, this will be the preferred way to download it. It's worth noting that using the roblox-ts package that it is fully type-safe. This currently is not in effect for events, but will be in a future release.

npm install @rbxts/objecat

Usage

Objecat has three main exports: create(), event(), and children. These are all documented below.

create(className: string, properties?: table): Instance

create<T extends keyof CreatableInstances>(className: T, properties?: ObjecatWritableProperties<Instances[T]>): Instances[T]

create() is the main function of Objecat. Used for creating instances, in general this should be the only top-level function you use from Objecat, the other two are used to define properties and events when creating instances.

local Objecat = require(path.to.objecat.package)
local create = Objecat.create

local part = create("Part", {
	anchored = true,
	position = Vector3.new(0, 5, 0),
	parent = workspace
})

part.Anchored = false -- This may be changed in the future to be lowercase
import { create } from "@rbxts/objecat";

const part = create("Part", {
	anchored: true,
	position: new Vector3(0, 5, 0),
	parent: game.Workspace,
});

part.Anchored = false;

event(str: string): string

event<K extends string>(str: K): \_event${K}__``

event() just takes a string and returns a string to be used as a symbol for an event. This is used to define events when creating instances. When destroying an Instance created by Objecat, any event will be automatically disconnected for you.

local event = Objecat.event

local part = create("Part", {
	[event "touched"] = function (otherPart)
		print("Touched by " .. otherPart.Name .. "!")
	end
})

-- This may be changed in the future to support event()
part.ChildAdded:Connect(function (child)
	print("Child added!")
end)
import { create, event } from "@rbxts/objecat";

const part = create("Part", {
	[event("touched")] = (otherPart: BasePart) => {
		print(`Touched by ${otherPart.Name}!`);
	},
});

part.ChildAdded.Connect((child) => {
	print("Child added!");
});

children: string

children: "__children__"

children is a string that just refers to a symbol for adding children to an Instance being created with Objecat. When destroying the parent Instance, all children will be automatically destroyed for you, including their events.

Children can either be an Array (or table) of Instances, or a single Instance.

local children = Objecat.children

local part = create("Part", {
	[children] = {
		create("PointLight")
	}
})
import { create, children } from "@rbxts/objecat";

const part = create("Part", {
	[children]: [
		create("PointLight")
	],
});

clone(instance: Instance, properties?: table): Instance

clone<T extends Instance>(instance: T, properties?: ObjecatWritableProperties<T>): T

clone() is a function that clones an Instance and returns the clone. If properties.parent is not set, it will default to the parent of the Instance being cloned. The properties table works the same as the create() method. Also, when making a clone it will automatically bind all descendants to a clean-up task.

local clone = Objecat.clone

local part = create("Part", {
	anchored = true
})

local newPart = clone(part, {
	color = Color3.fromRGB(255, 0, 0)
})
import { create, clone } from "@rbxts/objecat";

const part = create("part", {
	anchored: true,
});

const newPart = clone(part, {
	color: Color3.fromRGB(255, 0, 0),
});

Current Roadmap

  • [ ] Make the create() method behave more like Elttob's New() method for Fusion.
  • [ ] Maybe add support for after a Instance is created via create() to be able to define properties, children, and events as if you were still in the create() function.
  • [ ] Add self to events created with event() so you can access the Instance that the event is attached to.
  • [ ] Somehow make event() know what events can and can't be created?