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/conf

v0.0.1

Published

Instance based configuration management.

Downloads

4

Readme

Conf is a simple module to get and set variables from a Roblox Configuration instance.

Why Conf?

Conf combines keys and types to allow multiple ValueBase instances to exist under the same name, if they hold separate types.

This means that the following code:

conf.set('apples', true);
conf.set('apples', 10);

will result in the following Roblox tree:

Configuration
├── BoolValue "apples": true
└── NumberValue "apples": 10

These can be written to and read from individually, but they will both be deleted together with:

conf.delete('apples');

Introduction

Existing Values

In Conf, each ValueBase instance is referred to as a "Store". At instantiation, all existing stores are registered, meaning a reference of them is saved into the Conf instance.

Existing stores can be addressed via their instance name, which becomes their key. New stores are created when a new key is written to.

Any changes in the Roblox tree after instantiation are not automatically reflected, but this can be enabled with.

conf.watchTree();

Obtaining Values

When obtaining values in Conf, you must specify what you are expecting.

This is important to maintain type safety and keys associated with values of multiple types.

conf.get('apples', 'number');

If you would like to prevent the undefined result, in the case of the value not existing, you can use the ensure method.

conf.ensure('apples', 5);

In this case, Conf infers what type of value you are trying to obtain, and will address the correct store. If no store exists, or the store holds no value (in case of ObjectValue), the fallback will be returned. When using the fallback value, no store is created.

Setting Values

When setting values in Conf, the type of value you are setting is automatically inferred, and the appropriate store is created, if it does not exist already.

conf.set('apples', 10); // NumberValue store is created, if it doesn't exist
conf.set('apples', true); // BoolValue store is created, if it doesn't exist

Deleting Values

When deleting values, the key itself is deleted. This means that if multiple stores exist under the same key, they are all deleted.

conf.set('apples', 10);
conf.set('apples', true);

conf.delete('apples'); // Deletes both the Numbervalue and BoolValue store

Instance Tree Synchronization

Automatic synchronization can be enabled with:

conf.watchTree();

and disabled with:

conf.ignoreTree();

Manual synchronization can be executed with:

conf.syncTree();

Automatic sync does not reflect name changes of stores after they have been added. This means that if a store instance changes it's name, it's key within Conf will still be the original name.

This issue persists until a manual sync is executed, because a manual sync will re-register all stores.