@whatwg-node/server
Advanced tools
Comparing version 0.9.54 to 0.9.55-alpha-20241113130810-11f18a2ca304ad9b9e37556238407455c4e28c61
@@ -448,70 +448,14 @@ "use strict"; | ||
} | ||
originalCtx = {}; | ||
return { | ||
waitUntil(promise) { | ||
waitUntilPromises?.push(promise.catch(err => console.error(err))); | ||
}, | ||
}; | ||
} | ||
const extraProps = {}; | ||
const deletedProps = new Set(); | ||
return new Proxy(originalCtx, { | ||
get(originalCtx, prop) { | ||
if (waitUntilPromises != null && prop === 'waitUntil') { | ||
return function waitUntil(promise) { | ||
waitUntilPromises.push(promise.catch(err => console.error(err))); | ||
}; | ||
} | ||
const extraPropVal = extraProps[prop]; | ||
if (extraPropVal != null) { | ||
if (typeof extraPropVal === 'function') { | ||
return extraPropVal.bind(extraProps); | ||
} | ||
return extraPropVal; | ||
} | ||
if (deletedProps.has(prop)) { | ||
return undefined; | ||
} | ||
return originalCtx[prop]; | ||
return Object.create(originalCtx, { | ||
waitUntil: { | ||
value(promise) { | ||
waitUntilPromises?.push(promise.catch(err => console.error(err))); | ||
}, | ||
}, | ||
set(_originalCtx, prop, value) { | ||
extraProps[prop] = value; | ||
return true; | ||
}, | ||
has(originalCtx, prop) { | ||
if (waitUntilPromises != null && prop === 'waitUntil') { | ||
return true; | ||
} | ||
if (deletedProps.has(prop)) { | ||
return false; | ||
} | ||
if (prop in extraProps) { | ||
return true; | ||
} | ||
return prop in originalCtx; | ||
}, | ||
defineProperty(_originalCtx, prop, descriptor) { | ||
return Reflect.defineProperty(extraProps, prop, descriptor); | ||
}, | ||
deleteProperty(_originalCtx, prop) { | ||
if (prop in extraProps) { | ||
return Reflect.deleteProperty(extraProps, prop); | ||
} | ||
deletedProps.add(prop); | ||
return true; | ||
}, | ||
ownKeys(originalCtx) { | ||
const extraKeys = Reflect.ownKeys(extraProps); | ||
const originalKeys = Reflect.ownKeys(originalCtx); | ||
const deletedKeys = Array.from(deletedProps); | ||
const allKeys = new Set(extraKeys.concat(originalKeys.filter(keys => !deletedKeys.includes(keys)))); | ||
if (waitUntilPromises != null) { | ||
allKeys.add('waitUntil'); | ||
} | ||
return Array.from(allKeys); | ||
}, | ||
getOwnPropertyDescriptor(originalCtx, prop) { | ||
if (prop in extraProps) { | ||
return Reflect.getOwnPropertyDescriptor(extraProps, prop); | ||
} | ||
if (deletedProps.has(prop)) { | ||
return undefined; | ||
} | ||
return Reflect.getOwnPropertyDescriptor(originalCtx, prop); | ||
}, | ||
}); | ||
@@ -518,0 +462,0 @@ } |
@@ -426,70 +426,14 @@ export function isAsyncIterable(body) { | ||
} | ||
originalCtx = {}; | ||
return { | ||
waitUntil(promise) { | ||
waitUntilPromises?.push(promise.catch(err => console.error(err))); | ||
}, | ||
}; | ||
} | ||
const extraProps = {}; | ||
const deletedProps = new Set(); | ||
return new Proxy(originalCtx, { | ||
get(originalCtx, prop) { | ||
if (waitUntilPromises != null && prop === 'waitUntil') { | ||
return function waitUntil(promise) { | ||
waitUntilPromises.push(promise.catch(err => console.error(err))); | ||
}; | ||
} | ||
const extraPropVal = extraProps[prop]; | ||
if (extraPropVal != null) { | ||
if (typeof extraPropVal === 'function') { | ||
return extraPropVal.bind(extraProps); | ||
} | ||
return extraPropVal; | ||
} | ||
if (deletedProps.has(prop)) { | ||
return undefined; | ||
} | ||
return originalCtx[prop]; | ||
return Object.create(originalCtx, { | ||
waitUntil: { | ||
value(promise) { | ||
waitUntilPromises?.push(promise.catch(err => console.error(err))); | ||
}, | ||
}, | ||
set(_originalCtx, prop, value) { | ||
extraProps[prop] = value; | ||
return true; | ||
}, | ||
has(originalCtx, prop) { | ||
if (waitUntilPromises != null && prop === 'waitUntil') { | ||
return true; | ||
} | ||
if (deletedProps.has(prop)) { | ||
return false; | ||
} | ||
if (prop in extraProps) { | ||
return true; | ||
} | ||
return prop in originalCtx; | ||
}, | ||
defineProperty(_originalCtx, prop, descriptor) { | ||
return Reflect.defineProperty(extraProps, prop, descriptor); | ||
}, | ||
deleteProperty(_originalCtx, prop) { | ||
if (prop in extraProps) { | ||
return Reflect.deleteProperty(extraProps, prop); | ||
} | ||
deletedProps.add(prop); | ||
return true; | ||
}, | ||
ownKeys(originalCtx) { | ||
const extraKeys = Reflect.ownKeys(extraProps); | ||
const originalKeys = Reflect.ownKeys(originalCtx); | ||
const deletedKeys = Array.from(deletedProps); | ||
const allKeys = new Set(extraKeys.concat(originalKeys.filter(keys => !deletedKeys.includes(keys)))); | ||
if (waitUntilPromises != null) { | ||
allKeys.add('waitUntil'); | ||
} | ||
return Array.from(allKeys); | ||
}, | ||
getOwnPropertyDescriptor(originalCtx, prop) { | ||
if (prop in extraProps) { | ||
return Reflect.getOwnPropertyDescriptor(extraProps, prop); | ||
} | ||
if (deletedProps.has(prop)) { | ||
return undefined; | ||
} | ||
return Reflect.getOwnPropertyDescriptor(originalCtx, prop); | ||
}, | ||
}); | ||
@@ -496,0 +440,0 @@ } |
{ | ||
"name": "@whatwg-node/server", | ||
"version": "0.9.54", | ||
"version": "0.9.55-alpha-20241113130810-11f18a2ca304ad9b9e37556238407455c4e28c61", | ||
"description": "Fetch API compliant HTTP Server adapter", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
147582
3142