open-index/open-npm huggingface dataset:
npm package: @leisurelink/service-inject
Description: A service-injection utility for nodejs; reduces the need for boostrap coordination among modules.
Author: Phillip Clark
Latest version: 0.1.1

# service-inject [![Circle CI](https://circleci.com/gh/LeisureLink/service-inject.svg?style=svg)](https://circleci.com/gh/LeisureLink/service-inject)

A service-injection utility for nodejs; reduces the need for boostrap coordination among modules.

## What

`service-inject` exports a single class, [`Injector`](#user_content_injector_class).

`Injector` can be thought of as an inversion of control container. It enables modules to contribute _well-known_ services and to register callbacks that will be invoked by the injector _as-soon-as_ the callback's dependencies can be injected.

### Basics

**Consuming**

```javascript
var format = require('util').format;
var injector = require('service-inject')

// Name the dependencies
// here =>      v            v         v
injector.when(['LoginUtil', 'Logger', 'nameFormatter'],

// They will be injected
// here =>  v       v       v
  function (logins, logger, formatter) {

    function recordLogin(user) {
      logger.info(format('User logged in: %s', formatter(user)))
    }

    logins.on('user-login', recordLogin);
  })
```

**Contributing**

```javascript
var injector = reqiure('service-inject')

function nameFormatter(party) {
  var res;
  if (!party) {
    return '-nobody-'
  }
  // If the party has a 'name' property, use that; probably an entity of some sort.
  if (party.name) {
    return party.name
  }
  // if the party looks like a person, format name as last, first, middle
  if (party.lastName) {
    res = party.lastName
    if (party.firstName) {
      res = res.concat(', ', party.firstName)
      if (party.middleNames) {
        res = res.concat(', ', party.middleNames)
      }
    }
    return res
  }
  return '-un-named-'
}

injector.set('nameFormatter', nameFormatter)
```

**Well-known Names**

The _services_ you choose to inject are referenced by _well-known_ name. These names are agreed upon by your application and have no meaning elsewhere. The values you supply to the injector are opaque; it doesn't know or care about their meanings.


## Injector Class

* `get` - gets a registered service by name.
* `set` - sets a registered service by name.
* `has` - determines if there is a registered service by the specified name.
* `when` - specifies a list of services and a callback to invoke when all of the specified services can be fulfilled.
* `capture` - specifies a list of services to be captured for later use.
* `inject` - specifies a list of services to be injected immediately into a specified callback.
* `listUnfulfilled` - returns a list of services that have not been registered, but for which there are registered callbacks.

## [License (MIT)](https://github.com/LeisureLink/service-inject/raw/master/LICENSE)
npm package: @leisurelink/skinny-event-loggins
Description: Simple package that exposes a logger class for emitting events upon log methods. Works well with @leisurelink/skinny-loggins
Author: LeisureLink Tech
Latest version: 1.0.0

# @leisurelink/skinny-event-loggins

Simple event-based logger designed to be easily plugged into a different logging framework.

## Design goals

No dependencies, pure emit of log events, simple to use.

## Sample Usage

```javascript
const Logger = require('@leisurelink/skinny-event-loggins');
const log = Logger('my-namespace');

const skinny = new (require('@leisurelink/skinny-loggins'));
skinny.consumeFrom(log);

// - or -
const realLogger = require('winston');

log.on('log', function(ev){
  realLogger[ev.kind](ev.namespace + ' - ' + ev.message, ev.err);
});

//...
log.silly('Extremely detailed log message', result);
```

## API

### Logger(namespace, eventSink)
Create a logger with the specified namespace (optional) and the specified event sink (optional). Returns an object with these methods:

### [silly|debug|verbose|info|warn|error(message, err)
Log a message of the specified level with optional error

### on(event, handler)
Subscribes to events from the logger.

### withNamespace(namespace, separator)
Creates a child logger with the specified namespace. If the current logger has a namespace, the new namespace is created to look like 'old:new'. Use the `separator` parameter to specify a different separator than ':'. If `separator === false`, then the new namespace will not include the old.