n3 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/browser/n3.esm.min.js +2 -2
- package/browser/n3.min.js +1 -1
- package/lib/N3Lexer.js +8 -2
- package/lib/N3Store.js +3 -1
- package/package.json +1 -1
- package/src/N3Lexer.js +11 -3
- package/src/N3Store.js +3 -1
package/lib/N3Lexer.js
CHANGED
|
@@ -242,8 +242,14 @@ class N3Lexer {
|
|
|
242
242
|
if (this._n3Mode && (match = this._variable.exec(input))) type = 'var', value = match[0];
|
|
243
243
|
break;
|
|
244
244
|
case '@':
|
|
245
|
-
// Try to find a language code
|
|
246
|
-
|
|
245
|
+
// Try to find a language code. A language code can contain dash-separated
|
|
246
|
+
// subtags, so if the match is immediately followed by a single dash and the
|
|
247
|
+
// input is not finished, another subtag may still arrive in a later chunk and
|
|
248
|
+
// the match would be premature; wait for more input in that case.
|
|
249
|
+
// A double dash starts a direction code, which cannot extend the language code.
|
|
250
|
+
if (this._previousMarker === 'literal' && (match = this._langcode.exec(input)) && match[1] !== 'version') {
|
|
251
|
+
if (!inputFinished && input[match[0].length] === '-' && input[match[0].length + 1] !== '-') match = null;else type = 'langcode', value = match[1];
|
|
252
|
+
}
|
|
247
253
|
// Try to find a keyword
|
|
248
254
|
else if (match = this._atKeyword.exec(input)) type = match[0];
|
|
249
255
|
break;
|
package/lib/N3Store.js
CHANGED
|
@@ -728,7 +728,9 @@ class N3Store {
|
|
|
728
728
|
remove = false,
|
|
729
729
|
ignoreErrors = false
|
|
730
730
|
} = {}) {
|
|
731
|
-
|
|
731
|
+
// Keys are the list heads' term values, so a null-prototype map keeps
|
|
732
|
+
// them from colliding with inherited Object members such as `toString`
|
|
733
|
+
const lists = Object.create(null);
|
|
732
734
|
const onError = ignoreErrors ? () => true : (node, message) => {
|
|
733
735
|
throw new Error(`${node.value} ${message}`);
|
|
734
736
|
};
|
package/package.json
CHANGED
package/src/N3Lexer.js
CHANGED
|
@@ -226,9 +226,17 @@ export default class N3Lexer {
|
|
|
226
226
|
break;
|
|
227
227
|
|
|
228
228
|
case '@':
|
|
229
|
-
// Try to find a language code
|
|
230
|
-
|
|
231
|
-
|
|
229
|
+
// Try to find a language code. A language code can contain dash-separated
|
|
230
|
+
// subtags, so if the match is immediately followed by a single dash and the
|
|
231
|
+
// input is not finished, another subtag may still arrive in a later chunk and
|
|
232
|
+
// the match would be premature; wait for more input in that case.
|
|
233
|
+
// A double dash starts a direction code, which cannot extend the language code.
|
|
234
|
+
if (this._previousMarker === 'literal' && (match = this._langcode.exec(input)) && match[1] !== 'version') {
|
|
235
|
+
if (!inputFinished && input[match[0].length] === '-' && input[match[0].length + 1] !== '-')
|
|
236
|
+
match = null;
|
|
237
|
+
else
|
|
238
|
+
type = 'langcode', value = match[1];
|
|
239
|
+
}
|
|
232
240
|
// Try to find a keyword
|
|
233
241
|
else if (match = this._atKeyword.exec(input))
|
|
234
242
|
type = match[0];
|
package/src/N3Store.js
CHANGED
|
@@ -759,7 +759,9 @@ export default class N3Store {
|
|
|
759
759
|
// ### `extractLists` finds and removes all list triples
|
|
760
760
|
// and returns the items per list.
|
|
761
761
|
extractLists({ remove = false, ignoreErrors = false } = {}) {
|
|
762
|
-
|
|
762
|
+
// Keys are the list heads' term values, so a null-prototype map keeps
|
|
763
|
+
// them from colliding with inherited Object members such as `toString`
|
|
764
|
+
const lists = Object.create(null);
|
|
763
765
|
const onError = ignoreErrors ? (() => true) :
|
|
764
766
|
((node, message) => { throw new Error(`${node.value} ${message}`); });
|
|
765
767
|
|