@agoric/eventual-send
Advanced tools
Comparing version 0.1.7 to 0.1.8
@@ -27,4 +27,9 @@ 'use strict'; | ||
let forwardingHandler; | ||
function handler(p) { | ||
return promiseToHandler.get(p) || forwardingHandler; | ||
function handler(p, operation, ...args) { | ||
const h = promiseToHandler.get(p) || forwardingHandler; | ||
if (typeof h[operation] !== 'function') { | ||
const handlerName = h === forwardingHandler ? 'forwardingHandler' : 'unfulfilledHandler'; | ||
throw TypeError(`${handlerName}.${operation} is not a function`); | ||
} | ||
return h[operation](p, ...args); | ||
} | ||
@@ -36,27 +41,27 @@ | ||
get(key) { | ||
return handler(this).GET(this, key); | ||
return handler(this, 'GET', key); | ||
}, | ||
put(key, val) { | ||
return handler(this).PUT(this, key, val); | ||
return handler(this, 'PUT', key, val); | ||
}, | ||
delete(key) { | ||
return handler(this).DELETE(this, key); | ||
return handler(this, 'DELETE', key); | ||
}, | ||
post(optKey, args) { | ||
return handler(this).POST(this, optKey, args); | ||
return handler(this, 'POST', optKey, args); | ||
}, | ||
invoke(optKey, ...args) { | ||
return handler(this).POST(this, optKey, args); | ||
return handler(this, 'POST', optKey, args); | ||
}, | ||
fapply(args) { | ||
return handler(this).POST(this, undefined, args); | ||
return handler(this, 'POST', undefined, args); | ||
}, | ||
fcall(...args) { | ||
return handler(this).POST(this, undefined, args); | ||
return handler(this, 'POST', undefined, args); | ||
}, | ||
@@ -121,7 +126,2 @@ }), | ||
} | ||
for (const method of ['GET', 'PUT', 'DELETE', 'POST']) { | ||
if (typeof h[method] !== 'function') { | ||
throw TypeError(`Handler ${h} requires a ${method} method`); | ||
} | ||
} | ||
} | ||
@@ -223,2 +223,5 @@ validateHandler(unfulfilledHandler); | ||
// The handler was resolved, so give it a naked object. | ||
if (typeof fulfilledHandler[operation] !== 'function') { | ||
throw TypeError(`fulfilledHandler.${operation} is not a function`); | ||
} | ||
return fulfilledHandler[operation](o, ...args); | ||
@@ -225,0 +228,0 @@ } |
@@ -25,4 +25,9 @@ /** | ||
let forwardingHandler; | ||
function handler(p) { | ||
return promiseToHandler.get(p) || forwardingHandler; | ||
function handler(p, operation, ...args) { | ||
const h = promiseToHandler.get(p) || forwardingHandler; | ||
if (typeof h[operation] !== 'function') { | ||
const handlerName = h === forwardingHandler ? 'forwardingHandler' : 'unfulfilledHandler'; | ||
throw TypeError(`${handlerName}.${operation} is not a function`); | ||
} | ||
return h[operation](p, ...args); | ||
} | ||
@@ -34,27 +39,27 @@ | ||
get(key) { | ||
return handler(this).GET(this, key); | ||
return handler(this, 'GET', key); | ||
}, | ||
put(key, val) { | ||
return handler(this).PUT(this, key, val); | ||
return handler(this, 'PUT', key, val); | ||
}, | ||
delete(key) { | ||
return handler(this).DELETE(this, key); | ||
return handler(this, 'DELETE', key); | ||
}, | ||
post(optKey, args) { | ||
return handler(this).POST(this, optKey, args); | ||
return handler(this, 'POST', optKey, args); | ||
}, | ||
invoke(optKey, ...args) { | ||
return handler(this).POST(this, optKey, args); | ||
return handler(this, 'POST', optKey, args); | ||
}, | ||
fapply(args) { | ||
return handler(this).POST(this, undefined, args); | ||
return handler(this, 'POST', undefined, args); | ||
}, | ||
fcall(...args) { | ||
return handler(this).POST(this, undefined, args); | ||
return handler(this, 'POST', undefined, args); | ||
}, | ||
@@ -119,7 +124,2 @@ }), | ||
} | ||
for (const method of ['GET', 'PUT', 'DELETE', 'POST']) { | ||
if (typeof h[method] !== 'function') { | ||
throw TypeError(`Handler ${h} requires a ${method} method`); | ||
} | ||
} | ||
} | ||
@@ -221,2 +221,5 @@ validateHandler(unfulfilledHandler); | ||
// The handler was resolved, so give it a naked object. | ||
if (typeof fulfilledHandler[operation] !== 'function') { | ||
throw TypeError(`fulfilledHandler.${operation} is not a function`); | ||
} | ||
return fulfilledHandler[operation](o, ...args); | ||
@@ -223,0 +226,0 @@ } |
@@ -31,4 +31,9 @@ (function (global, factory) { | ||
let forwardingHandler; | ||
function handler(p) { | ||
return promiseToHandler.get(p) || forwardingHandler; | ||
function handler(p, operation, ...args) { | ||
const h = promiseToHandler.get(p) || forwardingHandler; | ||
if (typeof h[operation] !== 'function') { | ||
const handlerName = h === forwardingHandler ? 'forwardingHandler' : 'unfulfilledHandler'; | ||
throw TypeError(`${handlerName}.${operation} is not a function`); | ||
} | ||
return h[operation](p, ...args); | ||
} | ||
@@ -40,27 +45,27 @@ | ||
get(key) { | ||
return handler(this).GET(this, key); | ||
return handler(this, 'GET', key); | ||
}, | ||
put(key, val) { | ||
return handler(this).PUT(this, key, val); | ||
return handler(this, 'PUT', key, val); | ||
}, | ||
delete(key) { | ||
return handler(this).DELETE(this, key); | ||
return handler(this, 'DELETE', key); | ||
}, | ||
post(optKey, args) { | ||
return handler(this).POST(this, optKey, args); | ||
return handler(this, 'POST', optKey, args); | ||
}, | ||
invoke(optKey, ...args) { | ||
return handler(this).POST(this, optKey, args); | ||
return handler(this, 'POST', optKey, args); | ||
}, | ||
fapply(args) { | ||
return handler(this).POST(this, undefined, args); | ||
return handler(this, 'POST', undefined, args); | ||
}, | ||
fcall(...args) { | ||
return handler(this).POST(this, undefined, args); | ||
return handler(this, 'POST', undefined, args); | ||
}, | ||
@@ -125,7 +130,2 @@ }), | ||
} | ||
for (const method of ['GET', 'PUT', 'DELETE', 'POST']) { | ||
if (typeof h[method] !== 'function') { | ||
throw TypeError(`Handler ${h} requires a ${method} method`); | ||
} | ||
} | ||
} | ||
@@ -227,2 +227,5 @@ validateHandler(unfulfilledHandler); | ||
// The handler was resolved, so give it a naked object. | ||
if (typeof fulfilledHandler[operation] !== 'function') { | ||
throw TypeError(`fulfilledHandler.${operation} is not a function`); | ||
} | ||
return fulfilledHandler[operation](o, ...args); | ||
@@ -229,0 +232,0 @@ } |
{ | ||
"name": "@agoric/eventual-send", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"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
41721
685