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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@exodus/dependency-preprocessors

v6.3.2

Published

Dependency preprocessors to enable declarative augmenting of dependency definitions before passing them to @exodus/dependency-injection

Readme

@exodus/dependency-preprocessors

IOC preprocessor functions

Usage

Run built-in and custom preprocessors as follows:

import createIocContainer from '@exodus/dependency-injection'
import preprocess from '@exodus/dependency-preprocessors'
import logify from '@exodus/dependency-preprocessors/src/preprocessors/logify'
import config from '@exodus/dependency-preprocessors/src/preprocessors/config'
import alias from '@exodus/dependency-preprocessors/src/preprocessors/alias'
import namespaceStorage from '@exodus/dependency-preprocessors/src/preprocessors/namespace-storage'

const createLogger =
  (namespace) =>
  (...args) =>
    console.log(namespace, ...args)

const ioc = createIocContainer({ logger: createLogger('exodus:ioc') })

const customPreprocessor = ({ definition, ...extras }) => ({ definition, ...extras })
const deps = preprocess({
  dependencies: createDependencies({ adapters, config }),
  preprocessors: [
    //
    logify({ createLogger }),
    config(),
    alias(),
    namespaceStorage(),
    customPreprocessor,
  ],
})

ioc.registerMultiple(deps)
ioc.resolve()

Preprocessors

logify

Pass a namespaced logger instance

import createIocContainer from '@exodus/dependency-injection'
import preprocess from '@exodus/dependency-preprocessors'

const createLogger =
  (namespace) =>
  (...args) =>
    console.log(namespace, ...args)

const ioc = createIocContainer({ logger: createLogger('exodus:ioc') })

const deps = preprocess({
  dependencies: [
    {
      definition: {
        id: 'myModule',
        factory: ({ logger }) => logger.warn('sync finished'), // Logs will be prefixed with [myModule:warn]
      },
    },
  ],
  preprocessors: [logify({ createLogger })],
})

ioc.registerMultiple(deps)
ioc.resolve()

config

Performs global config auto-binding given module id, or injection from a node if it has "config" defined on it.

import createIocContainer from '@exodus/dependency-injection'
import preprocess from '@exodus/dependency-preprocessors'
import config from '@exodus/dependency-preprocessors/src/config'

const createLogger =
  (namespace) =>
  (...args) =>
    console.log(namespace, ...args)

const ioc = createIocContainer({ logger: createLogger('exodus:ioc') })

const deps = preprocess({
  dependencies: [
    {
      definition: {
        id: 'config',
        factory: () => ({ myModule: { apiUrl: 'https://exodus.com' } }),
      },
    },
    {
      definition: {
        id: 'myModule',
        factory: ({ config }) => config.apiUrl,
        dependencies: ['config'],
      },
    },
    {
      definition: {
        id: 'nodeInjected',
        factory: ({ config }) => config.potter.spells, // [lumos]
        dependencies: ['config'],
      },
      config: {
        potter: {
          spells: ['lumos'],
        },
      },
    },
  ],
  preprocessors: [config()],
})

ioc.registerMultiple(deps)
ioc.resolve()

alias

Alias injected dependencies, e.g. so you can inject a global dependency myMobileImplementationOfSomething as a locally named option something to a module.

See example.

namespaceStorage

Namespaces the storage injected to your dependency.

See example.

readOnlyAtoms

Makes all atoms readonly unless configured to be writeable

import readOnlyAtoms from '@exodus/dependency-preprocessors/src/preprocessors/read-only-atoms'

const deps = preprocess({
  dependencies: [
    {
      definition: {
        id: 'balances',
        factory: () => ({ myModule: { apiUrl: 'https://exodus.com' } }),
        dependencies: ['currencyAtom', 'balancesAtom'],
      },
    },
  ],
  preprocessors: [readOnlyAtoms()],
})

To warn instead of throw, set the warn flag to true and inject a logger instace:

import readOnlyAtoms from '@exodus/dependency-preprocessors/src/preprocessors/read-only-atoms'

const deps = preprocess({
  // ...
  preprocessors: [readOnlyAtoms({ warn: true, logger: createLogger('readOnlyAtoms') })],
})

optional

Allows conditionally adding dependencies using the if property:

import optional from '@exodus/dependency-preprocessors/src/preprocessors/optional'

const deps = preprocess({
  dependencies: [
    {
      if: ENABLE_OPTIMISTIC_ACTIVITY,
      definition: {
        id: 'optmisticBalances',
        factory: () => ({ myModule: { apiUrl: 'https://exodus.com' } }),
        dependencies: ['balancesAtom'],
      },
    },
  ],
  preprocessors: [optional()],
})

devModeAtoms

Helps detect various well-known issues with atoms

import devModeAtoms from '@exodus/dependency-preprocessors/src/preprocessors/dev-mode-atoms'

const deps = preprocess({
  dependencies,
  preprocessors: [
    devModeAtoms({
      logger,
      // throw when observers seem to hang
      timeoutObservers: {
        delay: 1000,
      },
      // warn is set() is called with the same value as the current value
      warnOnSameValueSet: true,
      // warn when observers throw/reject instead of crashing set()
      swallowObserverErrors: true,
    }),
  ],
})

performanceMonitor

Wraps method calls to IOC nodes in a proxy that notifies about the execution time of methods which exceed a configures threshold.

import performanceMonitor from '@exodus/dependency-preprocessors/src/preprocessors/performance-monitor'

const deps = preprocess({
  dependencies,
  preprocessors: [
    performanceMonitor({
      now: performance.now, // default
      onAboveThreshold: ({ id, method, duration }) => {
        console.log(`[exodus:${id}:perf]`, `${method} took ${duration}ms`)
      },
      config: {
        threshold: 50, // default, logs any method calls taking longer than 50ms
      },
    }),
  ],
})

order

The order preprocessor changes the order of nodes before passing them on to the IoC, based on the order configuration. In the below example weasleySpells will be reordered to come before potterSpells.

import order from '@exodus/dependency-preprocessors/src/preprocessors/order'

const deps = preprocess({
  dependencies: [
    {
      definition: {
        id: 'potterSpells',
        factory: () => ['lumos'],
      },
    },
    {
      definition: {
        id: 'weasleySpells',
        factory: () => ['lumos', 'wingardium leviosa'],
      },
      order: {
        before: ['potterSpells'],
      },
    },
  ],
  preprocessors: [order()],
})