microdata-rdf-streaming-parser
Advanced tools
Comparing version 1.2.0 to 2.0.0
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -9,5 +9,3 @@ /** | ||
name: string; | ||
attributes: { | ||
[s: string]: string; | ||
}; | ||
attributes: Record<string, string>; | ||
} | { | ||
@@ -14,0 +12,0 @@ type: 'text'; |
@@ -10,5 +10,3 @@ /** | ||
*/ | ||
onTagOpen: (name: string, attributes: { | ||
[s: string]: string; | ||
}) => void; | ||
onTagOpen: (name: string, attributes: Record<string, string>) => void; | ||
/** | ||
@@ -15,0 +13,0 @@ * Called when a tag is closed. |
@@ -22,8 +22,6 @@ import type * as RDF from '@rdfjs/types'; | ||
*/ | ||
predicates?: { | ||
[depth: number]: { | ||
forward?: RDF.NamedNode[]; | ||
reverse?: RDF.NamedNode[]; | ||
}; | ||
}; | ||
predicates?: Record<number, { | ||
forward?: RDF.NamedNode[]; | ||
reverse?: RDF.NamedNode[]; | ||
}>; | ||
/** | ||
@@ -30,0 +28,0 @@ * If triples from this scope must NOT be emitted. |
@@ -7,10 +7,4 @@ /** | ||
*/ | ||
export interface IVocabRegistry { | ||
[uriPrefix: string]: { | ||
properties?: { | ||
[property: string]: { | ||
[name: string]: string; | ||
}; | ||
}; | ||
}; | ||
} | ||
export declare type IVocabRegistry = Record<string, { | ||
properties?: Record<string, Record<string, string>>; | ||
}>; |
/// <reference types="node" /> | ||
import type { TransformCallback } from 'stream'; | ||
import { Transform } from 'stream'; | ||
import type * as RDF from '@rdfjs/types'; | ||
import { Parser as HtmlParser } from 'htmlparser2'; | ||
import { Transform } from 'readable-stream'; | ||
import type { IHtmlParseListener } from './IHtmlParseListener'; | ||
@@ -35,4 +34,4 @@ import type { IItemScope } from './IItemScope'; | ||
import(stream: EventEmitter): RDF.Stream; | ||
_transform(chunk: any, encoding: string, callback: TransformCallback): void; | ||
_flush(callback: TransformCallback): void; | ||
_transform(chunk: any, encoding: string, callback: (error?: Error | null, data?: any) => void): void; | ||
_flush(callback: (error?: Error | null, data?: any) => void): void; | ||
/** | ||
@@ -48,5 +47,3 @@ * Get the current item scope for the current depth. | ||
protected getDepth(): number; | ||
onTagOpen(name: string, attributes: { | ||
[s: string]: string; | ||
}): void; | ||
onTagOpen(name: string, attributes: Record<string, string>): void; | ||
onText(data: string): void; | ||
@@ -68,5 +65,3 @@ onTagClose(): void; | ||
*/ | ||
protected handleItemProperties(itempropValue: string, reverse: boolean, itemScope: IItemScope | undefined, tagName: string, tagAttributes: { | ||
[s: string]: string; | ||
}): void; | ||
protected handleItemProperties(itempropValue: string, reverse: boolean, itemScope: IItemScope | undefined, tagName: string, tagAttributes: Record<string, string>): void; | ||
/** | ||
@@ -73,0 +68,0 @@ * Emit the given object for the given predicates. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MicrodataRdfParser = void 0; | ||
const stream_1 = require("stream"); | ||
const htmlparser2_1 = require("htmlparser2"); | ||
const readable_stream_1 = require("readable-stream"); | ||
const ItemPropertyHandlerContent_1 = require("./propertyhandler/ItemPropertyHandlerContent"); | ||
@@ -15,3 +15,3 @@ const ItemPropertyHandlerNumber_1 = require("./propertyhandler/ItemPropertyHandlerNumber"); | ||
*/ | ||
class MicrodataRdfParser extends stream_1.Transform { | ||
class MicrodataRdfParser extends readable_stream_1.Transform { | ||
constructor(options) { | ||
@@ -42,3 +42,3 @@ super({ readableObjectMode: true }); | ||
import(stream) { | ||
const output = new stream_1.PassThrough({ readableObjectMode: true }); | ||
const output = new readable_stream_1.PassThrough({ readableObjectMode: true }); | ||
stream.on('error', (error) => parsed.emit('error', error)); | ||
@@ -51,3 +51,3 @@ stream.on('data', (data) => output.push(data)); | ||
_transform(chunk, encoding, callback) { | ||
this.parser.write(chunk); | ||
this.parser.write(chunk.toString()); | ||
callback(); | ||
@@ -95,3 +95,2 @@ } | ||
// Ensure the text buffer stack is in line with the stack depth | ||
// eslint-disable-next-line unicorn/no-useless-undefined | ||
this.textBufferStack.push(undefined); | ||
@@ -132,3 +131,2 @@ // Processing steps based on https://w3c.github.io/microdata-rdf/#rdf-conversion-algorithm | ||
// 2. Push any changes to the item scope to the stack | ||
// eslint-disable-next-line unicorn/no-useless-undefined | ||
this.itemScopeStack.push(undefined); | ||
@@ -160,12 +158,11 @@ } | ||
// Handle itemrefs (only if we also had an itemscope) | ||
if ('itemscope' in attributes) { | ||
// If we have an itemref, store it in our domain buffer. | ||
if (!this.isEmittingReferences && 'itemref' in attributes) { | ||
for (const reference of attributes.itemref.split(/\s+/u)) { | ||
if (!(reference in this.pendingItemRefsDomain)) { | ||
this.pendingItemRefsDomain[reference] = []; | ||
} | ||
this.pendingItemRefsDomain[reference].push(itemScope); | ||
this.tryToEmitReferences(reference, itemScope); | ||
// If we have an itemref, store it in our domain buffer. | ||
if ('itemscope' in attributes && | ||
!this.isEmittingReferences && 'itemref' in attributes) { | ||
for (const reference of attributes.itemref.split(/\s+/u)) { | ||
if (!(reference in this.pendingItemRefsDomain)) { | ||
this.pendingItemRefsDomain[reference] = []; | ||
} | ||
this.pendingItemRefsDomain[reference].push(itemScope); | ||
this.tryToEmitReferences(reference, itemScope); | ||
} | ||
@@ -401,3 +398,3 @@ } | ||
this.textBufferStack = [undefined]; | ||
const pendingIds = range.ids.slice(); | ||
const pendingIds = [...range.ids]; | ||
this.emittingReferencesItemScopeIdGenerator = () => pendingIds.shift(); | ||
@@ -404,0 +401,0 @@ for (const event of range.events) { |
@@ -8,8 +8,4 @@ import type * as RDF from '@rdfjs/types'; | ||
export interface IItemPropertyHandler { | ||
canHandle: (tagName: string, attributes: { | ||
[s: string]: string; | ||
}) => boolean; | ||
getObject: (attributes: { | ||
[s: string]: string; | ||
}, util: Util, itemScope: IItemScope) => RDF.Quad_Object; | ||
canHandle: (tagName: string, attributes: Record<string, string>) => boolean; | ||
getObject: (attributes: Record<string, string>, util: Util, itemScope: IItemScope) => RDF.Quad_Object; | ||
} |
@@ -9,8 +9,4 @@ import type * as RDF from '@rdfjs/types'; | ||
export declare class ItemPropertyHandlerContent implements IItemPropertyHandler { | ||
canHandle(tagName: string, attributes: { | ||
[p: string]: string; | ||
}): boolean; | ||
getObject(attributes: { | ||
[p: string]: string; | ||
}, util: Util, itemScope: IItemScope): RDF.Quad_Object; | ||
canHandle(tagName: string, attributes: Record<string, string>): boolean; | ||
getObject(attributes: Record<string, string>, util: Util, itemScope: IItemScope): RDF.Quad_Object; | ||
} |
@@ -12,8 +12,4 @@ import type * as RDF from '@rdfjs/types'; | ||
constructor(tagName: string, attributeName: string); | ||
canHandle(tagName: string, attributes: { | ||
[p: string]: string; | ||
}): boolean; | ||
getObject(attributes: { | ||
[p: string]: string; | ||
}, util: Util, itemScope: IItemScope): RDF.Quad_Object; | ||
canHandle(tagName: string, attributes: Record<string, string>): boolean; | ||
getObject(attributes: Record<string, string>, util: Util, itemScope: IItemScope): RDF.Quad_Object; | ||
} |
@@ -10,8 +10,4 @@ import type * as RDF from '@rdfjs/types'; | ||
private static readonly TIME_REGEXES; | ||
canHandle(tagName: string, attributes: { | ||
[p: string]: string; | ||
}): boolean; | ||
getObject(attributes: { | ||
[p: string]: string; | ||
}, util: Util, itemScope: IItemScope): RDF.Quad_Object; | ||
canHandle(tagName: string, attributes: Record<string, string>): boolean; | ||
getObject(attributes: Record<string, string>, util: Util, itemScope: IItemScope): RDF.Quad_Object; | ||
} |
@@ -16,3 +16,3 @@ "use strict"; | ||
for (const entry of ItemPropertyHandlerTime.TIME_REGEXES) { | ||
if (entry.regex.exec(value)) { | ||
if (entry.regex.test(value)) { | ||
datatype = util.dataFactory.namedNode(Util_1.Util.XSD + entry.type); | ||
@@ -19,0 +19,0 @@ break; |
@@ -12,8 +12,4 @@ import type * as RDF from '@rdfjs/types'; | ||
constructor(tagName: string, attributeName: string); | ||
canHandle(tagName: string, attributes: { | ||
[p: string]: string; | ||
}): boolean; | ||
getObject(attributes: { | ||
[p: string]: string; | ||
}, util: Util, itemScope: IItemScope): RDF.Quad_Object; | ||
canHandle(tagName: string, attributes: Record<string, string>): boolean; | ||
getObject(attributes: Record<string, string>, util: Util, itemScope: IItemScope): RDF.Quad_Object; | ||
} |
@@ -17,3 +17,3 @@ "use strict"; | ||
getObject(attributes, util, itemScope) { | ||
return util.dataFactory.namedNode(relative_to_absolute_iri_1.resolve(attributes[this.attributeName], util.baseIRI)); | ||
return util.dataFactory.namedNode((0, relative_to_absolute_iri_1.resolve)(attributes[this.attributeName], util.baseIRI)); | ||
} | ||
@@ -20,0 +20,0 @@ } |
@@ -64,3 +64,3 @@ "use strict"; | ||
if (parts.includes(property)) { | ||
predicates = predicates.concat(Object.values(expansions).map(iri => this.dataFactory.namedNode(iri))); | ||
predicates = [...Object.values(expansions).map(iri => this.dataFactory.namedNode(iri))]; | ||
} | ||
@@ -80,3 +80,3 @@ } | ||
try { | ||
iri = relative_to_absolute_iri_1.resolve(iri, this.baseIRI); | ||
iri = (0, relative_to_absolute_iri_1.resolve)(iri, this.baseIRI); | ||
} | ||
@@ -124,3 +124,3 @@ catch (_a) { | ||
else { | ||
vocab = relative_to_absolute_iri_1.resolve('.', typeIri); | ||
vocab = (0, relative_to_absolute_iri_1.resolve)('.', typeIri); | ||
} | ||
@@ -127,0 +127,0 @@ } |
{ | ||
"name": "microdata-rdf-streaming-parser", | ||
"version": "1.2.0", | ||
"version": "2.0.0", | ||
"description": "A fast and lightweight streaming Microdata to RDF parser", | ||
@@ -32,4 +32,5 @@ "keywords": [ | ||
"@rdfjs/types": "*", | ||
"htmlparser2": "^6.0.0", | ||
"htmlparser2": "^8.0.0", | ||
"rdf-data-factory": "^1.1.0", | ||
"readable-stream": "^4.1.0", | ||
"relative-to-absolute-iri": "^1.0.2" | ||
@@ -44,8 +45,8 @@ }, | ||
"@rubensworks/eslint-config": "^1.0.0", | ||
"@types/jest": "^26.0.0", | ||
"@types/jest": "^28.0.0", | ||
"@types/jest-each": "^24.3.0", | ||
"@types/node": "^13.1.0", | ||
"@typescript-eslint/eslint-plugin": "^4.2.0", | ||
"@typescript-eslint/parser": "^4.1.1", | ||
"arrayify-stream": "^1.0.0", | ||
"@types/readable-stream": "^2.3.14", | ||
"@typescript-eslint/eslint-plugin": "^5.0.0", | ||
"@typescript-eslint/parser": "^5.0.0", | ||
"arrayify-stream": "^2.0.0", | ||
"coveralls": "^3.0.0", | ||
@@ -56,7 +57,7 @@ "eslint": "^7.9.0", | ||
"eslint-plugin-import": "^2.22.0", | ||
"eslint-plugin-jest": "^24.0.2", | ||
"eslint-plugin-jest": "^25.0.0", | ||
"eslint-plugin-tsdoc": "^0.2.7", | ||
"eslint-plugin-unused-imports": "^1.0.0", | ||
"jest": "^26.0.0", | ||
"jest-each": "^26.0.0", | ||
"eslint-plugin-unused-imports": "^2.0.0", | ||
"jest": "^28.0.0", | ||
"jest-each": "^28.0.0", | ||
"jest-rdf": "^1.7.0", | ||
@@ -68,4 +69,7 @@ "manual-git-changelog": "^1.0.1", | ||
"streamify-string": "^1.0.1", | ||
"ts-jest": "^26.0.0", | ||
"typescript": "^4.3.5" | ||
"ts-jest": "^28.0.0", | ||
"ts-loader": "^9.3.1", | ||
"typescript": "^4.3.5", | ||
"webpack": "^5.73.0", | ||
"webpack-cli": "^4.10.0" | ||
}, | ||
@@ -109,5 +113,3 @@ "jest": { | ||
}, | ||
"resolutions": { | ||
"@types/rdf-js": "^4.0.0" | ||
} | ||
"sideEffects": false | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52351
5
28
1030
+ Addedreadable-stream@^4.1.0
+ Addedabort-controller@3.0.0(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addeddom-serializer@2.0.0(transitive)
+ Addeddomhandler@5.0.3(transitive)
+ Addeddomutils@3.1.0(transitive)
+ Addedentities@4.5.0(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedhtmlparser2@8.0.2(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedprocess@0.11.10(transitive)
+ Addedreadable-stream@4.5.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
- Removeddom-serializer@1.4.1(transitive)
- Removeddomhandler@4.3.1(transitive)
- Removeddomutils@2.8.0(transitive)
- Removedentities@2.2.0(transitive)
- Removedhtmlparser2@6.1.0(transitive)
Updatedhtmlparser2@^8.0.0