@agoric/eventual-send
Advanced tools
Comparing version 0.4.3 to 0.4.4
@@ -16,2 +16,17 @@ 'use strict'; | ||
const readOnlyProxy = { | ||
set(_target, _prop, _value) { | ||
return false; | ||
}, | ||
isExtensible(_target) { | ||
return false; | ||
}, | ||
setPrototypeOf(_target, _value) { | ||
return false; | ||
}, | ||
deleteProperty(_target, _prop) { | ||
return false; | ||
}, | ||
}; | ||
/** | ||
@@ -25,2 +40,3 @@ * A Proxy handler for E(x). | ||
return harden({ | ||
...readOnlyProxy, | ||
get(_target, p, _receiver) { | ||
@@ -37,10 +53,4 @@ if (`${p}` !== p) { | ||
}, | ||
deleteProperty(_target, p) { | ||
return harden(HandledPromise.delete(x, p)); | ||
}, | ||
set(_target, p, value, _receiver) { | ||
return harden(HandledPromise.set(x, p, value)); | ||
}, | ||
apply(_target, _thisArg, argArray = []) { | ||
return harden(HandledPromise.apply(x, argArray)); | ||
return harden(HandledPromise.applyFunction(x, argArray)); | ||
}, | ||
@@ -60,63 +70,87 @@ has(_target, _p) { | ||
const EChain = x => { | ||
return harden({ | ||
const makeEGetterProxy = (x, wrap = o => o) => | ||
new Proxy( | ||
Object.create(null), | ||
{ | ||
...readOnlyProxy, | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return wrap(HandledPromise.get(x, prop)); | ||
}, | ||
}, | ||
); | ||
const makeEDeleterProxy = (x, wrap = o => o) => | ||
new Proxy( | ||
Object.create(null), | ||
{ | ||
...readOnlyProxy, | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return wrap(HandledPromise.delete(x, prop)); | ||
}, | ||
}, | ||
); | ||
const makeESetterProxy = (x, wrap = o => o) => | ||
new Proxy( | ||
Object.create(null), | ||
{ | ||
...readOnlyProxy, | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return harden(value => | ||
wrap(HandledPromise.set(x, prop, value)), | ||
); | ||
}, | ||
}, | ||
); | ||
const makeEMethodProxy = (x, wrap = o => o) => | ||
new Proxy( | ||
(..._args) => {}, | ||
{ | ||
...readOnlyProxy, | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return harden((...args) => | ||
wrap(HandledPromise.applyMethod(x, prop, args)), | ||
); | ||
}, | ||
apply(_target, _thisArg, args = []) { | ||
return wrap(HandledPromise.applyFunction(x, args)); | ||
}, | ||
}); | ||
E.G = makeEGetterProxy; | ||
E.D = makeEDeleterProxy; | ||
E.S = makeESetterProxy; | ||
E.M = makeEMethodProxy; | ||
const EChain = x => | ||
harden({ | ||
get G() { | ||
// Return getter. | ||
return new Proxy( | ||
{ EChain: 'getter' }, | ||
{ | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return EChain(HandledPromise.get(x, prop)); | ||
}, | ||
}, | ||
); | ||
return makeEGetterProxy(x, EChain); | ||
}, | ||
get D() { | ||
// Return deleter. | ||
return new Proxy( | ||
{ EChain: 'deleter' }, | ||
{ | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return EChain(HandledPromise.delete(x, prop)); | ||
}, | ||
}, | ||
); | ||
return makeEDeleterProxy(x, EChain); | ||
}, | ||
get S() { | ||
// Return setter. | ||
return new Proxy( | ||
{ EChain: 'setter' }, | ||
{ | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return harden(value => | ||
EChain(HandledPromise.set(x, prop, value)), | ||
); | ||
}, | ||
}, | ||
); | ||
return makeESetterProxy(x, EChain); | ||
}, | ||
get M() { | ||
// Return method-caller. | ||
return new Proxy((..._args) => {}, { | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return harden((...args) => | ||
EChain(HandledPromise.applyMethod(x, prop, args)), | ||
); | ||
}, | ||
apply(_target, _thisArg, args = []) { | ||
return EChain(HandledPromise.applyFunction(x, args)); | ||
}, | ||
}); | ||
return makeEMethodProxy(x, EChain); | ||
}, | ||
@@ -128,3 +162,2 @@ get P() { | ||
}); | ||
}; | ||
@@ -187,10 +220,2 @@ E.C = EChain; | ||
}, | ||
// TODO: Remove when making HandledPromise a constructor | ||
// to avoid conflict with Function.prototype.apply | ||
apply(target, args) { | ||
return EPromise.resolve(target).post(undefined, args); | ||
}, | ||
applySendOnly(target, args) { | ||
EPromise.resolve(target).post(undefined, args); | ||
}, | ||
applyFunction(target, args) { | ||
@@ -197,0 +222,0 @@ return EPromise.resolve(target).post(undefined, args); |
@@ -12,2 +12,17 @@ /* global globalThis window */ | ||
const readOnlyProxy = { | ||
set(_target, _prop, _value) { | ||
return false; | ||
}, | ||
isExtensible(_target) { | ||
return false; | ||
}, | ||
setPrototypeOf(_target, _value) { | ||
return false; | ||
}, | ||
deleteProperty(_target, _prop) { | ||
return false; | ||
}, | ||
}; | ||
/** | ||
@@ -21,2 +36,3 @@ * A Proxy handler for E(x). | ||
return harden({ | ||
...readOnlyProxy, | ||
get(_target, p, _receiver) { | ||
@@ -33,10 +49,4 @@ if (`${p}` !== p) { | ||
}, | ||
deleteProperty(_target, p) { | ||
return harden(HandledPromise.delete(x, p)); | ||
}, | ||
set(_target, p, value, _receiver) { | ||
return harden(HandledPromise.set(x, p, value)); | ||
}, | ||
apply(_target, _thisArg, argArray = []) { | ||
return harden(HandledPromise.apply(x, argArray)); | ||
return harden(HandledPromise.applyFunction(x, argArray)); | ||
}, | ||
@@ -56,63 +66,87 @@ has(_target, _p) { | ||
const EChain = x => { | ||
return harden({ | ||
const makeEGetterProxy = (x, wrap = o => o) => | ||
new Proxy( | ||
Object.create(null), | ||
{ | ||
...readOnlyProxy, | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return wrap(HandledPromise.get(x, prop)); | ||
}, | ||
}, | ||
); | ||
const makeEDeleterProxy = (x, wrap = o => o) => | ||
new Proxy( | ||
Object.create(null), | ||
{ | ||
...readOnlyProxy, | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return wrap(HandledPromise.delete(x, prop)); | ||
}, | ||
}, | ||
); | ||
const makeESetterProxy = (x, wrap = o => o) => | ||
new Proxy( | ||
Object.create(null), | ||
{ | ||
...readOnlyProxy, | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return harden(value => | ||
wrap(HandledPromise.set(x, prop, value)), | ||
); | ||
}, | ||
}, | ||
); | ||
const makeEMethodProxy = (x, wrap = o => o) => | ||
new Proxy( | ||
(..._args) => {}, | ||
{ | ||
...readOnlyProxy, | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return harden((...args) => | ||
wrap(HandledPromise.applyMethod(x, prop, args)), | ||
); | ||
}, | ||
apply(_target, _thisArg, args = []) { | ||
return wrap(HandledPromise.applyFunction(x, args)); | ||
}, | ||
}); | ||
E.G = makeEGetterProxy; | ||
E.D = makeEDeleterProxy; | ||
E.S = makeESetterProxy; | ||
E.M = makeEMethodProxy; | ||
const EChain = x => | ||
harden({ | ||
get G() { | ||
// Return getter. | ||
return new Proxy( | ||
{ EChain: 'getter' }, | ||
{ | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return EChain(HandledPromise.get(x, prop)); | ||
}, | ||
}, | ||
); | ||
return makeEGetterProxy(x, EChain); | ||
}, | ||
get D() { | ||
// Return deleter. | ||
return new Proxy( | ||
{ EChain: 'deleter' }, | ||
{ | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return EChain(HandledPromise.delete(x, prop)); | ||
}, | ||
}, | ||
); | ||
return makeEDeleterProxy(x, EChain); | ||
}, | ||
get S() { | ||
// Return setter. | ||
return new Proxy( | ||
{ EChain: 'setter' }, | ||
{ | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return harden(value => | ||
EChain(HandledPromise.set(x, prop, value)), | ||
); | ||
}, | ||
}, | ||
); | ||
return makeESetterProxy(x, EChain); | ||
}, | ||
get M() { | ||
// Return method-caller. | ||
return new Proxy((..._args) => {}, { | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return harden((...args) => | ||
EChain(HandledPromise.applyMethod(x, prop, args)), | ||
); | ||
}, | ||
apply(_target, _thisArg, args = []) { | ||
return EChain(HandledPromise.applyFunction(x, args)); | ||
}, | ||
}); | ||
return makeEMethodProxy(x, EChain); | ||
}, | ||
@@ -124,3 +158,2 @@ get P() { | ||
}); | ||
}; | ||
@@ -183,10 +216,2 @@ E.C = EChain; | ||
}, | ||
// TODO: Remove when making HandledPromise a constructor | ||
// to avoid conflict with Function.prototype.apply | ||
apply(target, args) { | ||
return EPromise.resolve(target).post(undefined, args); | ||
}, | ||
applySendOnly(target, args) { | ||
EPromise.resolve(target).post(undefined, args); | ||
}, | ||
applyFunction(target, args) { | ||
@@ -193,0 +218,0 @@ return EPromise.resolve(target).post(undefined, args); |
@@ -18,2 +18,17 @@ (function (global, factory) { | ||
const readOnlyProxy = { | ||
set(_target, _prop, _value) { | ||
return false; | ||
}, | ||
isExtensible(_target) { | ||
return false; | ||
}, | ||
setPrototypeOf(_target, _value) { | ||
return false; | ||
}, | ||
deleteProperty(_target, _prop) { | ||
return false; | ||
}, | ||
}; | ||
/** | ||
@@ -27,2 +42,3 @@ * A Proxy handler for E(x). | ||
return harden({ | ||
...readOnlyProxy, | ||
get(_target, p, _receiver) { | ||
@@ -39,10 +55,4 @@ if (`${p}` !== p) { | ||
}, | ||
deleteProperty(_target, p) { | ||
return harden(HandledPromise.delete(x, p)); | ||
}, | ||
set(_target, p, value, _receiver) { | ||
return harden(HandledPromise.set(x, p, value)); | ||
}, | ||
apply(_target, _thisArg, argArray = []) { | ||
return harden(HandledPromise.apply(x, argArray)); | ||
return harden(HandledPromise.applyFunction(x, argArray)); | ||
}, | ||
@@ -62,63 +72,87 @@ has(_target, _p) { | ||
const EChain = x => { | ||
return harden({ | ||
const makeEGetterProxy = (x, wrap = o => o) => | ||
new Proxy( | ||
Object.create(null), | ||
{ | ||
...readOnlyProxy, | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return wrap(HandledPromise.get(x, prop)); | ||
}, | ||
}, | ||
); | ||
const makeEDeleterProxy = (x, wrap = o => o) => | ||
new Proxy( | ||
Object.create(null), | ||
{ | ||
...readOnlyProxy, | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return wrap(HandledPromise.delete(x, prop)); | ||
}, | ||
}, | ||
); | ||
const makeESetterProxy = (x, wrap = o => o) => | ||
new Proxy( | ||
Object.create(null), | ||
{ | ||
...readOnlyProxy, | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return harden(value => | ||
wrap(HandledPromise.set(x, prop, value)), | ||
); | ||
}, | ||
}, | ||
); | ||
const makeEMethodProxy = (x, wrap = o => o) => | ||
new Proxy( | ||
(..._args) => {}, | ||
{ | ||
...readOnlyProxy, | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return harden((...args) => | ||
wrap(HandledPromise.applyMethod(x, prop, args)), | ||
); | ||
}, | ||
apply(_target, _thisArg, args = []) { | ||
return wrap(HandledPromise.applyFunction(x, args)); | ||
}, | ||
}); | ||
E.G = makeEGetterProxy; | ||
E.D = makeEDeleterProxy; | ||
E.S = makeESetterProxy; | ||
E.M = makeEMethodProxy; | ||
const EChain = x => | ||
harden({ | ||
get G() { | ||
// Return getter. | ||
return new Proxy( | ||
{ EChain: 'getter' }, | ||
{ | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return EChain(HandledPromise.get(x, prop)); | ||
}, | ||
}, | ||
); | ||
return makeEGetterProxy(x, EChain); | ||
}, | ||
get D() { | ||
// Return deleter. | ||
return new Proxy( | ||
{ EChain: 'deleter' }, | ||
{ | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return EChain(HandledPromise.delete(x, prop)); | ||
}, | ||
}, | ||
); | ||
return makeEDeleterProxy(x, EChain); | ||
}, | ||
get S() { | ||
// Return setter. | ||
return new Proxy( | ||
{ EChain: 'setter' }, | ||
{ | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return harden(value => | ||
EChain(HandledPromise.set(x, prop, value)), | ||
); | ||
}, | ||
}, | ||
); | ||
return makeESetterProxy(x, EChain); | ||
}, | ||
get M() { | ||
// Return method-caller. | ||
return new Proxy((..._args) => {}, { | ||
has(_target, _prop) { | ||
return true; | ||
}, | ||
get(_target, prop) { | ||
return harden((...args) => | ||
EChain(HandledPromise.applyMethod(x, prop, args)), | ||
); | ||
}, | ||
apply(_target, _thisArg, args = []) { | ||
return EChain(HandledPromise.applyFunction(x, args)); | ||
}, | ||
}); | ||
return makeEMethodProxy(x, EChain); | ||
}, | ||
@@ -130,3 +164,2 @@ get P() { | ||
}); | ||
}; | ||
@@ -189,10 +222,2 @@ E.C = EChain; | ||
}, | ||
// TODO: Remove when making HandledPromise a constructor | ||
// to avoid conflict with Function.prototype.apply | ||
apply(target, args) { | ||
return EPromise.resolve(target).post(undefined, args); | ||
}, | ||
applySendOnly(target, args) { | ||
EPromise.resolve(target).post(undefined, args); | ||
}, | ||
applyFunction(target, args) { | ||
@@ -199,0 +224,0 @@ return EPromise.resolve(target).post(undefined, args); |
{ | ||
"name": "@agoric/eventual-send", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "Extend a Promise class to implement the eventual-send API", | ||
@@ -5,0 +5,0 @@ "main": "dist/eventual-send.cjs.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69667
1630