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

@beyond-js/config

v1.0.3

Published

The `@beyond-js/config` package allows for a modular and dynamic approach to managing project configurations. One of its key features is its ability to handle properties in two ways: as an inline data object or as a reference to an external file. From `@b

Downloads

17

Readme

@beyond-js/config

The @beyond-js/config package allows for a modular and dynamic approach to managing project configurations. One of its key features is its ability to handle properties in two ways: as an inline data object or as a reference to an external file. From @beyond-js/config's perspective, each branch of the configuration is an independent, dynamic property. The package's internal logic is responsible for resolving the value of each property, whether it comes from an inline object or an external file. This process is dynamic and hot-reloading, reacting to changes via the change event.


Configuration Flexibility

The package offers two primary methods for structuring your configuration, which can be freely combined.

1. Inline Configuration

For smaller projects or simple configuration branches, you can define all properties directly within a single config.json file. Here, the project property is an object containing all its information inline.

config.json

{
	"project": {
		"name": "My Awesome Project",
		"version": "1.0.0",
		"author": "BeyondJS"
	},
	"modules": [
		{
			"name": "core",
			"version": "1.0.0"
		},
		"modules/ui.json"
	]
}

In this example, the package resolves the project property from the inline object, while it resolves the modules/ui.json property by reading and parsing the external file.


2. Modular Configuration with References

When a configuration grows, you can modularize it by moving branches to external files. For instance, the project property can be moved to a separate file, and the main config.json file would simply reference it as a string.

config.json

{
	"project": "project/details.json",
	"modules": [
		{
			"name": "core",
			"version": "1.0.0"
		},
		"modules/ui.json"
	]
}

project/details.json

{
	"name": "My Awesome Project",
	"version": "1.0.0",
	"author": "BeyondJS"
}

The package transparently handles both scenarios for the developer. When a property's value is a string, it's treated as a path to an external configuration file, which is then read, parsed, and used as the final value for that property.


Developer Usage

A developer interacts with the configuration properties via the Config instance. Because the processing is asynchronous, the underlying @beyond-js/dynamic-processor library guarantees that properties are ready before being accessed and that the application can react to any changes.

const { Config } = require('@beyond-js/config');
const path = require('path');

const config = new Config(path.join(__dirname, 'config-project'), {
	'/project': 'object',
	'/modules': 'array',
	'/modules/children': 'object'
});

config.data = 'config.json';

// Wait for the project property to be ready before accessing its value
const project = config.get('project');
await project.ready;
console.log(project.value.name); // 'My Awesome Project'

// Listen for changes on the project property
project.on('change', () => {
	console.log('Project configuration has changed!');
	console.log('New project name:', project.value.name);
});

This approach eliminates the need for manual file loading and parsing, while the built-in reactivity ensures that any changes to the configuration files are automatically detected and processed.


Configuration Modularity: Branches and Paths

The @beyond-js/config package allows for configuration to be modularized by moving branches to external files for better organization. It is important to note that a branch can be specified in an independent folder. This allows for advanced flexibility in structuring complex configurations, as the system is capable of resolving file paths coherently even in nested branches.

Consider an example where the main configuration defines a list of modules, and each module has its own configuration files in a separate folder.

File structure:

.
├── config.json
└── modules/
    ├── invoices/
    │   ├── module.json
    │   ├── settings.json
    │   └── ...module files
    └── users/
        ├── module.json
        ├── settings.json
        └── ...module files

config.json

{
	"modules": ["modules/users/module.json", "modules/invoices/module.json"]
}

modules/users/module.json

{
	"name": "users",
	"version": "1.0.0",
	"settings": "settings.json"
}

modules/users/settings.json

{
	"permissions": ["read", "write"]
}

In this case, when config.json is processed, the modules property is read as an array. Each array element points to an external file. For the "modules/users/module.json" element, the package reads the file and its content becomes the value of the property. Inside this object, the settings property is in turn a reference to an external file. Since the path context is now modules/users/, the settings.json file is resolved to modules/users/settings.json. This way, each module can have its own configuration file structure without path conflicts.


Modularity with the path Property

The @beyond-js/config package also considers the path property within a configuration object to redefine the path root for that branch. This allows for greater flexibility in structuring the configuration, as nested paths can be relative to the location of a configuration file rather than the project root.

For example, config.json could use the path property to set a new root:

config.json

{
	"path": "modules",
	"modules": ["users/module.json", "invoices/module.json"]
}

In this case, the system first sets the new configuration root to the modules folder. From there, the references to the modules ("users/module.json" and "invoices/module.json") are resolved relative to modules, rather than the project root. This simplifies the main configuration and improves project organization.


ConfigCollection

The ConfigCollection class is designed to handle collections of configurations, such as a list of applications or modules. This class simplifies the management of configuration arrays by treating them as a dynamic, reactive collection. For detailed information on how to use ConfigCollection, refer to the collection documentation.