Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@rdfjs/fetch
Advanced tools
Wrapper for fetch to simplify sending and retrieving RDF data.
Since version 3.0, this packages is ESM only. Check version 2.x if you are looking for a CommonJS package.
The package exports a fetch
function which wraps the request and response object for on-the-fly RDF quad processing.
The function accepts the same parameters as fetch and some additional options.
It also provides extra methods.
The options
object accepts the following additional parameters:
formats
: A formats-common-compatible object which contains a set of parsers and serializers.
By default formats-common is used.factory
: The factory which will be used to create a Dataset when dataset()
is called.
By default @rdfjs/dataset is used.fetch
: An alternative fetch implementation.
By default nodeify-fetch is used.The following options
influence the logic of RDF quad processing:
headers.accept
: The accept header field will be automatically set base on the list of available parsers from the formats
object.
If it's already set it will not be overwritten.
This can be useful when only a subset of the available parsers should be used.headers.content-type
: When the request has a body, this header field will be automatically set to use matching media type for the corresponding serializer.
By setting this field manually a specific serializer can be enforced.body
: If the request should send quads, the quads must be given either as a stream or as an iterable like a DatasetCore object.
Iterables will be converted to streams before they are handed over to the serializer.The following methods are attached to the standard fetch response object:
quadStream()
: This method returns the quads of the response as stream.
The parser is selected based on the content type header field.dataset()
: This method uses the quadStream()
method to parse the content and will pipe it into a dataset, which is also the return value.This example fetches the RDF Schema vocab and loops over all quad using the dataset API.
For all rdfs:label
quads the object value is written to the console.
import fetch from '@rdfjs/fetch'
const label = 'http://www.w3.org/2000/01/rdf-schema#label'
fetch('http://www.w3.org/2000/01/rdf-schema')
.then(res => res.dataset())
.then(dataset => {
for (const quad of dataset) {
if (quad.predicate.value === label) {
console.log(`${quad.subject.value}: ${quad.object.value}`)
}
}
})
.catch(err => console.error(err))
FAQs
Wrapper for fetch to simplify sending and receiving RDF data
The npm package @rdfjs/fetch receives a total of 5,094 weekly downloads. As such, @rdfjs/fetch popularity was classified as popular.
We found that @rdfjs/fetch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.