{"library":"rdfa-streaming-parser","title":"RDFa Streaming Parser","description":"The `rdfa-streaming-parser` package provides a high-performance, lightweight, and 100% spec-compliant streaming parser for RDFa 1.1 data. It is currently at version 3.0.2. This library is designed to emit RDFJS-compliant quads as soon as possible, enabling the efficient parsing of documents larger than available memory. Its streaming nature leverages Node.js Transform streams, allowing for direct piping of input sources like file streams. It also implements the RDFJS Sink interface for alternative stream processing. Key differentiators include its strict adherence to the RDFa 1.1 specification, its low memory footprint due to streaming, and its compatibility with the RDFJS ecosystem for data representation. The release cadence appears stable, with major version 3 indicating significant updates from previous iterations.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install rdfa-streaming-parser"],"cli":null},"imports":["import { RdfaParser } from 'rdfa-streaming-parser';","const { RdfaParser } = require('rdfa-streaming-parser');","import type { RdfaParser } from 'rdfa-streaming-parser';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { RdfaParser } from 'rdfa-streaming-parser';\nimport * as fs from 'fs'; // Node.js built-in module\n\nasync function parseRdfaFile(filePath: string, baseIri: string, contentType: string) {\n  const myParser = new RdfaParser({ baseIRI: baseIri, contentType: contentType });\n\n  console.log(`Parsing RDFa from ${filePath}...`);\n\n  return new Promise<void>((resolve, reject) => {\n    fs.createReadStream(filePath)\n      .pipe(myParser)\n      .on('data', (quad) => {\n        console.log(`Parsed quad: ${quad.subject.value} ${quad.predicate.value} ${quad.object.value} .`);\n      })\n      .on('error', (error) => {\n        console.error('An error occurred during parsing:', error);\n        reject(error);\n      })\n      .on('end', () => {\n        console.log('All triples were parsed successfully!');\n        resolve();\n      });\n  });\n}\n\n// Example usage:\nconst dummyHtmlContent = `<!DOCTYPE html>\n<html>\n<head prefix=\"foaf: http://xmlns.com/foaf/0.1/\">\n  <title>Example Document</title>\n  <link rel=\"foaf:primaryTopic foaf:maker\" href=\"https://www.rubensworks.net/#me\" />\n</head>\n<body>\n  <h1>Hello RDFa</h1>\n  <p>This is an <span property=\"foaf:name\">RDFa Example</span>.</p>\n</body>\n</html>`;\n\nconst tempFilePath = 'temp_rdfa_doc.html';\nfs.writeFileSync(tempFilePath, dummyHtmlContent);\n\nparseRdfaFile(tempFilePath, 'https://example.org/doc#', 'text/html')\n  .finally(() => {\n    fs.unlinkSync(tempFilePath); // Clean up the temporary file\n  });","lang":"typescript","description":"This quickstart demonstrates how to parse an RDFa document from a file stream using `RdfaParser`, log the extracted RDFJS quads, and gracefully handle completion or errors. A temporary HTML file is created and then cleaned up.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}