Skip to content

Commit f4887f3

Browse files
authored
BREAKING CHANGE: Make class Term constructors internal (#338)
These constructors take the `id` at face value so can be interpreted as the wrong term type if an invalid value is given; for instance a `NamedNode` can be interpred as a `Literal` if instantiated with `new NamedNode('"hellow world"')`. Consumers of the library should use the `DataFactory` instead to create new terms.
1 parent e733c1f commit f4887f3

14 files changed

+27
-49
lines changed

src/index.js

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@ import * as Util from './N3Util';
99
import {
1010
default as DataFactory,
1111

12-
Term,
13-
NamedNode,
14-
Literal,
15-
BlankNode,
16-
Variable,
17-
DefaultGraph,
18-
Quad,
19-
Triple,
20-
2112
termFromId,
2213
termToId,
2314
} from './N3DataFactory';
@@ -34,15 +25,6 @@ export {
3425

3526
DataFactory,
3627

37-
Term,
38-
NamedNode,
39-
Literal,
40-
BlankNode,
41-
Variable,
42-
DefaultGraph,
43-
Quad,
44-
Triple,
45-
4628
termFromId,
4729
termToId,
4830
};
@@ -59,15 +41,6 @@ export default {
5941

6042
DataFactory,
6143

62-
Term,
63-
NamedNode,
64-
Literal,
65-
BlankNode,
66-
Variable,
67-
DefaultGraph,
68-
Quad,
69-
Triple,
70-
7144
termFromId,
7245
termToId,
7346
};

test/BlankNode-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BlankNode, Term } from '../src/';
1+
import { BlankNode, Term } from '../src/N3DataFactory';
22

33
describe('BlankNode', () => {
44
describe('The BlankNode module', () => {

test/DefaultGraph-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DefaultGraph, Term } from '../src/';
1+
import { DefaultGraph, Term } from '../src/N3DataFactory';
22

33
describe('DefaultGraph', () => {
44
describe('The DefaultGraph module', () => {

test/Literal-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Literal, NamedNode, Term } from '../src/';
1+
import { Literal, NamedNode, Term } from '../src/N3DataFactory';
22

33
describe('Literal', () => {
44
describe('The Literal module', () => {

test/N3DataFactory-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {
2-
DataFactory,
32
NamedNode,
43
Literal,
54
BlankNode,
65
Variable,
76
DefaultGraph,
87
Quad,
9-
} from '../src/';
8+
} from '../src/N3DataFactory';
9+
import { DataFactory } from '../src';
1010

1111
describe('DataFactory', () => {
1212
describe('namedNode', () => {

test/N3Parser-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Parser, NamedNode, BlankNode, Quad, termFromId } from '../src/';
1+
import { Parser, termFromId } from '../src/';
2+
import { NamedNode, BlankNode, Quad } from '../src/N3DataFactory';
23

34
const BASE_IRI = 'http://example.org/';
45

test/N3Store-test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import {
22
Store,
3+
termFromId, termToId,
4+
} from '../src/';
5+
import {
36
NamedNode,
47
Literal,
58
DefaultGraph,
69
Quad,
7-
termFromId, termToId,
8-
} from '../src/';
10+
} from '../src/N3DataFactory';
911
import namespaces from '../src/IRIs';
1012
import chai, { expect } from 'chai';
1113
import { Readable } from 'readable-stream';

test/N3StreamParser-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { StreamParser, NamedNode } from '../src/';
1+
import { StreamParser } from '../src/';
2+
import { NamedNode } from '../src/N3DataFactory';
23
import { Readable, Writable } from 'readable-stream';
34

45
describe('StreamParser', () => {

test/N3StreamWriter-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { StreamWriter, Quad, NamedNode, termFromId } from '../src/';
1+
import { StreamWriter, termFromId } from '../src/';
2+
import { Quad, NamedNode } from '../src/N3DataFactory';
23
import { Readable, Writable } from 'readable-stream';
34

45
describe('StreamWriter', () => {

test/N3Writer-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {
22
Writer,
3-
NamedNode,
4-
BlankNode,
5-
Literal,
6-
Quad,
73
termFromId,
84
} from '../src/';
5+
import { NamedNode,
6+
BlankNode,
7+
Literal,
8+
Quad } from '../src/N3DataFactory';
99
import namespaces from '../src/IRIs';
1010

1111
const { xsd } = namespaces;

0 commit comments

Comments
 (0)