@ai-zen/node-fetch-event-source
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -1,4 +0,2 @@ | ||
import fetch from 'node-fetch'; | ||
import { EventSourceMessage } from './parse'; | ||
import { RequestInfo, RequestInit, Response } from 'node-fetch'; | ||
export declare const EventStreamContentType = "text/event-stream"; | ||
@@ -5,0 +3,0 @@ export interface FetchEventSourceInit extends RequestInit { |
@@ -19,3 +19,3 @@ "use strict"; | ||
const parse_1 = require("./parse"); | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
const cross_fetch_1 = __importDefault(require("cross-fetch")); | ||
exports.EventStreamContentType = 'text/event-stream'; | ||
@@ -42,3 +42,3 @@ const DefaultRetryInterval = 1000; | ||
}); | ||
const fetch = inputFetch !== null && inputFetch !== void 0 ? inputFetch : node_fetch_1.default; | ||
const fetch = inputFetch !== null && inputFetch !== void 0 ? inputFetch : cross_fetch_1.default; | ||
const onopen = inputOnOpen !== null && inputOnOpen !== void 0 ? inputOnOpen : defaultOnOpen; | ||
@@ -45,0 +45,0 @@ async function create() { |
@@ -8,4 +8,4 @@ /// <reference types="node" /> | ||
} | ||
export declare function getBytes(stream: NodeJS.ReadableStream, onChunk: (arr: Uint8Array) => void): Promise<void>; | ||
export declare function getBytes(stream: NodeJS.ReadableStream | ReadableStream<Uint8Array>, onChunk: (arr: Uint8Array) => void): Promise<void>; | ||
export declare function getLines(onLine: (line: Uint8Array, fieldLength: number) => void): (arr: Uint8Array) => void; | ||
export declare function getMessages(onId: (id: string) => void, onRetry: (retry: number) => void, onMessage?: (msg: EventSourceMessage) => void): (line: Uint8Array, fieldLength: number) => void; |
@@ -13,2 +13,10 @@ "use strict"; | ||
var _a, e_1, _b, _c; | ||
if ('getReader' in stream) { | ||
const reader = stream.getReader(); | ||
let result; | ||
while (!(result = await reader.read()).done) { | ||
onChunk(result.value); | ||
} | ||
return; | ||
} | ||
try { | ||
@@ -15,0 +23,0 @@ for (var _d = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = await stream_1.next(), _a = stream_1_1.done, !_a;) { |
@@ -1,4 +0,2 @@ | ||
import fetch from 'node-fetch'; | ||
import { EventSourceMessage } from './parse'; | ||
import { RequestInfo, RequestInit, Response } from 'node-fetch'; | ||
export declare const EventStreamContentType = "text/event-stream"; | ||
@@ -5,0 +3,0 @@ export interface FetchEventSourceInit extends RequestInit { |
@@ -13,3 +13,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { getBytes, getLines, getMessages } from './parse'; | ||
import nodeFetch from 'node-fetch'; | ||
import crossFetch from 'cross-fetch'; | ||
export const EventStreamContentType = 'text/event-stream'; | ||
@@ -36,3 +36,3 @@ const DefaultRetryInterval = 1000; | ||
}); | ||
const fetch = inputFetch !== null && inputFetch !== void 0 ? inputFetch : nodeFetch; | ||
const fetch = inputFetch !== null && inputFetch !== void 0 ? inputFetch : crossFetch; | ||
const onopen = inputOnOpen !== null && inputOnOpen !== void 0 ? inputOnOpen : defaultOnOpen; | ||
@@ -39,0 +39,0 @@ async function create() { |
@@ -8,4 +8,4 @@ /// <reference types="node" /> | ||
} | ||
export declare function getBytes(stream: NodeJS.ReadableStream, onChunk: (arr: Uint8Array) => void): Promise<void>; | ||
export declare function getBytes(stream: NodeJS.ReadableStream | ReadableStream<Uint8Array>, onChunk: (arr: Uint8Array) => void): Promise<void>; | ||
export declare function getLines(onLine: (line: Uint8Array, fieldLength: number) => void): (arr: Uint8Array) => void; | ||
export declare function getMessages(onId: (id: string) => void, onRetry: (retry: number) => void, onMessage?: (msg: EventSourceMessage) => void): (line: Uint8Array, fieldLength: number) => void; |
@@ -10,2 +10,10 @@ var __asyncValues = (this && this.__asyncValues) || function (o) { | ||
var _a, e_1, _b, _c; | ||
if ('getReader' in stream) { | ||
const reader = stream.getReader(); | ||
let result; | ||
while (!(result = await reader.read()).done) { | ||
onChunk(result.value); | ||
} | ||
return; | ||
} | ||
try { | ||
@@ -12,0 +20,0 @@ for (var _d = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = await stream_1.next(), _a = stream_1_1.done, !_a;) { |
{ | ||
"name": "@ai-zen/node-fetch-event-source", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "A better API for making Event Source requests, with all the features of node-fetch", | ||
@@ -26,3 +26,3 @@ "homepage": "https://github.com/Azure/fetch-event-source#readme", | ||
"dependencies": { | ||
"node-fetch": "^3.3.1" | ||
"cross-fetch": "^3.1.8" | ||
}, | ||
@@ -29,0 +29,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
63671
792
+ Addedcross-fetch@^3.1.8
+ Addedcross-fetch@3.1.8(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removednode-fetch@^3.3.1
- Removeddata-uri-to-buffer@4.0.1(transitive)
- Removedfetch-blob@3.2.0(transitive)
- Removedformdata-polyfill@4.0.10(transitive)
- Removednode-domexception@1.0.0(transitive)
- Removednode-fetch@3.3.2(transitive)
- Removedweb-streams-polyfill@3.3.3(transitive)