diff --git a/dist/oldm.mjs b/dist/oldm.mjs index 08e0e07..e6ca059 100644 --- a/dist/oldm.mjs +++ b/dist/oldm.mjs @@ -25,7 +25,7 @@ var Bl=Object.create;var zr=Object.defineProperty;var Fl=Object.getOwnPropertyDe ]`)}}list(e){let r=e&&e.length||0,n=new Array(r);for(let i=0;i{r=null,e(n,i)});if(this._endStream)try{return this._outputStream.end(r)}catch{}r&&r()}};function Ji(t){let e=ou[t];return e===void 0&&(t.length===1?(e=t.charCodeAt(0).toString(16),e="\\u0000".substr(0,6-e.length)+e):(e=((t.charCodeAt(0)-55296)*1024+t.charCodeAt(1)+9216).toString(16),e="\\U00000000".substr(0,10-e.length)+e)),e}function Ki(t){return t.replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&")}var Ni=nr(Wr());var Tt=class{constructor(e,r){this._size=0,this._graphs=Object.create(null),this._id=0,this._ids=Object.create(null),this._entities=Object.create(null),this._blankNodeIndex=0,!r&&e&&!e[0]&&(r=e,e=null),r=r||{},this._factory=r.factory||ue,e&&this.addQuads(e)}_termFromId(e,r){if(e[0]==="."){let n=this._entities,i=e.split(".");return this._factory.quad(this._termFromId(n[i[1]]),this._termFromId(n[i[2]]),this._termFromId(n[i[3]]),i[4]&&this._termFromId(n[i[4]]))}return ve(e,r)}_termToNumericId(e){if(e.termType==="Quad"){let r=this._termToNumericId(e.subject),n=this._termToNumericId(e.predicate),i=this._termToNumericId(e.object),s;return r&&n&&i&&(xe(e.graph)||(s=this._termToNumericId(e.graph)))&&this._ids[s?`.${r}.${n}.${i}.${s}`:`.${r}.${n}.${i}`]}return this._ids[H(e)]}_termToNewNumericId(e){let r=e&&e.termType==="Quad"?`.${this._termToNewNumericId(e.subject)}.${this._termToNewNumericId(e.predicate)}.${this._termToNewNumericId(e.object)}${xe(e.graph)?"":`.${this._termToNewNumericId(e.graph)}`}`:H(e);return this._ids[r]||(this._ids[this._entities[++this._id]=r]=this._id)}get size(){let e=this._size;if(e!==null)return e;e=0;let r=this._graphs,n,i;for(let s in r)for(let o in n=r[s].subjects)for(let a in i=n[o])e+=Object.keys(i[a]).length;return this._size=e}_addToIndex(e,r,n,i){let s=e[r]||(e[r]={}),o=s[n]||(s[n]={}),a=i in o;return a||(o[i]=null),!a}_removeFromIndex(e,r,n,i){let s=e[r],o=s[n];delete o[i];for(let a in o)return;delete s[n];for(let a in s)return;delete e[r]}*_findInIndex(e,r,n,i,s,o,a,l){let u,d,f,b=this._entities,_=this._termFromId(l,this._factory),y={subject:null,predicate:null,object:null};r&&((u=e,e={})[r]=u[r]);for(let g in e)if(d=e[g]){y[s]=this._termFromId(b[g],this._factory),n&&((u=d,d={})[n]=u[n]);for(let m in d)if(f=d[m]){y[o]=this._termFromId(b[m],this._factory);let w=i?i in f?[i]:[]:Object.keys(f);for(let R=0;R{n in r||(r[n]=!0,e(this._termFromId(this._entities[n],this._factory)))}}add(e){return this.addQuad(e),this}addQuad(e,r,n,i){r||(i=e.graph,n=e.object,r=e.predicate,e=e.subject),i=H(i);let s=this._graphs[i];s||(s=this._graphs[i]={subjects:{},predicates:{},objects:{}},Object.freeze(s)),e=this._termToNewNumericId(e),r=this._termToNewNumericId(r),n=this._termToNewNumericId(n);let o=this._addToIndex(s.subjects,e,r,n);return this._addToIndex(s.predicates,r,n,e),this._addToIndex(s.objects,n,e,r),this._size=null,o}addQuads(e){for(let r=0;r{this.addQuad(r)}),e}removeQuad(e,r,n,i){r||(i=e.graph,n=e.object,r=e.predicate,e=e.subject),i=H(i);let s=this._graphs,o,a,l;if(!(e=e&&this._termToNumericId(e))||!(r=r&&this._termToNumericId(r))||!(n=n&&this._termToNumericId(n))||!(o=s[i])||!(a=o.subjects[e])||!(l=a[r])||!(n in l))return!1;this._removeFromIndex(o.subjects,e,r,n),this._removeFromIndex(o.predicates,r,n,e),this._removeFromIndex(o.objects,n,e,r),this._size!==null&&this._size--;for(e in o.subjects)return!0;return delete s[i],!0}removeQuads(e){for(let r=0;r{this.removeQuad(r)}),e}removeMatches(e,r,n,i){let s=new Ni.Readable({objectMode:!0});return s._read=()=>{for(let o of this.readQuads(e,r,n,i))s.push(o);s.push(null)},this.remove(s)}deleteGraph(e){return this.removeMatches(null,null,null,e)}getQuads(e,r,n,i){return[...this.readQuads(e,r,n,i)]}*readQuads(e,r,n,i){i=i&&H(i);let s=this._getGraphs(i),o,a,l,u;if(!(e&&!(a=this._termToNumericId(e))||r&&!(l=this._termToNumericId(r))||n&&!(u=this._termToNumericId(n))))for(let d in s)(o=s[d])&&(a?u?yield*this._findInIndex(o.objects,u,a,l,"object","subject","predicate",d):yield*this._findInIndex(o.subjects,a,l,null,"subject","predicate","object",d):l?yield*this._findInIndex(o.predicates,l,u,null,"predicate","object","subject",d):u?yield*this._findInIndex(o.objects,u,null,null,"object","subject","predicate",d):yield*this._findInIndex(o.subjects,null,null,null,"subject","predicate","object",d))}match(e,r,n,i){return new Ti(this,e,r,n,i)}countQuads(e,r,n,i){i=i&&H(i);let s=this._getGraphs(i),o=0,a,l,u,d;if(e&&!(l=this._termToNumericId(e))||r&&!(u=this._termToNumericId(r))||n&&!(d=this._termToNumericId(n)))return 0;for(let f in s)(a=s[f])&&(e?n?o+=this._countInIndex(a.objects,d,l,u):o+=this._countInIndex(a.subjects,l,u,d):r?o+=this._countInIndex(a.predicates,u,d,l):o+=this._countInIndex(a.objects,d,l,u));return o}forEach(e,r,n,i,s){this.some(o=>(e(o),!1),r,n,i,s)}every(e,r,n,i,s){let o=!1,a=!this.some(l=>(o=!0,!e(l)),r,n,i,s);return o&&a}some(e,r,n,i,s){for(let o of this.readQuads(r,n,i,s))if(e(o))return!0;return!1}getSubjects(e,r,n){let i=[];return this.forSubjects(s=>{i.push(s)},e,r,n),i}forSubjects(e,r,n,i){i=i&&H(i);let s=this._getGraphs(i),o,a,l;if(e=this._uniqueEntities(e),!(r&&!(a=this._termToNumericId(r))||n&&!(l=this._termToNumericId(n))))for(i in s)(o=s[i])&&(a?l?this._loopBy2Keys(o.predicates,a,l,e):this._loopByKey1(o.subjects,a,e):l?this._loopByKey0(o.objects,l,e):this._loop(o.subjects,e))}getPredicates(e,r,n){let i=[];return this.forPredicates(s=>{i.push(s)},e,r,n),i}forPredicates(e,r,n,i){i=i&&H(i);let s=this._getGraphs(i),o,a,l;if(e=this._uniqueEntities(e),!(r&&!(a=this._termToNumericId(r))||n&&!(l=this._termToNumericId(n))))for(i in s)(o=s[i])&&(a?l?this._loopBy2Keys(o.objects,l,a,e):this._loopByKey0(o.subjects,a,e):l?this._loopByKey1(o.predicates,l,e):this._loop(o.predicates,e))}getObjects(e,r,n){let i=[];return this.forObjects(s=>{i.push(s)},e,r,n),i}forObjects(e,r,n,i){i=i&&H(i);let s=this._getGraphs(i),o,a,l;if(e=this._uniqueEntities(e),!(r&&!(a=this._termToNumericId(r))||n&&!(l=this._termToNumericId(n))))for(i in s)(o=s[i])&&(a?l?this._loopBy2Keys(o.subjects,a,l,e):this._loopByKey1(o.objects,a,e):l?this._loopByKey0(o.predicates,l,e):this._loop(o.objects,e))}getGraphs(e,r,n){let i=[];return this.forGraphs(s=>{i.push(s)},e,r,n),i}forGraphs(e,r,n,i){for(let s in this._graphs)this.some(o=>(e(o.graph),!0),r,n,i,s)}createBlankNode(e){let r,n;if(e)for(r=e=`_:${e}`,n=1;this._ids[r];)r=e+n++;else do r=`_:b${this._blankNodeIndex++}`;while(this._ids[r]);return this._ids[r]=++this._id,this._entities[this._id]=r,this._factory.blankNode(r.substr(2))}extractLists({remove:e=!1,ignoreErrors:r=!1}={}){let n={},i=r?()=>!0:(a,l)=>{throw new Error(`${a.value} ${l}`)},s=this.getQuads(null,P.rdf.rest,P.rdf.nil,null),o=e?[...s]:[];return s.forEach(a=>{let l=[],u=!1,d,f,b=a.graph,_=a.subject;for(;_&&!u;){let y=this.getQuads(null,null,_,null),g=this.getQuads(_,null,null,null),m,w=null,R=null,N=null;for(let S=0;S{switch(s){case"data":n=o;break;case"end":i=o;break}}},(s,o)=>{s&&this.emit("error",s)||o&&this.push(o)},(s,o)=>{this.emit("prefix",s,o)}),this._transform=(s,o,a)=>{n(s),a()},this._flush=s=>{i(),s()}}import(e){return e.on("data",r=>{this.write(r)}),e.on("end",()=>{this.end()}),e.on("error",r=>{this.emit("error",r)}),this}};var Tl=nr(Wr());var rr=class extends Tl.Transform{constructor(e){super({encoding:"utf8",writableObjectMode:!0});let r=this._writer=new He({write:(n,i,s)=>{this.push(n),s&&s()},end:n=>{this.push(null),n&&n()}},e);this._transform=(n,i,s)=>{r.addQuad(n,s)},this._flush=n=>{r.end(n)}}import(e){return e.on("data",r=>{this.write(r)}),e.on("end",()=>{this.end()}),e.on("error",r=>{this.emit("error",r)}),e.on("prefix",(r,n)=>{this._writer.addPrefix(r,n)}),this}};var Nl={Lexer:qe,Parser:Fe,Writer:He,Store:Tt,StreamParser:tr,StreamWriter:rr,Util:Xr,DataFactory:ue,Term:X,NamedNode:ot,Literal:Be,BlankNode:Ot,Variable:Ct,DefaultGraph:Mt,Quad:We,Triple:We,termFromId:ve,termToId:H};var d_={xsd$dateTime:"",xsd$time:"