@rdfjs/fetch-lite
Advanced tools
Comparing version 3.2.2 to 3.2.3
@@ -8,6 +8,6 @@ import fetch, { Headers } from './index.js' | ||
return fetch(url, { | ||
fetch: context._fetch.fetch, | ||
formats: context.formats, | ||
...options, | ||
factory, | ||
fetch: context._fetch.fetch, | ||
formats: context.formats | ||
factory | ||
}) | ||
@@ -14,0 +14,0 @@ } |
{ | ||
"name": "@rdfjs/fetch-lite", | ||
"version": "3.2.2", | ||
"version": "3.2.3", | ||
"description": "Wrapper for fetch to simplify sending and receiving RDF data", | ||
@@ -29,21 +29,21 @@ "type": "module", | ||
"dependencies": { | ||
"is-stream": "^3.0.0", | ||
"is-stream": "^4.0.1", | ||
"nodeify-fetch": "^3.1.0", | ||
"readable-stream": "^4.4.2" | ||
"readable-stream": "^4.5.2" | ||
}, | ||
"devDependencies": { | ||
"@rdfjs/data-model": "^2.0.1", | ||
"@rdfjs/dataset": "^2.0.1", | ||
"@rdfjs/environment": "^0.1.2", | ||
"@rdfjs/formats-common": "^3.1.0", | ||
"@rdfjs/sink-map": "^2.0.0", | ||
"@rdfjs/to-ntriples": "^2.0.0", | ||
"@rdfjs/data-model": "^2.0.2", | ||
"@rdfjs/dataset": "^2.0.2", | ||
"@rdfjs/environment": "^1.0.0", | ||
"@rdfjs/formats": "^4.0.0", | ||
"@rdfjs/sink-map": "^2.0.1", | ||
"@rdfjs/to-ntriples": "^3.0.1", | ||
"assert": "^2.1.0", | ||
"c8": "^8.0.1", | ||
"express-as-promise": "^1.2.0", | ||
"mocha": "^10.2.0", | ||
"c8": "^9.1.0", | ||
"express-as-promise": "^2.0.0", | ||
"mocha": "^10.4.0", | ||
"stream-chunks": "^1.0.0", | ||
"stricter-standard": "^0.3.0", | ||
"stricter-standard": "^0.3.1", | ||
"test-runner-browser": "^0.1.0" | ||
} | ||
} |
import { strictEqual } from 'assert' | ||
import DatasetFactory from '@rdfjs/dataset/Factory.js' | ||
import formats from '@rdfjs/formats-common' | ||
import formats from '@rdfjs/formats' | ||
import { describe, it } from 'mocha' | ||
@@ -5,0 +5,0 @@ import rdfFetch from '../index.js' |
@@ -5,4 +5,5 @@ import { strictEqual } from 'assert' | ||
import Environment from '@rdfjs/environment' | ||
import FormatsFactory from '@rdfjs/environment/FormatsFactory.js' | ||
import formats from '@rdfjs/formats-common' | ||
import formats from '@rdfjs/formats' | ||
import FormatsFactory from '@rdfjs/formats/Factory.js' | ||
import SinkMap from '@rdfjs/sink-map' | ||
import toNT from '@rdfjs/to-ntriples' | ||
@@ -110,2 +111,33 @@ import withServer from 'express-as-promise/withServer.js' | ||
it('should allow overwriting the formats', async () => { | ||
await withServer(async server => { | ||
let called = false | ||
class CustomParser extends formats.parsers.get('text/turtle').constructor { | ||
import (stream) { | ||
called = true | ||
return super.import(stream) | ||
} | ||
} | ||
const customFormats = { | ||
parsers: new SinkMap([['text/turtle', new CustomParser()]]) | ||
} | ||
const env = new Environment([DataFactory, DatasetFactory, FetchFactory, FormatsFactory]) | ||
env.formats.import(formats) | ||
server.app.get('/', (req, res) => { | ||
res.set('content-type', 'text/turtle').end(toNT(example.quad)) | ||
}) | ||
const res = await env.fetch(await server.listen(), { | ||
formats: customFormats | ||
}) | ||
await res.dataset() | ||
strictEqual(called, true) | ||
}) | ||
}) | ||
it('should use an alternative fetch implementation if set in the config', async () => { | ||
@@ -132,2 +164,25 @@ await withServer(async server => { | ||
}) | ||
it('should allow overwriting the fetch implementation', async () => { | ||
await withServer(async server => { | ||
let called = false | ||
const customFetch = (url, options) => { | ||
called = true | ||
return nodeFetch(url, options) | ||
} | ||
const env = new Environment([DataFactory, FetchFactory, FormatsFactory]) | ||
env.formats.import(formats) | ||
server.app.get('/', (req, res) => { | ||
res.set('content-type', 'text/turtle').end(toNT(example.quad)) | ||
}) | ||
await env.fetch(await server.listen(), { | ||
fetch: customFetch | ||
}) | ||
strictEqual(called, true) | ||
}) | ||
}) | ||
}) | ||
@@ -134,0 +189,0 @@ |
import { rejects, strictEqual } from 'assert' | ||
import formats from '@rdfjs/formats-common' | ||
import formats from '@rdfjs/formats' | ||
import SinkMap from '@rdfjs/sink-map' | ||
@@ -4,0 +4,0 @@ import { describe, it } from 'mocha' |
import { deepStrictEqual, rejects, strictEqual } from 'assert' | ||
import rdfDataset from '@rdfjs/dataset' | ||
import formats from '@rdfjs/formats-common' | ||
import formats from '@rdfjs/formats' | ||
import SinkMap from '@rdfjs/sink-map' | ||
@@ -5,0 +5,0 @@ import { isReadableStream } from 'is-stream' |
@@ -59,3 +59,3 @@ import { text } from 'express' | ||
await withServer(async server => { | ||
context.baseUrl = await server.listen() | ||
context.baseUrl = (await server.listen()).toString() | ||
@@ -62,0 +62,0 @@ for (const [path, config] of Object.entries(resources)) { |
Sorry, the diff of this file is not supported yet
42722
24
1045
+ Addedis-stream@4.0.1(transitive)
- Removedis-stream@3.0.0(transitive)
Updatedis-stream@^4.0.1
Updatedreadable-stream@^4.5.2