@agoric/eventual-send
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -16,19 +16,3 @@ 'use strict'; | ||
// Make idempotent, so we don't layer on top of a BasePromise that is adequate. | ||
let needsShim = false; | ||
for (const method of [ | ||
'get', | ||
'put', | ||
'post', | ||
'delete', | ||
'invoke', | ||
'fapply', | ||
'fcall', | ||
]) { | ||
if (typeof Promise.prototype[method] !== 'function') { | ||
needsShim = true; | ||
break; | ||
} | ||
} | ||
if (!needsShim) { | ||
// Already supports all the methods. | ||
if (typeof Promise.makeHandled === 'function') { | ||
return Promise; | ||
@@ -47,3 +31,3 @@ } | ||
let forwardingHandler; | ||
function relay(p) { | ||
function handler(p) { | ||
return promiseToHandler.get(p) || forwardingHandler; | ||
@@ -56,27 +40,27 @@ } | ||
get(key) { | ||
return relay(this).GET(this, key); | ||
return handler(this).GET(this, key); | ||
}, | ||
put(key, val) { | ||
return relay(this).PUT(this, key, val); | ||
return handler(this).PUT(this, key, val); | ||
}, | ||
delete(key) { | ||
return relay(this).DELETE(this, key); | ||
return handler(this).DELETE(this, key); | ||
}, | ||
post(optKey, args) { | ||
return relay(this).POST(this, optKey, args); | ||
return handler(this).POST(this, optKey, args); | ||
}, | ||
invoke(optKey, ...args) { | ||
return relay(this).POST(this, optKey, args); | ||
return handler(this).POST(this, optKey, args); | ||
}, | ||
fapply(args) { | ||
return relay(this).POST(this, undefined, args); | ||
return handler(this).POST(this, undefined, args); | ||
}, | ||
fcall(...args) { | ||
return relay(this).POST(this, undefined, args); | ||
return handler(this).POST(this, undefined, args); | ||
}, | ||
@@ -217,3 +201,3 @@ }), | ||
// Not a Remote, so use the local implementation on the | ||
// Not a handled Promise, so use the local implementation on the | ||
// naked object. | ||
@@ -220,0 +204,0 @@ return localImpl(o, ...args); |
@@ -14,19 +14,3 @@ /** | ||
// Make idempotent, so we don't layer on top of a BasePromise that is adequate. | ||
let needsShim = false; | ||
for (const method of [ | ||
'get', | ||
'put', | ||
'post', | ||
'delete', | ||
'invoke', | ||
'fapply', | ||
'fcall', | ||
]) { | ||
if (typeof Promise.prototype[method] !== 'function') { | ||
needsShim = true; | ||
break; | ||
} | ||
} | ||
if (!needsShim) { | ||
// Already supports all the methods. | ||
if (typeof Promise.makeHandled === 'function') { | ||
return Promise; | ||
@@ -45,3 +29,3 @@ } | ||
let forwardingHandler; | ||
function relay(p) { | ||
function handler(p) { | ||
return promiseToHandler.get(p) || forwardingHandler; | ||
@@ -54,27 +38,27 @@ } | ||
get(key) { | ||
return relay(this).GET(this, key); | ||
return handler(this).GET(this, key); | ||
}, | ||
put(key, val) { | ||
return relay(this).PUT(this, key, val); | ||
return handler(this).PUT(this, key, val); | ||
}, | ||
delete(key) { | ||
return relay(this).DELETE(this, key); | ||
return handler(this).DELETE(this, key); | ||
}, | ||
post(optKey, args) { | ||
return relay(this).POST(this, optKey, args); | ||
return handler(this).POST(this, optKey, args); | ||
}, | ||
invoke(optKey, ...args) { | ||
return relay(this).POST(this, optKey, args); | ||
return handler(this).POST(this, optKey, args); | ||
}, | ||
fapply(args) { | ||
return relay(this).POST(this, undefined, args); | ||
return handler(this).POST(this, undefined, args); | ||
}, | ||
fcall(...args) { | ||
return relay(this).POST(this, undefined, args); | ||
return handler(this).POST(this, undefined, args); | ||
}, | ||
@@ -215,3 +199,3 @@ }), | ||
// Not a Remote, so use the local implementation on the | ||
// Not a handled Promise, so use the local implementation on the | ||
// naked object. | ||
@@ -218,0 +202,0 @@ return localImpl(o, ...args); |
@@ -20,19 +20,3 @@ (function (global, factory) { | ||
// Make idempotent, so we don't layer on top of a BasePromise that is adequate. | ||
let needsShim = false; | ||
for (const method of [ | ||
'get', | ||
'put', | ||
'post', | ||
'delete', | ||
'invoke', | ||
'fapply', | ||
'fcall', | ||
]) { | ||
if (typeof Promise.prototype[method] !== 'function') { | ||
needsShim = true; | ||
break; | ||
} | ||
} | ||
if (!needsShim) { | ||
// Already supports all the methods. | ||
if (typeof Promise.makeHandled === 'function') { | ||
return Promise; | ||
@@ -51,3 +35,3 @@ } | ||
let forwardingHandler; | ||
function relay(p) { | ||
function handler(p) { | ||
return promiseToHandler.get(p) || forwardingHandler; | ||
@@ -60,27 +44,27 @@ } | ||
get(key) { | ||
return relay(this).GET(this, key); | ||
return handler(this).GET(this, key); | ||
}, | ||
put(key, val) { | ||
return relay(this).PUT(this, key, val); | ||
return handler(this).PUT(this, key, val); | ||
}, | ||
delete(key) { | ||
return relay(this).DELETE(this, key); | ||
return handler(this).DELETE(this, key); | ||
}, | ||
post(optKey, args) { | ||
return relay(this).POST(this, optKey, args); | ||
return handler(this).POST(this, optKey, args); | ||
}, | ||
invoke(optKey, ...args) { | ||
return relay(this).POST(this, optKey, args); | ||
return handler(this).POST(this, optKey, args); | ||
}, | ||
fapply(args) { | ||
return relay(this).POST(this, undefined, args); | ||
return handler(this).POST(this, undefined, args); | ||
}, | ||
fcall(...args) { | ||
return relay(this).POST(this, undefined, args); | ||
return handler(this).POST(this, undefined, args); | ||
}, | ||
@@ -221,3 +205,3 @@ }), | ||
// Not a Remote, so use the local implementation on the | ||
// Not a handled Promise, so use the local implementation on the | ||
// naked object. | ||
@@ -224,0 +208,0 @@ return localImpl(o, ...args); |
{ | ||
"name": "@agoric/eventual-send", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"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
38401
619