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

electrolyte-assembly-mapper

v1.0.0

Published

Assembly mapper and loader for Electrolyte

Downloads

1

Readme

electrolyte-assembly-mapper

Build Status

An Assembly Mapper and Loader for the Electrolyte DI/IoC Container in Node.js.

This npm module can be used to map any dependency loaded via Electrolyte to another dependency, like a stub instead of the real implementation.

Installation

npm install electrolyte-assembly-mapper --save

Use case

Given this example web project structure:

app/
  areas/
    homepage/
      controller.js
  lib/
    content-client/
      index.js
      stub.js
  bootstrap.js
  router.js
index.js
package.json

In app/areas/homepage/controller.js you require the content-client dependency:

module.exports = factory
module.exports['@singleton'] = true
module.exports['@require'] = ['lib/content-client']

function factory (content) {
  return (req, res) => {
    const home = await content.getPage('homepage')
    res.end(`<h1>${home.title}</h1>`)
  }
}

If you're bootstrapping Electrolyte with the electrolyte-assembly-mapper from your entrypoint file (index.js):

// Configure DI/IoC container
const IoC = require('electrolyte')
const loader = require('electrolyte-assembly-mapper')('.ioc-mapper.json')
IoC.use(loader('.', 'app'))
IoC.use(IoC.node_modules())

// Start app
IoC.create('app/bootstrap')
  .then(app => app())

The .ioc-mapper.json will instruct to map the content-client to it's stub:

{
  "lib/content-client": "lib/content-client/stub"
}

In this example, it's best to put .ioc-mapper.json in your .gitignore file, since stubs are only used for development.

If the .ioc-mapper.json file is not found, the loader will only load from the specified directories (in the example . and app), and not map to anything. This way you can leave out the .ioc-mapper.json from your deployment package to production.