diff --git a/packages/primitives/src/primitives/fetch.js b/packages/primitives/src/primitives/fetch.js index 9192c683..c15420fc 100644 --- a/packages/primitives/src/primitives/fetch.js +++ b/packages/primitives/src/primitives/fetch.js @@ -20,7 +20,7 @@ process.nextTick = setImmediate process.emitWarning = () => {} class Request extends BaseRequest { - constructor(input, init) { + constructor (input, init) { super(input, addDuplexToInit(init)) } } @@ -82,7 +82,7 @@ ResponseModule.Response.error = function (...args) { * @param {string} potentialName * @param {'Header.append' | 'Headers.delete' | 'Headers.get' | 'Headers.has' | 'Header.set'} errorPrefix */ -function normalizeAndValidateHeaderName(potentialName, errorPrefix) { +function normalizeAndValidateHeaderName (potentialName, errorPrefix) { const normalizedName = potentialName.toLowerCase() if (UtilModule.isValidHeaderName(normalizedName)) { @@ -93,7 +93,7 @@ function normalizeAndValidateHeaderName(potentialName, errorPrefix) { WebIDLModule.errors.invalidArgument({ prefix: errorPrefix, value: normalizedName, - type: 'header name', + type: 'header name' }) } @@ -103,7 +103,7 @@ function normalizeAndValidateHeaderName(potentialName, errorPrefix) { * @param {string} potentialValue * @param {'Header.append' | 'Header.set'} errorPrefix */ -function normalizeAndValidateHeaderValue(potentialValue, errorPrefix) { +function normalizeAndValidateHeaderValue (potentialValue, errorPrefix) { /** * To normalize a byte sequence potentialValue, remove * any leading and trailing HTTP whitespace bytes from @@ -121,7 +121,7 @@ function normalizeAndValidateHeaderValue(potentialValue, errorPrefix) { WebIDLModule.errors.invalidArgument({ prefix: errorPrefix, value: normalizedValue, - type: 'header value', + type: 'header value' }) } @@ -131,11 +131,11 @@ function normalizeAndValidateHeaderValue(potentialValue, errorPrefix) { */ let globalDispatcher = new Agent() -export function getGlobalDispatcher() { +export function getGlobalDispatcher () { return globalDispatcher } -export function setGlobalDispatcher(agent) { +export function setGlobalDispatcher (agent) { if (!agent || typeof agent.dispatch !== 'function') { throw new InvalidArgumentError('Argument agent must implement Agent') } @@ -145,11 +145,11 @@ export function setGlobalDispatcher(agent) { /** * Add `duplex: 'half'` by default to all requests */ -function addDuplexToInit(init) { - if (typeof init === 'undefined' || typeof init === 'object') { - return { duplex: 'half', ...init } - } - return init +function addDuplexToInit (init) { + return typeof init === 'undefined' || + (typeof init === 'object' && init.duplex !== 'half') + ? { duplex: 'half', ...init } + : init } /** @@ -157,7 +157,7 @@ function addDuplexToInit(init) { * It also re-cretates a new Response object in order to allow mutations on * the Response headers. */ -export async function fetch(info, init) { +export async function fetch (info, init) { init = addDuplexToInit(init) const res = await fetchImpl.call(getGlobalDispatcher(), info, init) const response = new Response(res.body, res) diff --git a/packages/runtime/src/cli/repl.ts b/packages/runtime/src/cli/repl.ts index 918bfdb9..64b10270 100644 --- a/packages/runtime/src/cli/repl.ts +++ b/packages/runtime/src/cli/repl.ts @@ -14,7 +14,7 @@ const writer: createRepl.REPLWriter = (output) => { } const repl = createRepl.start({ prompt: 'ƒ => ', writer }) -repl.setupHistory(join(homedir(), '.edge_runtime_repl_history'), () => { }) +repl.setupHistory(join(homedir(), '.edge_runtime_repl_history'), () => {}) Object.getOwnPropertyNames(repl.context).forEach( (mod) => delete repl.context[mod]