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

nali

v1.1.4

Published

a DI service registry

Downloads

66

Readme

nali

a service registry for dependency injection and application composition

js-standard-style Dependency Status Circle CI

usage

const nali = require('nali')

// we can register services
// type Service: (...) => Instance
// Services are functions with
// optional dependency names as parameters
// and which return an initialized instance of itself
// the return value can be a Promise or a Value
nali.register({
  config: function () {
    return P
    conn_str: 'http://foo.bar'
  },
  db: function (config) {
    return Doodaboos.connect(config.conn_str)
  
  })

// we can resolve an instance of our `db` service:

nali.resolve('db').then(function (db) {
  // now we can do stuff with our db service
})

nali will fetch or lazily instantiate arbitrary trees of service dependencies.

api

nali(name: String) => service:any

(alias: nali.fetch)

Synchronously fetch a service instance

Can also be used to asynchronously resolve multiple dependencies, for example:

nali(function (db, log, sessions, webService) {
  // now we have all the things
})

nali.resolve(name: String) => Promise<service: Any>

Asynchronously resolve an instance of a service, lazily instantiating any dependencies if necessary

nali.registerInstance(name: String, instance: Object) => void

deprecated use nali.register('name', () => instance) instead

nali.registerService(name: String, service: Service) => void

deprecated use nali.register('name', service) instead

Service Dependencies

DI works similar to Angular. Service init functions state the names of their dependencies as parameter names, which are parsed out when the Service is registered. They are not called with new or with any particular this context.

Return a Promises/A+ promise if you need to asynchronously instantiate a service

Resolution algorithm

Work in progress.

Try get local instance Try get new instance of local service Try get parent instance Try get new instance of parent service Etc

not implemented

  • scopes
  • disposing instances / lifecycle management
  • anything else

installation

$ npm install nali

running the tests

From package root:

$ npm install
$ npm test

contributors

license

MIT. (c) MMXV AgileMD. See LICENSE.md