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

comcom

v0.2.5

Published

Module containing common classes and helper functions for Javascript

Downloads

36

Readme

Complyify Commons for Javscript

Module containing common classes and helper functions for Javascript/Node.js applications.

Code Climate Test Coverage

Installation

npm install comcom --save

Building

This module is written in ES6 but can be compiled to ES5 with Babel for wider compatibility.

npm run compile

Ensure you run the compile command after running npm install which will load Babel and other development dependancies.

Getting Started

Simply import or require one or more classes from this module to make them available in your code.

ES6

import { SomeClass } from 'comcom';

ES5

var SomeClass = require('comcom').SomeClass;

API Reference

Classes

Configurable

A class that defines an object that must have a config object as a local property.

Constructor

var name = 'SomeName';
var type = 'SomeType';
var config = { configKey: 'someValue' };
var configurable = new Configurable(name, type, config);

| Parameter | Description | Constraints | | --- | --- | --- | | name | user-friendly name for the configurable object, mostly for showing in logs | must not be undefined, null, nor an empty string | | type | user-friendly type for the configurable object, mostly for show in logs | must not be undefined, null, nor an empty string | | config | instance configuration object | must be an object or undefined/null |

Executable

A class designed to provide the scaffolding for an asynchronous job.

Constructor

var name = 'SomeName';
var config = { configKey: 'someValue' };
var log = bunyan.createLogger({name: 'myAppName'});
var executable = new Executable(name, config, log);

| Parameter | Description | Constraints | | --- | --- | --- | | name | user-friendly name for the executable, mostly for showing in logs | must not be undefined, null, nor an empty string | | config | instance configuration object | must be an object or undefined/null | | log | a Bunyan logger object | required |

Methods

| Method | Description | Returns | | --- | --- | --- | | exec() | Runs the executable by calling the implementing class' execImpl() method | a promise that resolves to the eventual returned value of execImpl() |

Named

A class that defines an object that must have name as a local property.

Constructor

var name = 'SomeName';
var named = new Named(name);

| Parameter | Description | Constraints | | --- | --- | --- | | name | user-friendly name for the object, mostly for showing in logs | must not be undefined, null, nor an empty string |

NamedTyped

A class that defines an object that must have name and type as local properties.

Constructor

var name = 'SomeName';
var type = 'SomeType';
var namedTyped = new NamedTyped(name, type);

| Parameter | Description | Constraints | | --- | --- | --- | | name | user-friendly name for the object, mostly for showing in logs | must not be undefined, null, nor an empty string | | type | user-friendly type for the object, mostly for show in logs | must not be undefined, null, nor an empty string |

Service

A class designed to provide the scaffolding for a persistent service or daemon.

Usage

const NAME = 'SomeName';
const CONFIG = { configKey: 'someValue' };
const LOG = bunyan.createLogger({name: 'myAppName'});
let MyService = class extends Service {
  constructor() {
    super(NAME, CONFIG, LOG);
  }
}
let svc = new MyService();
svc.start();

| Parameter | Description | Constraints | | --- | --- | --- | | name | user-friendly name for the service, mostly for showing in logs | must not be undefined, null, nor an empty string | | config | instance configuration object | must be an object or undefined/null | | log | a Bunyan logger object | required |

Methods

| Method | Description | Returns | | --- | --- | --- | | start() | Starts the service by calling the implementing class' startImpl() method | a promise that resolves when startup is complete | | stop() | Stops the service by calling the implementing class' stopImpl() method | a promise that resolves when shutdown is complete | | restart() | Convenience method to call stop(), wait for completion, then call start() | a promise that resolves upon completion of the restart | | use() | Register a service adapter or command/query/event handler | undefined |

License

This module is made available under the terms of the GNU Affero General Public License v3.0 (see LICENSE).