New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@universal-packages/adapter-resolver

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@universal-packages/adapter-resolver

Module loader based on adapter parameters.

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13K
decreased by-14.27%
Maintainers
1
Weekly downloads
 
Created
Source

Adapter Resolver

npm version Testing codecov

Module loader based on adapter parameters.

Install

npm install @universal-packages/adapter-resolver

Global methods

resolveAdapter(name: string, [options])

Tries to infer an installed module name based on name and options, imports it and infers the desired export based on name and options.

import { resolveAdapter } from '@universal-packages/adapter-resolver'

const adapter = resolveAdapter('redis', { domain: 'token-registry', type: 'engine' })

console.log(adapter)

// > [class RedisEngine]
Options

Options are meant for inferring the matching adapter so the parent library can have a single simple adapter name requirement instead of the whole path of library and export.

  • domain String To help infer the module name for example if the adapter is redis and is meant to work with @universal-packages/token-registry you can just provide here token-registry.
  • internal Object An object which keys match an internal adapter provided by the root library.
    import { resolveAdapter } from '@universal-packages/adapter-resolver'
    
    const adapter = resolveAdapter('local', { internal: { local: LocalAdapter } })
    
    console.log(adapter)
    
    // > [class LocalAdapter]
    
  • type String To help infer the export name, for example if the adapter is an "engine", you can provide here engine and it will internally will come up with different case variations to try to find the export ex: redisEngine, RedisEngine, redis_engine.

Typescript

This library is developed in TypeScript and shipped fully typed.

Contributing

The development of this library happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving this library.

License

MIT licensed.

FAQs

Package last updated on 09 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc