fix(rdf-fetch): options are optional (#43294)

* feix(rdf-fetch): options are optional

* options are also optional
This commit is contained in:
Tomasz Pluskiewicz 2020-03-22 21:48:21 +01:00 committed by GitHub
parent 0e3a2e2cf8
commit cf0edd580e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -6,9 +6,9 @@
import { FormatsInit, RdfFetchResponse, FactoryInit, DatasetResponse } from '@rdfjs/fetch-lite';
import { DatasetCore, Quad, BaseQuad } from 'rdf-js';
declare function rdfFetch(url: string, options: FormatsInit): Promise<RdfFetchResponse>;
declare function rdfFetch(url: string, options?: Partial<FormatsInit>): Promise<RdfFetchResponse>;
declare function rdfFetch <D extends DatasetCore<OutQuad, InQuad>, OutQuad extends BaseQuad = Quad, InQuad extends BaseQuad = OutQuad>(
url: string,
options: FactoryInit<D, OutQuad, InQuad>): Promise<DatasetResponse<D, OutQuad, InQuad>>;
options?: Partial<FactoryInit<D, OutQuad, InQuad>>): Promise<DatasetResponse<D, OutQuad, InQuad>>;
export = rdfFetch;

View File

@ -2,11 +2,20 @@ import fetch = require('@rdfjs/fetch');
import { SinkMap } from '@rdfjs/sink-map';
import { Stream, Dataset, Quad, DatasetCoreFactory } from 'rdf-js';
import { EventEmitter } from 'events';
import { RdfFetchResponse } from '@rdfjs/fetch-lite';
const formats: {
parsers: SinkMap<EventEmitter, Stream>;
} = <any> {};
function noOptions(): Promise<RdfFetchResponse> {
return fetch('http://example.com/');
}
function allOptionsOptional(): Promise<RdfFetchResponse> {
return fetch('http://example.com/', {});
}
async function fetchString(): Promise<string> {
const response = await fetch('http://example.com', { formats });
return response.text();