rdf-data-factory
Advanced tools
Comparing version 1.0.3 to 1.0.4
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
<a name="v1.0.4"></a> | ||
## [v1.0.4](https://github.com/rubensworks/rdf-data-factory.js/compare/v1.0.3...v1.0.4) - 2020-10-14 | ||
### Fixed | ||
* [Fix blank node clashes across multiple factory instances](https://github.com/rubensworks/rdf-data-factory.js/commit/ae8467f1cf14da78e643fdb5c31391d4d7751aa3) | ||
<a name="v1.0.3"></a> | ||
@@ -5,0 +11,0 @@ ## [v1.0.3](https://github.com/rubensworks/rdf-data-factory.js/compare/v1.0.2...v1.0.3) - 2020-09-16 |
@@ -1,2 +0,2 @@ | ||
import * as RDF from 'rdf-js'; | ||
import type * as RDF from 'rdf-js'; | ||
/** | ||
@@ -9,3 +9,3 @@ * A term that represents an RDF blank node with a label. | ||
constructor(value: string); | ||
equals(other: RDF.Term | null | undefined): boolean; | ||
equals(other?: RDF.Term | null): boolean; | ||
} |
@@ -1,2 +0,2 @@ | ||
import * as RDF from 'rdf-js'; | ||
import type * as RDF from 'rdf-js'; | ||
import { BlankNode } from './BlankNode'; | ||
@@ -12,3 +12,5 @@ import { DefaultGraph } from './DefaultGraph'; | ||
export declare class DataFactory<Q extends RDF.BaseQuad = RDF.Quad> implements RDF.DataFactory<Q> { | ||
private readonly blankNodePrefix; | ||
private blankNodeCounter; | ||
constructor(options?: IDataFactoryOptions); | ||
/** | ||
@@ -76,1 +78,4 @@ * @param value The IRI for the named node. | ||
} | ||
export interface IDataFactoryOptions { | ||
blankNodePrefix?: string; | ||
} |
@@ -10,2 +10,3 @@ "use strict"; | ||
const Variable_1 = require("./Variable"); | ||
let dataFactoryCounter = 0; | ||
/** | ||
@@ -15,4 +16,6 @@ * A factory for instantiating RDF terms and quads. | ||
class DataFactory { | ||
constructor() { | ||
constructor(options) { | ||
this.blankNodeCounter = 0; | ||
options = options || {}; | ||
this.blankNodePrefix = options.blankNodePrefix || `df_${dataFactoryCounter++}_`; | ||
} | ||
@@ -35,3 +38,3 @@ /** | ||
blankNode(value) { | ||
return new BlankNode_1.BlankNode(value || `df_${this.blankNodeCounter++}`); | ||
return new BlankNode_1.BlankNode(value || `${this.blankNodePrefix}${this.blankNodeCounter++}`); | ||
} | ||
@@ -38,0 +41,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import * as RDF from 'rdf-js'; | ||
import type * as RDF from 'rdf-js'; | ||
/** | ||
@@ -11,3 +11,3 @@ * A singleton term instance that represents the default graph. | ||
private constructor(); | ||
equals(other: RDF.Term | null | undefined): boolean; | ||
equals(other?: RDF.Term | null): boolean; | ||
} |
@@ -1,2 +0,2 @@ | ||
import * as RDF from 'rdf-js'; | ||
import type * as RDF from 'rdf-js'; | ||
/** | ||
@@ -13,3 +13,3 @@ * A term that represents an RDF literal, containing a string with an optional language tag or datatype. | ||
constructor(value: string, languageOrDatatype?: string | RDF.NamedNode); | ||
equals(other: RDF.Term | null | undefined): boolean; | ||
equals(other?: RDF.Term | null): boolean; | ||
} |
@@ -1,2 +0,2 @@ | ||
import * as RDF from 'rdf-js'; | ||
import type * as RDF from 'rdf-js'; | ||
/** | ||
@@ -9,3 +9,3 @@ * A term that contains an IRI. | ||
constructor(value: Iri); | ||
equals(other: RDF.Term | null | undefined): boolean; | ||
equals(other?: RDF.Term | null): boolean; | ||
} |
@@ -1,2 +0,2 @@ | ||
import * as RDF from 'rdf-js'; | ||
import type * as RDF from 'rdf-js'; | ||
/** | ||
@@ -14,3 +14,3 @@ * An instance of DefaultGraph represents the default graph. | ||
constructor(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term, graph: RDF.Term); | ||
equals(other: RDF.Term | null | undefined): boolean; | ||
equals(other?: RDF.Term | null): boolean; | ||
} |
@@ -1,2 +0,2 @@ | ||
import * as RDF from 'rdf-js'; | ||
import type * as RDF from 'rdf-js'; | ||
/** | ||
@@ -9,3 +9,3 @@ * A term that represents a variable. | ||
constructor(value: string); | ||
equals(other: RDF.Term | null | undefined): boolean; | ||
equals(other?: RDF.Term | null): boolean; | ||
} |
{ | ||
"name": "rdf-data-factory", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A TypeScript/JavaScript implementation of the RDF/JS data factory.", | ||
@@ -37,11 +37,14 @@ "keywords": [ | ||
"devDependencies": { | ||
"@rubensworks/eslint-config": "^1.0.0", | ||
"@types/jest": "^26.0.0", | ||
"@types/rdf-js": "^4.0.0", | ||
"@typescript-eslint/eslint-plugin": "^4.2.0", | ||
"@typescript-eslint/parser": "^4.1.1", | ||
"coveralls": "^3.0.0", | ||
"eslint": "^7.5.0", | ||
"eslint-config-es": "^3.19.64", | ||
"eslint-import-resolver-typescript": "^2.0.0", | ||
"eslint": "^7.9.0", | ||
"eslint-config-es": "^3.23.0", | ||
"eslint-import-resolver-typescript": "^2.3.0", | ||
"eslint-plugin-import": "^2.22.0", | ||
"eslint-plugin-jest": "^24.0.0", | ||
"eslint-plugin-tsdoc": "^0.2.6", | ||
"eslint-plugin-jest": "^24.0.2", | ||
"eslint-plugin-tsdoc": "^0.2.7", | ||
"eslint-plugin-unused-imports": "^0.1.3", | ||
@@ -48,0 +51,0 @@ "jest": "^26.0.0", |
@@ -43,2 +43,9 @@ # RDF Data Factory | ||
You can pass the following option to define a blank node prefix: | ||
```typescript | ||
const factory: RDF.DataFactory = new DataFactory({ blankNodePrefix: 'bnode_' }); | ||
``` | ||
If no `blankNodePrefix` is passed, it will generate a unique prefix of the form `df_[0-9]+_`, | ||
which ensures there will be no blank nodes clashes when instantiating multiple factories. | ||
### Creating named nodes | ||
@@ -45,0 +52,0 @@ |
27213
422
207
19