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

micon

v1.2.7

Published

Dependency injector

Downloads

33

Readme

Dependency injector, assembles application.

Registering, getting and setting components.

app.register 'component', -> 'some component'
console.log app.component
# => some component

app.component = 'another component'
console.log app.component
# => another component

Dependencies can be specified implicitly.

app.register 'a', ->
  console.log 'initializing a'
  'a'
app.register 'b', ->
  console.log 'initializing b'
  "#{app.a} b"

console.log app.b
# => initializing b
# => initializing a
# => a b

Or explicitly. The only difference with implicit approach is that explicit declaration will resolve circular dependencies (implicit approach will fail).

app.register 'a', ->
  console.log 'initializing a'
  'a'
app.register 'b', dependencies: ['a'], ->
  console.log 'initializing b'
  "#{app.a} b"

console.log app.b
# => initializing a
# => initializing b
# => a b

Component lifecycle callbacks.

app.register 'component', ->
  console.log 'initialization'
  'some component'
app.before 'component', -> console.log 'before initialization'
app.after 'component', -> console.log 'after initialization'

app.component
# => before initialization
# => initialization
# => after initialization

Scopes.

app.register 'params', scope: 'request', -> {}

startFiberSomehow ->
  app.scope 'request', ->
    app.params.key = 'some value'
    console.log app.params
    # => {key: 'some value'}

Scope callbacks.

app.beforeScope 'request', -> console.log 'before'
app.afterScope 'request', -> console.log 'after'

startFiberSomehow ->
  app.scope 'request', ->
  # => before
  # => after

Require files in directory, provide watch: true option to watch for changes and reload.

# /app/controllers/SomeController.coffee
# app.SomeController = 'some controller'

app.requireDirectory '/absolutePath/app/controllers', watch: true

console.log app.SomeController
# => some controller

Limitations.

  • Fiber and custom scopes will not work in browser because browsers doesn't support fibers.
  • Use app.get componentName instead of app.componentName in old browsers not supporting getters and setters syntax. Use set for setting components.

Copyright (c) Alexey Petrushin, http://petrush.in, released under the MIT license.