Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@universal-packages/adapter-resolver
Advanced tools
Module loader based on adapter parameters.
npm install @universal-packages/adapter-resolver
resolveAdapter(options: Object)
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({ name: 'redis', domain: 'token-registry', type: 'engine' })
console.log(adapter)
// > [class RedisEngine]
Adapters need to follow the convention in order to be found. domain and name are use to infer the package name and type is used to infer the export name.
name
String
The name of the adapter, for example redis
.
domain
String
The domain for which the adapter will work for example if the adapter is redis
and is meant to work with @universal-packages/token-registry
you 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: { domain: 'token-registry', type: 'engine', local: LocalAdapter } })
console.log(adapter)
// > [class LocalAdapter]
type
String
The package needs to export something in the format <name><type>
, for example if the adapter is an "engine", you provide here engine
and it will internally will come up with different case variations of the format to find the export ex: redisEngine, RedisEngine, redis_engine.
gatherAdapters(options: Object)
Gather of the adapters of a type under the same domain.
import { gatherAdapters } from '@universal-packages/adapter-resolver'
const adapters = gatherAdapters({ domain: 'token-registry', type: 'engine' })
console.log(adapters)
// > { redis: [class RedisEngine], local: [class LocalEngine] }
domain
String
The domain under which the adapters are meant to work, for example all engines for @universal-packages/token-registry
will have the same domain token-registry
.
internal
Object
An object of named internal adapters provided by the root library to be mixed with the gathered adapters.
import { gatherAdapters } from '@universal-packages/adapter-resolver'
const adapters = gatherAdapters({ domain: 'token-registry', type: 'engine', internal: { local: InternalAdapter } })
console.log(adapters)
// > { internal: [class InternalAdapter], redis: [class RedisEngine], local: [class LocalAdapter] }
type
String
The type of the adapters, for example engine
.
This library is developed in TypeScript and shipped fully typed.
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.
FAQs
Module loader based on adapter parameters.
The npm package @universal-packages/adapter-resolver receives a total of 12,839 weekly downloads. As such, @universal-packages/adapter-resolver popularity was classified as popular.
We found that @universal-packages/adapter-resolver demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.