Socket
Socket
Sign inDemoInstall

node-relation

Package Overview
Dependencies
0
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0 to 4.0.1-alpha.0

2

dist/esm/index.js

@@ -1,1 +0,1 @@

var t={d:(e,r)=>{for(var s in r)t.o(r,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:r[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{W:()=>s});class r{constructor(t=[]){this.__relations=new Map(t)}static has(t,e){return t.includes(e)}static add(t,...e){for(const s of e)r.has(t,s)||t.push(s);return t}static drop(t,...e){for(const s of e)if(r.has(t,s)){const e=t.indexOf(s);-1!==e&&t.splice(e,1)}return t}static clear(t){return t.length=0,t}get dataset(){return Array.from(this.__relations)}get nodes(){const t=[];for(const[e,s]of this.__relations)r.add(t,e),r.add(t,...s);return t}get nodeset(){const t=new Set;for(const[e,r]of this.__relations){t.add(e);for(const e of r)t.add(e)}return t}get copy(){return new this.constructor(this.dataset)}ensureRelation(t,...e){this.__relations.has(t)||this.__relations.set(t,[]);const s=this.__relations.get(t);for(const t of e)r.add(s,t);return s}to(t,...e){return this.ensureRelation(t,...e),this}both(t,...e){this.ensureRelation(t,...e);for(const r of e)this.ensureRelation(r,t);return this}all(...t){for(const e of t){const s=this.ensureRelation(e,...t);r.drop(s,e)}return this}getCombinedDataset(t,e){const s=new Map,o=new Map(t),n=new Map(e);for(const[t,e]of o){s.has(t)||s.set(t,e);const o=s.get(t);r.add(o,...e)}for(const[t,e]of n){s.has(t)||s.set(t,e);const o=s.get(t);r.add(o,...e)}return Array.from(s)}getSearchedRelationDataset(t,e,s=[[t,[]]],o=[]){const n=this.__relations.has(t)?this.__relations.get(t):[],a=[[t,n]];if(!e)return a;if(!n)return a;if(r.has(o,t))return a;r.add(o,t),e--,s=this.getCombinedDataset(s,a);for(const t of n){const r=this.getSearchedRelationDataset(t,e,s,o);s=this.getCombinedDataset(s,r)}return s}from(t,e=-1){e<0&&(e=Number.MAX_SAFE_INTEGER);const r=this.copy.getSearchedRelationDataset(t,--e);return new this.constructor(r)}where(t){const e=this.copy,r=e.nodes.filter(((e,r,s)=>!t(e,r,s)));return e.drop(...r),e}without(...t){return r.drop(this.nodes,...t)}unlinkRefersFromSource(t,...e){const s=this.__relations.get(t);s&&r.drop(s,...e)}unlinkTo(t,...e){return this.unlinkRefersFromSource(t,...e),this}unlinkBoth(t,...e){this.unlinkRefersFromSource(t,...e);for(const r of e)this.unlinkRefersFromSource(r,t);return this}drop(...t){for(const e of this.__relations.values())r.drop(e,...t);for(const e of t)this.__relations.delete(e);return this}has(t){let e=this.__relations.has(t);for(const s of this.__relations.values())if(r.has(s,t)){e=!0;break}return e}hasAll(...t){for(const e of t)if(!this.has(e))return!1;return!0}clear(){this.__relations.clear()}}class s extends r{constructor(t=[]){super(t)}to(t,...e){return super.to.call(this.copy,t,...e)}both(t,...e){return super.both.call(this.copy,t,...e)}all(...t){return super.all.call(this.copy,...t)}unlinkTo(t,...e){return super.unlinkTo.call(this.copy,t,...e)}unlinkBoth(t,...e){return super.unlinkBoth.call(this.copy,t,...e)}drop(...t){return super.drop.call(this.copy,...t)}}var o=e.W;export{o as Relationship};
var t={d:(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{W:()=>o});class r{constructor(t=[]){this.__relations=new Map(t)}static has(t,e){return t.includes(e)}static add(t,...e){for(const o of e)r.has(t,o)||t.push(o);return t}static drop(t,...e){for(const o of e)if(r.has(t,o)){const e=t.indexOf(o);-1!==e&&t.splice(e,1)}return t}static clear(t){return t.length=0,t}get dataset(){return Array.from(this.__relations)}get nodes(){const t=[];for(const[e,o]of this.__relations)r.add(t,e),r.add(t,...o);return t}get nodeset(){const t=new Set;for(const[e,r]of this.__relations){t.add(e);for(const e of r)t.add(e)}return t}get copy(){return new this.constructor(this.dataset)}ensureRelation(t,...e){this.__relations.has(t)||this.__relations.set(t,[]);const o=this.__relations.get(t);for(const t of e)r.add(o,t);return o}to(t,...e){return this.ensureRelation(t,...e),this}both(t,...e){this.ensureRelation(t,...e);for(const r of e)this.ensureRelation(r,t);return this}all(...t){for(const e of t){const o=this.ensureRelation(e,...t);r.drop(o,e)}return this}getCombinedDataset(t,e){const o=new Map,s=new Map(t),n=new Map(e);for(const[t,e]of s){o.has(t)||o.set(t,e);const s=o.get(t);r.add(s,...e)}for(const[t,e]of n){o.has(t)||o.set(t,e);const s=o.get(t);r.add(s,...e)}return Array.from(o)}getSearchedRelationDataset(t,e,o=[[t,[]]],s=[]){const n=this.__relations.has(t)?this.__relations.get(t):[],a=[[t,n]];if(!e)return a;if(!n)return a;if(r.has(s,t))return a;r.add(s,t),e--,o=this.getCombinedDataset(o,a);for(const t of n){const r=this.getSearchedRelationDataset(t,e,o,s);o=this.getCombinedDataset(o,r)}return o}from(t,e=-1){e<0&&(e=Number.MAX_SAFE_INTEGER);const r=this.copy.getSearchedRelationDataset(t,--e);return new this.constructor(r)}where(t){const e=this.copy,o=e.nodes.filter(((e,r,o)=>!t(e,r,o)));return r.prototype.drop.call(e,...o),e}without(...t){return r.drop(this.nodes,...t)}unlinkRefersFromSource(t,...e){const o=this.__relations.get(t);o&&r.drop(o,...e)}unlinkTo(t,...e){return this.unlinkRefersFromSource(t,...e),this}unlinkBoth(t,...e){this.unlinkRefersFromSource(t,...e);for(const r of e)this.unlinkRefersFromSource(r,t);return this}drop(...t){for(const e of this.__relations.values())r.drop(e,...t);for(const e of t)this.__relations.delete(e);return this}has(t){let e=this.__relations.has(t);for(const o of this.__relations.values())if(r.has(o,t)){e=!0;break}return e}hasAll(...t){for(const e of t)if(!this.has(e))return!1;return!0}clear(){this.__relations.clear()}}class o extends r{constructor(t=[]){super(t)}to(t,...e){return super.to.call(this.copy,t,...e)}both(t,...e){return super.both.call(this.copy,t,...e)}all(...t){return super.all.call(this.copy,...t)}unlinkTo(t,...e){return super.unlinkTo.call(this.copy,t,...e)}unlinkBoth(t,...e){return super.unlinkBoth.call(this.copy,t,...e)}drop(...t){return super.drop.call(this.copy,...t)}}var s=e.W;export{s as Relationship};

@@ -1,1 +0,1 @@

var t={d:(e,r)=>{for(var s in r)t.o(r,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:r[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{W:()=>r});class r{constructor(t=[]){this.__relations=new Map(t)}static has(t,e){return t.includes(e)}static add(t,...e){for(const s of e)r.has(t,s)||t.push(s);return t}static drop(t,...e){for(const s of e)if(r.has(t,s)){const e=t.indexOf(s);-1!==e&&t.splice(e,1)}return t}static clear(t){return t.length=0,t}get dataset(){return Array.from(this.__relations)}get nodes(){const t=[];for(const[e,s]of this.__relations)r.add(t,e),r.add(t,...s);return t}get nodeset(){const t=new Set;for(const[e,r]of this.__relations){t.add(e);for(const e of r)t.add(e)}return t}get copy(){return new this.constructor(this.dataset)}ensureRelation(t,...e){this.__relations.has(t)||this.__relations.set(t,[]);const s=this.__relations.get(t);for(const t of e)r.add(s,t);return s}to(t,...e){return this.ensureRelation(t,...e),this}both(t,...e){this.ensureRelation(t,...e);for(const r of e)this.ensureRelation(r,t);return this}all(...t){for(const e of t){const s=this.ensureRelation(e,...t);r.drop(s,e)}return this}getCombinedDataset(t,e){const s=new Map,o=new Map(t),n=new Map(e);for(const[t,e]of o){s.has(t)||s.set(t,e);const o=s.get(t);r.add(o,...e)}for(const[t,e]of n){s.has(t)||s.set(t,e);const o=s.get(t);r.add(o,...e)}return Array.from(s)}getSearchedRelationDataset(t,e,s=[[t,[]]],o=[]){const n=this.__relations.has(t)?this.__relations.get(t):[],a=[[t,n]];if(!e)return a;if(!n)return a;if(r.has(o,t))return a;r.add(o,t),e--,s=this.getCombinedDataset(s,a);for(const t of n){const r=this.getSearchedRelationDataset(t,e,s,o);s=this.getCombinedDataset(s,r)}return s}from(t,e=-1){e<0&&(e=Number.MAX_SAFE_INTEGER);const r=this.copy.getSearchedRelationDataset(t,--e);return new this.constructor(r)}where(t){const e=this.copy,r=e.nodes.filter(((e,r,s)=>!t(e,r,s)));return e.drop(...r),e}without(...t){return r.drop(this.nodes,...t)}unlinkRefersFromSource(t,...e){const s=this.__relations.get(t);s&&r.drop(s,...e)}unlinkTo(t,...e){return this.unlinkRefersFromSource(t,...e),this}unlinkBoth(t,...e){this.unlinkRefersFromSource(t,...e);for(const r of e)this.unlinkRefersFromSource(r,t);return this}drop(...t){for(const e of this.__relations.values())r.drop(e,...t);for(const e of t)this.__relations.delete(e);return this}has(t){let e=this.__relations.has(t);for(const s of this.__relations.values())if(r.has(s,t)){e=!0;break}return e}hasAll(...t){for(const e of t)if(!this.has(e))return!1;return!0}clear(){this.__relations.clear()}}var s=e.W;export{s as Relationship};
var t={d:(e,r)=>{for(var s in r)t.o(r,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:r[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{W:()=>r});class r{constructor(t=[]){this.__relations=new Map(t)}static has(t,e){return t.includes(e)}static add(t,...e){for(const s of e)r.has(t,s)||t.push(s);return t}static drop(t,...e){for(const s of e)if(r.has(t,s)){const e=t.indexOf(s);-1!==e&&t.splice(e,1)}return t}static clear(t){return t.length=0,t}get dataset(){return Array.from(this.__relations)}get nodes(){const t=[];for(const[e,s]of this.__relations)r.add(t,e),r.add(t,...s);return t}get nodeset(){const t=new Set;for(const[e,r]of this.__relations){t.add(e);for(const e of r)t.add(e)}return t}get copy(){return new this.constructor(this.dataset)}ensureRelation(t,...e){this.__relations.has(t)||this.__relations.set(t,[]);const s=this.__relations.get(t);for(const t of e)r.add(s,t);return s}to(t,...e){return this.ensureRelation(t,...e),this}both(t,...e){this.ensureRelation(t,...e);for(const r of e)this.ensureRelation(r,t);return this}all(...t){for(const e of t){const s=this.ensureRelation(e,...t);r.drop(s,e)}return this}getCombinedDataset(t,e){const s=new Map,o=new Map(t),n=new Map(e);for(const[t,e]of o){s.has(t)||s.set(t,e);const o=s.get(t);r.add(o,...e)}for(const[t,e]of n){s.has(t)||s.set(t,e);const o=s.get(t);r.add(o,...e)}return Array.from(s)}getSearchedRelationDataset(t,e,s=[[t,[]]],o=[]){const n=this.__relations.has(t)?this.__relations.get(t):[],a=[[t,n]];if(!e)return a;if(!n)return a;if(r.has(o,t))return a;r.add(o,t),e--,s=this.getCombinedDataset(s,a);for(const t of n){const r=this.getSearchedRelationDataset(t,e,s,o);s=this.getCombinedDataset(s,r)}return s}from(t,e=-1){e<0&&(e=Number.MAX_SAFE_INTEGER);const r=this.copy.getSearchedRelationDataset(t,--e);return new this.constructor(r)}where(t){const e=this.copy,s=e.nodes.filter(((e,r,s)=>!t(e,r,s)));return r.prototype.drop.call(e,...s),e}without(...t){return r.drop(this.nodes,...t)}unlinkRefersFromSource(t,...e){const s=this.__relations.get(t);s&&r.drop(s,...e)}unlinkTo(t,...e){return this.unlinkRefersFromSource(t,...e),this}unlinkBoth(t,...e){this.unlinkRefersFromSource(t,...e);for(const r of e)this.unlinkRefersFromSource(r,t);return this}drop(...t){for(const e of this.__relations.values())r.drop(e,...t);for(const e of t)this.__relations.delete(e);return this}has(t){let e=this.__relations.has(t);for(const s of this.__relations.values())if(r.has(s,t)){e=!0;break}return e}hasAll(...t){for(const e of t)if(!this.has(e))return!1;return!0}clear(){this.__relations.clear()}}var s=e.W;export{s as Relationship};

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.NodeRelation=e():t.NodeRelation=e()}(this,(function(){return(()=>{"use strict";var t={d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Relationship:()=>r});class o{constructor(t=[]){this.__relations=new Map(t)}static has(t,e){return t.includes(e)}static add(t,...e){for(const r of e)o.has(t,r)||t.push(r);return t}static drop(t,...e){for(const r of e)if(o.has(t,r)){const e=t.indexOf(r);-1!==e&&t.splice(e,1)}return t}static clear(t){return t.length=0,t}get dataset(){return Array.from(this.__relations)}get nodes(){const t=[];for(const[e,r]of this.__relations)o.add(t,e),o.add(t,...r);return t}get nodeset(){const t=new Set;for(const[e,o]of this.__relations){t.add(e);for(const e of o)t.add(e)}return t}get copy(){return new this.constructor(this.dataset)}ensureRelation(t,...e){this.__relations.has(t)||this.__relations.set(t,[]);const r=this.__relations.get(t);for(const t of e)o.add(r,t);return r}to(t,...e){return this.ensureRelation(t,...e),this}both(t,...e){this.ensureRelation(t,...e);for(const o of e)this.ensureRelation(o,t);return this}all(...t){for(const e of t){const r=this.ensureRelation(e,...t);o.drop(r,e)}return this}getCombinedDataset(t,e){const r=new Map,s=new Map(t),n=new Map(e);for(const[t,e]of s){r.has(t)||r.set(t,e);const s=r.get(t);o.add(s,...e)}for(const[t,e]of n){r.has(t)||r.set(t,e);const s=r.get(t);o.add(s,...e)}return Array.from(r)}getSearchedRelationDataset(t,e,r=[[t,[]]],s=[]){const n=this.__relations.has(t)?this.__relations.get(t):[],i=[[t,n]];if(!e)return i;if(!n)return i;if(o.has(s,t))return i;o.add(s,t),e--,r=this.getCombinedDataset(r,i);for(const t of n){const o=this.getSearchedRelationDataset(t,e,r,s);r=this.getCombinedDataset(r,o)}return r}from(t,e=-1){e<0&&(e=Number.MAX_SAFE_INTEGER);const o=this.copy.getSearchedRelationDataset(t,--e);return new this.constructor(o)}where(t){const e=this.copy,o=e.nodes.filter(((e,o,r)=>!t(e,o,r)));return e.drop(...o),e}without(...t){return o.drop(this.nodes,...t)}unlinkRefersFromSource(t,...e){const r=this.__relations.get(t);r&&o.drop(r,...e)}unlinkTo(t,...e){return this.unlinkRefersFromSource(t,...e),this}unlinkBoth(t,...e){this.unlinkRefersFromSource(t,...e);for(const o of e)this.unlinkRefersFromSource(o,t);return this}drop(...t){for(const e of this.__relations.values())o.drop(e,...t);for(const e of t)this.__relations.delete(e);return this}has(t){let e=this.__relations.has(t);for(const r of this.__relations.values())if(o.has(r,t)){e=!0;break}return e}hasAll(...t){for(const e of t)if(!this.has(e))return!1;return!0}clear(){this.__relations.clear()}}class r extends o{constructor(t=[]){super(t)}to(t,...e){return super.to.call(this.copy,t,...e)}both(t,...e){return super.both.call(this.copy,t,...e)}all(...t){return super.all.call(this.copy,...t)}unlinkTo(t,...e){return super.unlinkTo.call(this.copy,t,...e)}unlinkBoth(t,...e){return super.unlinkBoth.call(this.copy,t,...e)}drop(...t){return super.drop.call(this.copy,...t)}}return e})()}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.NodeRelation=e():t.NodeRelation=e()}(this,(function(){return(()=>{"use strict";var t={d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Relationship:()=>r});class o{constructor(t=[]){this.__relations=new Map(t)}static has(t,e){return t.includes(e)}static add(t,...e){for(const r of e)o.has(t,r)||t.push(r);return t}static drop(t,...e){for(const r of e)if(o.has(t,r)){const e=t.indexOf(r);-1!==e&&t.splice(e,1)}return t}static clear(t){return t.length=0,t}get dataset(){return Array.from(this.__relations)}get nodes(){const t=[];for(const[e,r]of this.__relations)o.add(t,e),o.add(t,...r);return t}get nodeset(){const t=new Set;for(const[e,o]of this.__relations){t.add(e);for(const e of o)t.add(e)}return t}get copy(){return new this.constructor(this.dataset)}ensureRelation(t,...e){this.__relations.has(t)||this.__relations.set(t,[]);const r=this.__relations.get(t);for(const t of e)o.add(r,t);return r}to(t,...e){return this.ensureRelation(t,...e),this}both(t,...e){this.ensureRelation(t,...e);for(const o of e)this.ensureRelation(o,t);return this}all(...t){for(const e of t){const r=this.ensureRelation(e,...t);o.drop(r,e)}return this}getCombinedDataset(t,e){const r=new Map,s=new Map(t),n=new Map(e);for(const[t,e]of s){r.has(t)||r.set(t,e);const s=r.get(t);o.add(s,...e)}for(const[t,e]of n){r.has(t)||r.set(t,e);const s=r.get(t);o.add(s,...e)}return Array.from(r)}getSearchedRelationDataset(t,e,r=[[t,[]]],s=[]){const n=this.__relations.has(t)?this.__relations.get(t):[],i=[[t,n]];if(!e)return i;if(!n)return i;if(o.has(s,t))return i;o.add(s,t),e--,r=this.getCombinedDataset(r,i);for(const t of n){const o=this.getSearchedRelationDataset(t,e,r,s);r=this.getCombinedDataset(r,o)}return r}from(t,e=-1){e<0&&(e=Number.MAX_SAFE_INTEGER);const o=this.copy.getSearchedRelationDataset(t,--e);return new this.constructor(o)}where(t){const e=this.copy,r=e.nodes.filter(((e,o,r)=>!t(e,o,r)));return o.prototype.drop.call(e,...r),e}without(...t){return o.drop(this.nodes,...t)}unlinkRefersFromSource(t,...e){const r=this.__relations.get(t);r&&o.drop(r,...e)}unlinkTo(t,...e){return this.unlinkRefersFromSource(t,...e),this}unlinkBoth(t,...e){this.unlinkRefersFromSource(t,...e);for(const o of e)this.unlinkRefersFromSource(o,t);return this}drop(...t){for(const e of this.__relations.values())o.drop(e,...t);for(const e of t)this.__relations.delete(e);return this}has(t){let e=this.__relations.has(t);for(const r of this.__relations.values())if(o.has(r,t)){e=!0;break}return e}hasAll(...t){for(const e of t)if(!this.has(e))return!1;return!0}clear(){this.__relations.clear()}}class r extends o{constructor(t=[]){super(t)}to(t,...e){return super.to.call(this.copy,t,...e)}both(t,...e){return super.both.call(this.copy,t,...e)}all(...t){return super.all.call(this.copy,...t)}unlinkTo(t,...e){return super.unlinkTo.call(this.copy,t,...e)}unlinkBoth(t,...e){return super.unlinkBoth.call(this.copy,t,...e)}drop(...t){return super.drop.call(this.copy,...t)}}return e})()}));

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.NodeRelation=e():t.NodeRelation=e()}(this,(function(){return(()=>{"use strict";var t={d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Relationship:()=>o});class o{constructor(t=[]){this.__relations=new Map(t)}static has(t,e){return t.includes(e)}static add(t,...e){for(const r of e)o.has(t,r)||t.push(r);return t}static drop(t,...e){for(const r of e)if(o.has(t,r)){const e=t.indexOf(r);-1!==e&&t.splice(e,1)}return t}static clear(t){return t.length=0,t}get dataset(){return Array.from(this.__relations)}get nodes(){const t=[];for(const[e,r]of this.__relations)o.add(t,e),o.add(t,...r);return t}get nodeset(){const t=new Set;for(const[e,o]of this.__relations){t.add(e);for(const e of o)t.add(e)}return t}get copy(){return new this.constructor(this.dataset)}ensureRelation(t,...e){this.__relations.has(t)||this.__relations.set(t,[]);const r=this.__relations.get(t);for(const t of e)o.add(r,t);return r}to(t,...e){return this.ensureRelation(t,...e),this}both(t,...e){this.ensureRelation(t,...e);for(const o of e)this.ensureRelation(o,t);return this}all(...t){for(const e of t){const r=this.ensureRelation(e,...t);o.drop(r,e)}return this}getCombinedDataset(t,e){const r=new Map,s=new Map(t),n=new Map(e);for(const[t,e]of s){r.has(t)||r.set(t,e);const s=r.get(t);o.add(s,...e)}for(const[t,e]of n){r.has(t)||r.set(t,e);const s=r.get(t);o.add(s,...e)}return Array.from(r)}getSearchedRelationDataset(t,e,r=[[t,[]]],s=[]){const n=this.__relations.has(t)?this.__relations.get(t):[],i=[[t,n]];if(!e)return i;if(!n)return i;if(o.has(s,t))return i;o.add(s,t),e--,r=this.getCombinedDataset(r,i);for(const t of n){const o=this.getSearchedRelationDataset(t,e,r,s);r=this.getCombinedDataset(r,o)}return r}from(t,e=-1){e<0&&(e=Number.MAX_SAFE_INTEGER);const o=this.copy.getSearchedRelationDataset(t,--e);return new this.constructor(o)}where(t){const e=this.copy,o=e.nodes.filter(((e,o,r)=>!t(e,o,r)));return e.drop(...o),e}without(...t){return o.drop(this.nodes,...t)}unlinkRefersFromSource(t,...e){const r=this.__relations.get(t);r&&o.drop(r,...e)}unlinkTo(t,...e){return this.unlinkRefersFromSource(t,...e),this}unlinkBoth(t,...e){this.unlinkRefersFromSource(t,...e);for(const o of e)this.unlinkRefersFromSource(o,t);return this}drop(...t){for(const e of this.__relations.values())o.drop(e,...t);for(const e of t)this.__relations.delete(e);return this}has(t){let e=this.__relations.has(t);for(const r of this.__relations.values())if(o.has(r,t)){e=!0;break}return e}hasAll(...t){for(const e of t)if(!this.has(e))return!1;return!0}clear(){this.__relations.clear()}}return e})()}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.NodeRelation=e():t.NodeRelation=e()}(this,(function(){return(()=>{"use strict";var t={d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Relationship:()=>o});class o{constructor(t=[]){this.__relations=new Map(t)}static has(t,e){return t.includes(e)}static add(t,...e){for(const r of e)o.has(t,r)||t.push(r);return t}static drop(t,...e){for(const r of e)if(o.has(t,r)){const e=t.indexOf(r);-1!==e&&t.splice(e,1)}return t}static clear(t){return t.length=0,t}get dataset(){return Array.from(this.__relations)}get nodes(){const t=[];for(const[e,r]of this.__relations)o.add(t,e),o.add(t,...r);return t}get nodeset(){const t=new Set;for(const[e,o]of this.__relations){t.add(e);for(const e of o)t.add(e)}return t}get copy(){return new this.constructor(this.dataset)}ensureRelation(t,...e){this.__relations.has(t)||this.__relations.set(t,[]);const r=this.__relations.get(t);for(const t of e)o.add(r,t);return r}to(t,...e){return this.ensureRelation(t,...e),this}both(t,...e){this.ensureRelation(t,...e);for(const o of e)this.ensureRelation(o,t);return this}all(...t){for(const e of t){const r=this.ensureRelation(e,...t);o.drop(r,e)}return this}getCombinedDataset(t,e){const r=new Map,s=new Map(t),n=new Map(e);for(const[t,e]of s){r.has(t)||r.set(t,e);const s=r.get(t);o.add(s,...e)}for(const[t,e]of n){r.has(t)||r.set(t,e);const s=r.get(t);o.add(s,...e)}return Array.from(r)}getSearchedRelationDataset(t,e,r=[[t,[]]],s=[]){const n=this.__relations.has(t)?this.__relations.get(t):[],i=[[t,n]];if(!e)return i;if(!n)return i;if(o.has(s,t))return i;o.add(s,t),e--,r=this.getCombinedDataset(r,i);for(const t of n){const o=this.getSearchedRelationDataset(t,e,r,s);r=this.getCombinedDataset(r,o)}return r}from(t,e=-1){e<0&&(e=Number.MAX_SAFE_INTEGER);const o=this.copy.getSearchedRelationDataset(t,--e);return new this.constructor(o)}where(t){const e=this.copy,r=e.nodes.filter(((e,o,r)=>!t(e,o,r)));return o.prototype.drop.call(e,...r),e}without(...t){return o.drop(this.nodes,...t)}unlinkRefersFromSource(t,...e){const r=this.__relations.get(t);r&&o.drop(r,...e)}unlinkTo(t,...e){return this.unlinkRefersFromSource(t,...e),this}unlinkBoth(t,...e){this.unlinkRefersFromSource(t,...e);for(const o of e)this.unlinkRefersFromSource(o,t);return this}drop(...t){for(const e of this.__relations.values())o.drop(e,...t);for(const e of t)this.__relations.delete(e);return this}has(t){let e=this.__relations.has(t);for(const r of this.__relations.values())if(o.has(r,t)){e=!0;break}return e}hasAll(...t){for(const e of t)if(!this.has(e))return!1;return!0}clear(){this.__relations.clear()}}return e})()}));
{
"name": "node-relation",
"version": "4.0.0",
"version": "4.0.1-alpha.0",
"description": "Manage strings, number, object that are related to each other.",

@@ -5,0 +5,0 @@ "main": "dist/umd/index.js",

# node-relation
[![jsdelivr](https://data.jsdelivr.com/v1/package/npm/node-relation/badge)](https://www.jsdelivr.com/package/npm/node-relation)
This module helps you manage string, numbers, object as a group.

@@ -35,3 +37,3 @@ Check the code.

```html
<script src="'https://cdn.jsdelivr.net/npm/node-relation@latest/dist/umd/index.min.js'"></script>
<script src="https://cdn.jsdelivr.net/npm/node-relation@latest/dist/umd/index.min.js"></script>
<script>

@@ -38,0 +40,0 @@ const A = new NodeRelation.Relationship().to('a', 'b', 'c')

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc