Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@encodable/registry

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@encodable/registry

All-purpose map data structure on steroids.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14K
decreased by-19.54%
Maintainers
2
Weekly downloads
 
Created
Source

@encodable/registry

Version David (path)

All-purpose map data structure on steroids.

  • Can be used to store state as global, making a true singleton that can be used across packages.
  • Can be used locally as well.
  • Support asynchronous values.

Install

npm install @encodable/registry global-box

Example usage

Create registries

import { Registry, SyncRegistry, makeSingleton } from '@encodable/registry';

// local registry (when globalId is not defined)
const registry = new Registry<string>();

// global registry
const globalRegistry = new Registry({ globalId: 'my-global-key' });

const singleton = makeSingleton(() => new Registry({ globalId: 'my-global-key' }));

Registering

// constant value
registry.registerValue('key', 1);
// sync loader
registry.registerLoader('key', () => 1);
// async loader
registry.registerLoader('key', () => Promise.resolve(1));
  • Registry can support both constant values and sync/async loaders.
  • SyncRegistry only support constant values and sync loaders.

Keywords

FAQs

Package last updated on 20 Aug 2020

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