eyeling 1.16.4 → 1.17.0

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/lib/engine.js CHANGED
@@ -13,6 +13,8 @@ const {
13
13
  MATH_NS,
14
14
  LOG_NS,
15
15
  SKOLEM_NS,
16
+ MAX_LITERAL_TID_LEN,
17
+ normalizeLiteralForTid,
16
18
  Literal,
17
19
  Iri,
18
20
  Var,
@@ -921,7 +923,18 @@ function __internCompoundTid(key) {
921
923
 
922
924
  function termFastKey(t) {
923
925
  // Atomic terms that already have a stable id.
924
- if (t instanceof Iri || t instanceof Blank || t instanceof Literal) return t.__tid;
926
+ if (t instanceof Iri || t instanceof Blank) return t.__tid;
927
+
928
+ if (t instanceof Literal) {
929
+ // Very large literals intentionally skip global interning in prelude.js to
930
+ // avoid retaining huge strings forever. Their per-object __tid is therefore
931
+ // not value-stable, so using it here breaks duplicate detection for facts
932
+ // such as long log:outputString blocks that are re-derived during forward
933
+ // chaining. Fall back to a value-based key in that case.
934
+ const norm = normalizeLiteralForTid(t.value);
935
+ if (typeof norm === 'string' && norm.length > MAX_LITERAL_TID_LEN) return 'L:' + norm;
936
+ return t.__tid;
937
+ }
925
938
 
926
939
  // Structural fast key for strict-ground list terms.
927
940
  // We only index when every element has a fast key; otherwise return null.
package/lib/prelude.js CHANGED
@@ -515,6 +515,8 @@ module.exports = {
515
515
  RDF_JSON_DT,
516
516
  resolveIriRef,
517
517
  literalParts,
518
+ normalizeLiteralForTid,
519
+ MAX_LITERAL_TID_LEN,
518
520
  Term,
519
521
  Iri,
520
522
  Literal,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyeling",
3
- "version": "1.16.4",
3
+ "version": "1.17.0",
4
4
  "description": "A minimal Notation3 (N3) reasoner in JavaScript.",
5
5
  "main": "./index.js",
6
6
  "keywords": [
package/test/api.test.js CHANGED
@@ -1205,8 +1205,8 @@ _:l2 rdf:rest rdf:nil.
1205
1205
  // -------------------------
1206
1206
 
1207
1207
  {
1208
- name: '51 --strings: prints log:outputString values ordered by key (subject)',
1209
- opt: ['--strings', '-n'],
1208
+ name: '51 automatic output rendering: prints log:outputString values ordered by key (subject)',
1209
+ opt: ['-n'],
1210
1210
  input: `@prefix log: <http://www.w3.org/2000/10/swap/log#>.
1211
1211
 
1212
1212
  <http://example.org/2> log:outputString "B".