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

@agoric/eventual-send

Package Overview
Dependencies
Maintainers
5
Versions
322
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agoric/eventual-send - npm Package Compare versions

Comparing version 0.13.30 to 0.13.31-dev.0

src/handled-promise.js

12

package.json
{
"name": "@agoric/eventual-send",
"version": "0.13.30",
"version": "0.13.31-dev.0+3804194",
"description": "Extend a Promise class to implement the eventual-send API",

@@ -13,5 +13,7 @@ "type": "module",

"build": "exit 0",
"lint-fix": "yarn lint:eslint --fix && yarn lint:types",
"lint-check": "yarn lint",
"lint-fix": "eslint --fix '**/*.js'",
"lint": "eslint '**/*.js'"
"lint": "yarn lint:types && yarn lint:eslint",
"lint:types": "tsc -p jsconfig.json",
"lint:eslint": "eslint '**/*.js'"
},

@@ -29,3 +31,3 @@ "repository": {

"devDependencies": {
"@agoric/assert": "^0.3.14",
"@agoric/assert": "0.3.15-dev.0+3804194",
"@agoric/babel-standalone": "^7.14.3",

@@ -64,3 +66,3 @@ "@endo/ses-ava": "^0.2.8",

},
"gitHead": "34bf70e60b29f53ba50fd4afebdb02d9196860fa"
"gitHead": "380419441d21eade22955258bb84602963cbd5e0"
}
/* global globalThis */
import { makeHandledPromise } from './src/index.js';
import { makeHandledPromise } from './src/handled-promise.js';

@@ -4,0 +4,0 @@ if (typeof HandledPromise === 'undefined') {

@@ -0,1 +1,2 @@

// @ts-check
import { trackTurns } from './track-turns.js';

@@ -52,3 +53,3 @@

* A Proxy handler for E.sendOnly(x)
* For now it is just a variant on the E(x) Proxy handler.
* It is a variant on the E(x) Proxy handler.
*

@@ -64,3 +65,3 @@ * @param {*} x Any value passed to E.sendOnly(x)

return (...args) => {
HandledPromise.applyMethod(x, p, args);
HandledPromise.applyMethodSendOnly(x, p, args);
return undefined;

@@ -70,7 +71,7 @@ };

apply(_target, _thisArg, argsArray = []) {
HandledPromise.applyFunction(x, argsArray);
HandledPromise.applyFunctionSendOnly(x, argsArray);
return undefined;
},
has(_target, _p) {
// We just pretend that every thing exists.
// We just pretend that everything exists.
return true;

@@ -98,3 +99,2 @@ },

E.G = makeEGetterProxy;
E.get = makeEGetterProxy;

@@ -101,0 +101,0 @@ E.resolve = HandledPromise.resolve;

@@ -1,6 +0,6 @@

/* eslint-disable */
/* eslint-disable no-shadow,no-unused-vars,no-use-before-define,no-var,vars-on-top */
// Type definitions for eventual-send
// TODO: Add jsdocs.
type Property = string | number;
type Property = string | number | symbol;

@@ -11,7 +11,11 @@ type ERef<T> = PromiseLike<T> | T;

// interface but declares all the functions as asyncable.
export type EOnly<T> = T extends (...args: infer P) => infer R ?
(...args: P) => ERef<R> | EOnly<R>
: T extends Record<string | number | symbol, Function> ? ERef<{
[K in keyof T]: EOnly<T[K]>
}> : ERef<T>;
export type EOnly<T> = T extends (...args: infer P) => infer R
? (...args: P) => ERef<R> | EOnly<R>
: T extends Record<string | number | symbol, Function>
? ERef<
{
[K in keyof T]: EOnly<T[K]>;
}
>
: ERef<T>;

@@ -24,4 +28,17 @@ type Unpromise<T> = T extends ERef<infer U> ? U : T;

interface EHandler<T> {
get?: (p: T, name: Property) => any;
applyMethod?: (p: T, name?: Property, args: unknown[]) => any;
get?: (p: T, name: Property, returnedP?: Promise<unknown>) => any;
getSendOnly?: (p: T, name: Property) => void;
applyFunction?: (p: T, args: unknown[], returnedP?: Promise<unknown>) => any;
applyFunctionSendOnly?: (p: T, args: unknown[]) => void;
applyMethod?: (
p: T,
name: Property | undefined,
args: unknown[],
returnedP?: Promise<unknown>,
) => any;
applyMethodSendOnly?: (
p: T,
name: Property | undefined,
args: unknown[],
) => void;
}

@@ -32,19 +49,19 @@

rejectHandled: (reason?: unknown) => void,
resolveWithPresence: (presenceHandler: EHandler<{}>, options?: ResolveWithPresenceOptionsBag<{}>) => object,
resolveWithPresence: (
presenceHandler: EHandler<{}>,
options?: ResolveWithPresenceOptionsBag<{}>,
) => object,
) => void;
type ResolveWithPresenceOptionsBag<T> = {
type ResolveWithPresenceOptionsBag<T extends Object> = {
proxy?: {
handler: ProxyHandler<T>,
target: unknown,
revokerCallback?: (revoker: () => void) => void,
},
handler: ProxyHandler<T>;
target: unknown;
revokerCallback?: (revoker: () => void) => void;
};
};
declare interface HandledPromiseConstructor extends PromiseConstructor {
new <R>(
executor: HandledExecutor<R>,
unfulfilledHandler?: EHandler<Promise<unknown>>
);
prototype: Promise<unknown>;
declare interface HandledPromiseStaticMethods {
resolve<T>(x: T): Promise<Unpromise<T>>;
resolve(): Promise<undefined>;
applyFunction(target: unknown, args: unknown[]): Promise<unknown>;

@@ -55,3 +72,3 @@ applyFunctionSendOnly(target: unknown, args: unknown[]): void;

prop: Property | undefined,
args: unknown[]
args: unknown[],
): Promise<unknown>;

@@ -63,6 +80,16 @@ applyMethodSendOnly(target: unknown, prop: Property, args: unknown[]): void;

declare interface HandledPromiseConstructor
extends PromiseConstructor,
HandledPromiseStaticMethods {
new <R>(
executor: HandledExecutor<R>,
unfulfilledHandler?: EHandler<Promise<unknown>>,
): Promise<R>;
prototype: Promise<unknown>;
}
declare var HandledPromise: HandledPromiseConstructor;
namespace global {
declare var HandledPromise: HandledPromiseConstructor;
declare namespace global {
var HandledPromise: HandledPromiseConstructor;
}

@@ -77,9 +104,10 @@

) => Promise<Unpromise<ReturnType<T[P]>>>;
}
type ESingleCall<T> = T extends Function ?
((...args: Parameters<T>) => Promise<Unpromise<ReturnType<T>>>) &
ESingleMethod<Required<T>> : ESingleMethod<Required<T>>;
};
type ESingleCall<T> = T extends Function
? ((...args: Parameters<T>) => Promise<Unpromise<ReturnType<T>>>) &
ESingleMethod<Required<T>>
: ESingleMethod<Required<T>>;
type ESingleGet<T> = {
readonly [P in keyof T]: Promise<Unpromise<T[P]>>;
}
};

@@ -89,12 +117,12 @@ /* Same types for send-only. */

readonly [P in keyof T]: (...args: Parameters<T[P]>) => void;
}
type ESingleCallOnly<T> = T extends Function ?
((...args: Parameters<T>) => void) & ESingleMethodOnly<T> :
ESingleMethodOnly<T>;
};
type ESingleCallOnly<T> = T extends Function
? ((...args: Parameters<T>) => void) & ESingleMethodOnly<T>
: ESingleMethodOnly<T>;
type ESingleGetOnly<T> = {
readonly [P in keyof T]: void;
}
};
interface ESendOnly {
<T>(x: T): ESingleCallOnly<Unpromise<T>, void>;
<T>(x: T): ESingleCallOnly<Unpromise<T>>;
}

@@ -113,6 +141,2 @@

<T>(x: T): ESingleCall<Unpromise<T>>;
/**
* @deprecated use E.get(x) instead
*/
readonly G<T>(x: T): ESingleGet<Unpromise<T>>;

@@ -128,3 +152,3 @@ /**

*/
readonly get<T>(x: T): ESingleGet<Unpromise<T>>;
readonly get: <T>(x: T) => ESingleGet<Unpromise<T>>;

@@ -135,3 +159,3 @@ /**

*/
readonly resolve<T>(x: T): Promise<Unpromise<T>>;
readonly resolve: <T>(x: T) => Promise<Unpromise<T>>;

@@ -142,7 +166,7 @@ /**

*/
readonly when<T,U>(
readonly when: <T, U>(
x: T,
onfulfilled?: (value: Unpromise<T>) => ERef<U>,
onrejected?: (reason: any) => ERef<U>,
): Promise<U>;
) => Promise<U>;

@@ -149,0 +173,0 @@ /**

@@ -28,2 +28,3 @@ /* global globalThis */

/**
* @template {TurnStarterFn[]} T
* Given a list of `TurnStarterFn`s, returns a list of `TurnStarterFn`s whose

@@ -39,4 +40,4 @@ * `this`-free call behaviors are not observably different to those that

*
* @param {TurnStarterFn[]} funcs
* @returns {TurnStarterFn[]}
* @param {T} funcs
* @returns {T}
*/

@@ -43,0 +44,0 @@ export const trackTurns = funcs => {

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