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

mu-manager

v0.2.2

Published

A simple object tagged object management system.

Downloads

10

Readme

Mu-Manager

A simple object management system.

Usage

Mu-Manager is an object management system. It can also act as an object factory as well when configured.

Simple Example

In it's simplist use, Mu-Manager acts as a way to easily manage and call on objects, though it can handle other datatypes as well.

const Manager = require('mu-manager');
const tasks = new Manager();

// register a new 'task'
tasks.register('first-task', {
  name: 'foobar',
  description: 'Do some console logging.',
  func: () => console.log('This is a task!')
});

// Later, we want to reference the task in our code and run our function.
console.log(tasks.get('first-task').name) // 'foobar'
tasks.get('first-task').func() // Logged to console: 'This is a task!'

Object Factory Example

Say we have a pre-established class for a task. Instead of feeding the manager an object literal, it can create a new instance of a class. When defining a new instance of mu-manager, pass in a create method, which is a function that accepts an array of arguments.

const Manager = require('mu-manager');

// First we're going to create a simple class to work with.
/** Create a new Task */
class Task {
  constructor({name, description, func}){
    this.name = name;
    this.description = description;
    this.func = func;
  }

  /** Logs to the console */
  doSomething() {
    console.log('Did something!');
  }
}

// Next we create a new instanc of the mu-manager, defining the create
// method, using our `task` class.
tasks = new Manager({
  // The create method is passed an array of arguments.  I'm using
  // destructuring here to grab the first.
  create: [options={}] => new Task(options)
})

// Create our new object  This creates and stores a new 'todo' object under
// the task list.
tasks.create('first-task', {
  name: 'foobar',
  description: 'Do some console logging.',
  func: () => console.log('This is a task!')
});

// Later, we want to reference the task in our code and run our function.
console.log(tasks.get('first-task').name) // 'foobar'
tasks.get('first-task').func() // Logged to console: 'This is a task!'

// But we can also call methods attached to the object.
tasks.get('first-task').doSomething() // Logged to console: 'Did Something!'