@akashbabu/node-dll
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -34,3 +34,5 @@ (function (global, factory) { | ||
revokeAccess(dllItem) { | ||
return new AccessRestrictedDLLItem(dllItem); | ||
return (dllItem | ||
? new AccessRestrictedDLLItem(dllItem) | ||
: null); | ||
} | ||
@@ -51,10 +53,6 @@ } | ||
get prev() { | ||
return this.dllItem.prev | ||
? this.dllItemAccessRestrictor.revokeAccess(this.dllItem.prev) | ||
: null; | ||
return this.dllItemAccessRestrictor.revokeAccess(this.dllItem.prev); | ||
} | ||
get next() { | ||
return this.dllItem.next | ||
? this.dllItemAccessRestrictor.revokeAccess(this.dllItem.next) | ||
: null; | ||
return this.dllItemAccessRestrictor.revokeAccess(this.dllItem.next); | ||
} | ||
@@ -69,10 +67,6 @@ } | ||
get head() { | ||
return this.state.head | ||
? this.dllItemAccessRestrictor.revokeAccess(this.state.head) | ||
: null; | ||
return this.dllItemAccessRestrictor.revokeAccess(this.state.head); | ||
} | ||
get tail() { | ||
return this.state.tail | ||
? this.dllItemAccessRestrictor.revokeAccess(this.state.tail) | ||
: null; | ||
return this.dllItemAccessRestrictor.revokeAccess(this.state.tail); | ||
} | ||
@@ -79,0 +73,0 @@ get length() { |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).DLL={})}(this,(function(t){"use strict";class e{constructor(t,e=null,s=null){this.data=t,this.prev=e,this.next=s}}class s{grantAccess(t){return t.__dllItem__}revokeAccess(t){return new r(t)}}class r{constructor(t){this.dllItem=t,this.dllItemAccessRestrictor=new s,this.__dllItem__=t}get data(){return this.dllItem.data}set data(t){this.dllItem.data=t}get prev(){return this.dllItem.prev?this.dllItemAccessRestrictor.revokeAccess(this.dllItem.prev):null}get next(){return this.dllItem.next?this.dllItemAccessRestrictor.revokeAccess(this.dllItem.next):null}}t.DLL=class{constructor(){this.state=this.getFreshState(),this.dllItemAccessRestrictor=new s}get head(){return this.state.head?this.dllItemAccessRestrictor.revokeAccess(this.state.head):null}get tail(){return this.state.tail?this.dllItemAccessRestrictor.revokeAccess(this.state.tail):null}get length(){return this.state.length}shift(){let t=this.state.head;if(!(t instanceof e))return;this.remove(t);const s=t.data;return t=null,s}unshift(t){const s=this.state.head,r=new e(t,null,s);this.state.head=r,s instanceof e?s.prev=r:this.state.tail=r,this.state.length++}forEach(t){this.iterate((e,s)=>{t(e.data,s)})}map(t){const e=[];return this.forEach((s,r)=>{e.push(t(s,r))}),e}push(t){return this.appendAfter(this.state.tail,t)}appendAfter(t,s){let n;if(null===t&&this.state.length>0)throw Error("Invalid Node `null`: DLL is not empty, hence can't append to the given node");n=t instanceof r?this.dllItemAccessRestrictor.grantAccess(t):t;const i=new e(s);return null===n?this.state.head=this.state.tail=i:(i.prev=n,i.next=n.next,n.next=i,n===this.state.tail&&(this.state.tail=i)),this.state.length++,this.dllItemAccessRestrictor.revokeAccess(i)}remove(t){let s;if(t instanceof r)s=this.dllItemAccessRestrictor.grantAccess(t);else{if(!(t instanceof e))return!1;s=t}return s.prev?s.prev.next=s.next:this.state.head=s.next,s.next?s.next.prev=s.prev:this.state.tail=s.prev,this.state.length--,!0}clear(){this.iterate(t=>{t.prev=t.next=null}),this.state=this.getFreshState()}getFreshState(){return{length:0,head:null,tail:null}}iterate(t){let e=this.state.head,s=0;for(;e;)t(e,s++),e=e.next}},t.DLLItem=r,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).DLL={})}(this,(function(t){"use strict";class e{constructor(t,e=null,s=null){this.data=t,this.prev=e,this.next=s}}class s{grantAccess(t){return t.__dllItem__}revokeAccess(t){return t?new r(t):null}}class r{constructor(t){this.dllItem=t,this.dllItemAccessRestrictor=new s,this.__dllItem__=t}get data(){return this.dllItem.data}set data(t){this.dllItem.data=t}get prev(){return this.dllItemAccessRestrictor.revokeAccess(this.dllItem.prev)}get next(){return this.dllItemAccessRestrictor.revokeAccess(this.dllItem.next)}}t.DLL=class{constructor(){this.state=this.getFreshState(),this.dllItemAccessRestrictor=new s}get head(){return this.dllItemAccessRestrictor.revokeAccess(this.state.head)}get tail(){return this.dllItemAccessRestrictor.revokeAccess(this.state.tail)}get length(){return this.state.length}shift(){let t=this.state.head;if(!(t instanceof e))return;this.remove(t);const s=t.data;return t=null,s}unshift(t){const s=this.state.head,r=new e(t,null,s);this.state.head=r,s instanceof e?s.prev=r:this.state.tail=r,this.state.length++}forEach(t){this.iterate((e,s)=>{t(e.data,s)})}map(t){const e=[];return this.forEach((s,r)=>{e.push(t(s,r))}),e}push(t){return this.appendAfter(this.state.tail,t)}appendAfter(t,s){let n;if(null===t&&this.state.length>0)throw Error("Invalid Node `null`: DLL is not empty, hence can't append to the given node");n=t instanceof r?this.dllItemAccessRestrictor.grantAccess(t):t;const i=new e(s);return null===n?this.state.head=this.state.tail=i:(i.prev=n,i.next=n.next,n.next=i,n===this.state.tail&&(this.state.tail=i)),this.state.length++,this.dllItemAccessRestrictor.revokeAccess(i)}remove(t){let s;if(t instanceof r)s=this.dllItemAccessRestrictor.grantAccess(t);else{if(!(t instanceof e))return!1;s=t}return s.prev?s.prev.next=s.next:this.state.head=s.next,s.next?s.next.prev=s.prev:this.state.tail=s.prev,this.state.length--,!0}clear(){this.iterate(t=>{t.prev=t.next=null}),this.state=this.getFreshState()}getFreshState(){return{length:0,head:null,tail:null}}iterate(t){let e=this.state.head,s=0;for(;e;)t(e,s++),e=e.next}},t.DLLItem=r,Object.defineProperty(t,"__esModule",{value:!0})})); |
@@ -28,3 +28,5 @@ class DLLItem { | ||
revokeAccess(dllItem) { | ||
return new AccessRestrictedDLLItem(dllItem); | ||
return (dllItem | ||
? new AccessRestrictedDLLItem(dllItem) | ||
: null); | ||
} | ||
@@ -45,10 +47,6 @@ } | ||
get prev() { | ||
return this.dllItem.prev | ||
? this.dllItemAccessRestrictor.revokeAccess(this.dllItem.prev) | ||
: null; | ||
return this.dllItemAccessRestrictor.revokeAccess(this.dllItem.prev); | ||
} | ||
get next() { | ||
return this.dllItem.next | ||
? this.dllItemAccessRestrictor.revokeAccess(this.dllItem.next) | ||
: null; | ||
return this.dllItemAccessRestrictor.revokeAccess(this.dllItem.next); | ||
} | ||
@@ -63,10 +61,6 @@ } | ||
get head() { | ||
return this.state.head | ||
? this.dllItemAccessRestrictor.revokeAccess(this.state.head) | ||
: null; | ||
return this.dllItemAccessRestrictor.revokeAccess(this.state.head); | ||
} | ||
get tail() { | ||
return this.state.tail | ||
? this.dllItemAccessRestrictor.revokeAccess(this.state.tail) | ||
: null; | ||
return this.dllItemAccessRestrictor.revokeAccess(this.state.tail); | ||
} | ||
@@ -73,0 +67,0 @@ get length() { |
@@ -32,3 +32,5 @@ 'use strict'; | ||
revokeAccess(dllItem) { | ||
return new AccessRestrictedDLLItem(dllItem); | ||
return (dllItem | ||
? new AccessRestrictedDLLItem(dllItem) | ||
: null); | ||
} | ||
@@ -49,10 +51,6 @@ } | ||
get prev() { | ||
return this.dllItem.prev | ||
? this.dllItemAccessRestrictor.revokeAccess(this.dllItem.prev) | ||
: null; | ||
return this.dllItemAccessRestrictor.revokeAccess(this.dllItem.prev); | ||
} | ||
get next() { | ||
return this.dllItem.next | ||
? this.dllItemAccessRestrictor.revokeAccess(this.dllItem.next) | ||
: null; | ||
return this.dllItemAccessRestrictor.revokeAccess(this.dllItem.next); | ||
} | ||
@@ -67,10 +65,6 @@ } | ||
get head() { | ||
return this.state.head | ||
? this.dllItemAccessRestrictor.revokeAccess(this.state.head) | ||
: null; | ||
return this.dllItemAccessRestrictor.revokeAccess(this.state.head); | ||
} | ||
get tail() { | ||
return this.state.tail | ||
? this.dllItemAccessRestrictor.revokeAccess(this.state.tail) | ||
: null; | ||
return this.dllItemAccessRestrictor.revokeAccess(this.state.tail); | ||
} | ||
@@ -77,0 +71,0 @@ get length() { |
{ | ||
"name": "@akashbabu/node-dll", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "DLL(doubly linked list) library for javascript projects", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -9,4 +9,4 @@ import DLLItem, { DLLItemType } from './dllItem'; | ||
export interface IDLLItemAccessRestrictor<T> { | ||
grantAccess(accessRestrictedDllItem: IAccessRestrictedDLLItem<T>): DLLItemType<T>; | ||
revokeAccess(dllItem: DLLItem<T>): IAccessRestrictedDLLItem<T>; | ||
grantAccess(accessRestrictedDllItem: IAccessRestrictedDLLItem<T>): DLLItem<T>; | ||
revokeAccess<U extends DLLItem<T> | null>(dllItem: U): U extends DLLItem<T> ? AccessRestrictedDLLItem<T> : null; | ||
} | ||
@@ -21,3 +21,3 @@ export default class DLLItemAccessRestrictor<T> implements IDLLItemAccessRestrictor<T> { | ||
*/ | ||
grantAccess(accessRestrictedDllItem: AccessRestrictedDLLItem<T>): DLLItemType<T>; | ||
grantAccess(accessRestrictedDllItem: AccessRestrictedDLLItem<T>): DLLItem<T>; | ||
/** | ||
@@ -30,3 +30,3 @@ * Revokes write access to `prev` & `next` properties | ||
*/ | ||
revokeAccess(dllItem: DLLItem<T>): AccessRestrictedDLLItem<T>; | ||
revokeAccess<U extends DLLItem<T> | null>(dllItem: U): U extends DLLItem<T> ? AccessRestrictedDLLItem<T> : null; | ||
} | ||
@@ -33,0 +33,0 @@ export declare class AccessRestrictedDLLItem<T> implements IAccessRestrictedDLLItem<T> { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
39738
914