hierophant

1.0.1 • Public • Published

Hierophant 🕍

Hierophant is a minimalist dependency injection container for the Phantomaton AI. It provides a simple way to manage providers, decorators, and aggregators using symbols as identifiers.

Purpose 🧠

Phantomaton needs a flexible way to manage dependencies between its various components and services. Hierophant provides this through a lightweight container that can:

  • Register and resolve providers
  • Support decoration patterns
  • Enable aggregation strategies
  • Handle dependency injection

Usage 🪄

First, import the container factory:

import hierophant from 'hierophant';

Create extension points using symbols:

const log = Symbol('log');
const converse = Symbol('converse');

Then create a container and register components:

const container = hierophant();

// Register a simple provider
container.provide(log, () => console.log);

// Register a provider with dependencies
container.provide(converse, container.depend([log], (logger) => (messages) => {
  logger(messages);
  return `Got ${messages.length} messages`;
}));

// Use the functionality
const [logger] = container.resolve(log);
const [converseFn] = container.resolve(converse);

converseFn(['Hello!']); // Logs then returns response

Batch Installation 🔮

For more complex setups, you can install multiple components at once:

container.install({
  providers: [
    { 
      symbol: log, 
      dependencies: [], 
      factory: () => console.log 
    },
    {
      symbol: converse,
      dependencies: [log],
      factory: (logger) => (messages) => {
        logger(messages);
        return `Got ${messages.length} messages`;
      }
    }
  ]
});

Contributing 🦄

We welcome contributions to the Hierophant project! If you have any ideas, bug reports, or pull requests, please feel free to submit them on the Hierophant GitHub repository.

License 🔒

Hierophant is licensed under the MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i hierophant

Weekly Downloads

29

Version

1.0.1

License

MIT

Unpacked Size

8.75 kB

Total Files

5

Last publish

Collaborators

  • phantomaton