Socket
Book a DemoInstallSign in
Socket

@exodus/await-proxy

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@exodus/await-proxy

Proxies a module and delays all module calls

1.2.2
latest
Source
npmnpm
Version published
Weekly downloads
2.7K
-4.36%
Maintainers
1
Weekly downloads
 
Created
Source

@exodus/await-proxy

Proxies a module and delays all module calls until the specified promise resolves.

Usage

This is an example of desktop RPC usage:

import awaitProxy from '@exodus/await-proxy'
import { createClient } from '#/electron-rpc-broadcast'
import Handshake from '#/handshake'

const handshake = new Handshake({
  sendMessage: (message) => ipc.targeted('core', 'handshake', message),
  attachListener: (listener) => ipc.on('handshake', listener),
})

// calls to some-module will be queued until the RPC server is initialized (as indicated by the handshake)
export default awaitProxy({
  object: createClient('core', 'some-module'),
  delayUntil: handshake.awaitDone(),
})

API

awaitProxy({ object, delayUntil, synchronousMethods })

  • object is the module to be proxied (should only have functions/methods; no properties)
  • delayUntil is the Promise to await before calling methods on object
  • synchronousMethods is an optional array of strings, denoting methods names on object that are synchronous, but return an object with async methods. Calls to synchronous methods will return a Proxy, with async functions that await promise before actually executing. The underlying synchronous method will only be called after promise resolves. s

FAQs

Package last updated on 01 Nov 2024

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.