Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rahome

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rahome - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

dist/data-structure/Queue/index.d.ts

45

changelog.md

@@ -7,5 +7,5 @@ ### Changelog

#### 0.2.2
#### 0.2.3
> 29 March 2020
> 4 April 2020

@@ -15,22 +15,51 @@ - 📦 FEATURE : LinkedList data structure [`#1`](https://github.com/sagar-gavhane/rahome/pull/1)

- Create ci-run-tests.yml [`#2`](https://github.com/sagar-gavhane/rahome/pull/2)
- FIX: hide implementation details of a class using private property [`fac2e92`](https://github.com/sagar-gavhane/rahome/commit/fac2e92f50f5fcc071254ebbfd50ddd5562a2515)
- LinkedList initial draft [`5e594d5`](https://github.com/sagar-gavhane/rahome/commit/5e594d5fc4228a9ad78f75fdc7115affe765d0e8)
- ADD: all contributors [`5909ba0`](https://github.com/sagar-gavhane/rahome/commit/5909ba0b0b9c8d3c1a441bf656df6de568d27b7a)
- 👌 IMPROVE: remove, removeFirst, removeLast method add and lodash removed [`4e733d1`](https://github.com/sagar-gavhane/rahome/commit/4e733d1491a20d0cfc8386704c30584d17c4c0ba)
- 📦 NEW: Stack abstract data structure add [`8b4e741`](https://github.com/sagar-gavhane/rahome/commit/8b4e741d3a12b4c0c050e994a78543da021ecab7)
- 🐞 FIX: hide implementation details of private properties [`730b1be`](https://github.com/sagar-gavhane/rahome/commit/730b1be7512419739dee7d7ef551c0e5c34d763d)
- first commit [`5f781f5`](https://github.com/sagar-gavhane/rahome/commit/5f781f5917783bd3b6745aa866894e64c9049918)
- all contributor add [`e250b42`](https://github.com/sagar-gavhane/rahome/commit/e250b42aafef9e43dc20c6aaf60f71618db15446)
- 📖 DOC: Changelog [`772ed11`](https://github.com/sagar-gavhane/rahome/commit/772ed11435ab68697793ce9f1b70d3fef987ecc3)
- 👌 IMPROVE: README.md [`c7a0bf3`](https://github.com/sagar-gavhane/rahome/commit/c7a0bf3e3137af05896c3d8786752e5a5949a788)
- 📖 DOC: Changelog [`091eff5`](https://github.com/sagar-gavhane/rahome/commit/091eff5c0a19d0056800448bc9f542c547cef56b)
- 📦 NEW: add travis setup [`86d34aa`](https://github.com/sagar-gavhane/rahome/commit/86d34aaefe019931a2992dec2cb2ad2204c59ff7)
- LinkedList initial draft [`5e594d5`](https://github.com/sagar-gavhane/rahome/commit/5e594d5fc4228a9ad78f75fdc7115affe765d0e8)
- 📦 NEW: Stack abstract data structure add [`8b4e741`](https://github.com/sagar-gavhane/rahome/commit/8b4e741d3a12b4c0c050e994a78543da021ecab7)
- 👌 IMPROVE: README.md improve [`d07137d`](https://github.com/sagar-gavhane/rahome/commit/d07137d366dc0a44cac9b9c2fb97d154fcf0e39a)
- PR comments resolved [`7141aef`](https://github.com/sagar-gavhane/rahome/commit/7141aefc654151073177c6ba2a4bf33991ba6ea5)
- 🐞 FIX: PR comments resolved [`40c9dd4`](https://github.com/sagar-gavhane/rahome/commit/40c9dd439c142c3118ad5a8f68c72cfb9518a114)
- 🐞 FIX: end of line issue [`0e589d9`](https://github.com/sagar-gavhane/rahome/commit/0e589d9416ecfeb2ffb816b4f6256d5e3bfb4f63)
- test suite for isEmpty() [`62f2126`](https://github.com/sagar-gavhane/rahome/commit/62f2126973ce2fba85fa654f9a1c5bd85a19d404)
- commentout sonar cloud setup for travis.yml [`2206628`](https://github.com/sagar-gavhane/rahome/commit/2206628652b5f53251308149bd761538fb828c36)
- 📖 DOC: Changelog [`acd879a`](https://github.com/sagar-gavhane/rahome/commit/acd879a14718b640aa6a045d998b66984eb2d55a)
- 📦FEATURE: Queue [`6346fb3`](https://github.com/sagar-gavhane/rahome/commit/6346fb3d7d9af0d3cae51bca21aa4f3519a48563)
- ‼️ BREAKING: Queue [`f5a2ae2`](https://github.com/sagar-gavhane/rahome/commit/f5a2ae2c39870ea9af3b3510ed750e0c408a43ed)
- 📦 NEW: initial Queue draft [`aae6889`](https://github.com/sagar-gavhane/rahome/commit/aae6889729d9f72261d77c6d5f1493cf37f05ce1)
- 📦 NEW: add travis setup [`5079144`](https://github.com/sagar-gavhane/rahome/commit/50791441f88ba25ceeee5b71d8f6fed1955c9b9f)
- 👌 IMPROVE: travis.yml modified [`6b152c6`](https://github.com/sagar-gavhane/rahome/commit/6b152c6e47b54e57ba9ad31a619b5949ebb22543)
- 📖 DOC: Changelog [`13f61bc`](https://github.com/sagar-gavhane/rahome/commit/13f61bcbd7cee9582919404a185739edf1a5c2e2)
- 📖 DOC: Changelog [`f14dc45`](https://github.com/sagar-gavhane/rahome/commit/f14dc45d97b7f64641f389e5894806a2666496e6)
- 📖 DOC: Changelog [`ca8d500`](https://github.com/sagar-gavhane/rahome/commit/ca8d5005dd1772483a3c625db5e9e957dea1963e)
- remove test suite [`0de5867`](https://github.com/sagar-gavhane/rahome/commit/0de58671ee1eb79b4ed17571e0758c2bbeabc340)
- 📖 DOC: Changelog [`56379f4`](https://github.com/sagar-gavhane/rahome/commit/56379f428644fefdbd44b78315f6a1b04aac3d3c)
- 📖 DOC: Changelog [`af33e94`](https://github.com/sagar-gavhane/rahome/commit/af33e9487e0a232a286a324d54f6ff66f213276e)
- travis sonar cloud config update and modify sonar-project.property file [`9e66e10`](https://github.com/sagar-gavhane/rahome/commit/9e66e101c62cf7a88b3ed934cb1d31874fa3ab45)
- 📖 DOC: Changelog [`32332ac`](https://github.com/sagar-gavhane/rahome/commit/32332ac2e5729ef416e36e580cef689c6c6757d0)
- add sonar-project.properties [`b6fabe0`](https://github.com/sagar-gavhane/rahome/commit/b6fabe08e587e365ff26d2cf732f6cb523c861e2)
- 📖 DOC: Changelog [`084b87b`](https://github.com/sagar-gavhane/rahome/commit/084b87b363c39f8d08ea9c8eae2b1307b97f2c55)
- 📖 DOC: Changelog [`5200440`](https://github.com/sagar-gavhane/rahome/commit/5200440e2996cce977d89118e693d79f8dbbf5c0)
- 👌 IMPROVE: sonar project properties [`7210584`](https://github.com/sagar-gavhane/rahome/commit/72105840e5069adc2c4b512a931052d4319516cf)
- 📖 DOC: Changelog [`bc86831`](https://github.com/sagar-gavhane/rahome/commit/bc86831688c7dd844db77199aef3b036f748475e)
- 🐞 FIX: prettier insert . issue [`9f83450`](https://github.com/sagar-gavhane/rahome/commit/9f83450c66452e741acefc66ebead3dce8a00de0)
- 🐞 FIX: prettier latest installed to fix private property issue [`b9a408e`](https://github.com/sagar-gavhane/rahome/commit/b9a408e5179106a8dea6658853984ae2472f7984)
- 📖 DOC: Changelog [`7708289`](https://github.com/sagar-gavhane/rahome/commit/770828952ff1ac5aee38645b651dfbde6a0e502d)
- node formating fix [`3bbcb28`](https://github.com/sagar-gavhane/rahome/commit/3bbcb28c2785659203358913933fe64a1cd5bfad)
- sonar token update [`5dc5401`](https://github.com/sagar-gavhane/rahome/commit/5dc5401b63d68c956487fc6ebc6f9c90b5f665fc)
- sonar.login property add [`4ce069e`](https://github.com/sagar-gavhane/rahome/commit/4ce069ef736fda2904302d7e0523d814a3e926e8)
- FIX: node formating [`9e9b97e`](https://github.com/sagar-gavhane/rahome/commit/9e9b97edde018723c8b80109a2d625df5ad11ad1)
- 👌IMPROVE: sonar project properties [`77756c9`](https://github.com/sagar-gavhane/rahome/commit/77756c924cb25f8f6824c7a2878dd23d7c16d675)
- Update changelog.yml [`26fa4a1`](https://github.com/sagar-gavhane/rahome/commit/26fa4a10312267f2fc06d8c3e80ded11bfc0bfde)
- Update changelog.yml [`925a803`](https://github.com/sagar-gavhane/rahome/commit/925a803aac9217be44f080912c925a2d5326b844)
- FIX: hide implementation details of a class using private property [`fac2e92`](https://github.com/sagar-gavhane/rahome/commit/fac2e92f50f5fcc071254ebbfd50ddd5562a2515)
- 📦 NEW: Stack [`d1f12b2`](https://github.com/sagar-gavhane/rahome/commit/d1f12b2cfa0746401953c7017ccf9ed41ade95f3)
- add sonar-project.properties [`b6fabe0`](https://github.com/sagar-gavhane/rahome/commit/b6fabe08e587e365ff26d2cf732f6cb523c861e2)
- 📖 DOC: Changelog [`bc86831`](https://github.com/sagar-gavhane/rahome/commit/bc86831688c7dd844db77199aef3b036f748475e)
- 📖 DOC: Changelog [`7708289`](https://github.com/sagar-gavhane/rahome/commit/770828952ff1ac5aee38645b651dfbde6a0e502d)
- 👌 IMPROVE: remove, removeFirst, removeLast method add and lodash removed [`92e25d8`](https://github.com/sagar-gavhane/rahome/commit/92e25d8b79d98f0b32234537cf74c96388e9d246)
- update pkg.json [`25f06c7`](https://github.com/sagar-gavhane/rahome/commit/25f06c7a8015b3ef1c5fa40895ef8280b4d7f66b)

3

dist/index.d.ts
import LinkedList from './data-structure/LinkedList';
import Stack from './data-structure/Stack';
export { LinkedList, Stack };
import Queue from './data-structure/Queue';
export { LinkedList, Stack, Queue };

@@ -440,4 +440,105 @@ 'use strict';

var DEFAULT_CAPACITY = 100;
var Queue = /*#__PURE__*/function () {
function Queue(capacity) {
if (capacity === void 0) {
capacity = DEFAULT_CAPACITY;
}
Object.defineProperty(this, _storage$1, {
writable: true,
value: void 0
});
Object.defineProperty(this, _front, {
writable: true,
value: void 0
});
Object.defineProperty(this, _rear, {
writable: true,
value: void 0
});
Object.defineProperty(this, _size, {
writable: true,
value: void 0
});
Object.defineProperty(this, _capacity, {
writable: true,
value: void 0
});
_classPrivateFieldLooseBase(this, _storage$1)[_storage$1] = [];
_classPrivateFieldLooseBase(this, _front)[_front] = 0;
_classPrivateFieldLooseBase(this, _rear)[_rear] = DEFAULT_CAPACITY - 1;
_classPrivateFieldLooseBase(this, _size)[_size] = 0;
_classPrivateFieldLooseBase(this, _capacity)[_capacity] = DEFAULT_CAPACITY;
var absoluteCapacity = Math.abs(capacity);
_classPrivateFieldLooseBase(this, _capacity)[_capacity] = absoluteCapacity > 0 ? absoluteCapacity : DEFAULT_CAPACITY;
_classPrivateFieldLooseBase(this, _storage$1)[_storage$1] = new Array(_classPrivateFieldLooseBase(this, _capacity)[_capacity]).fill(null);
_classPrivateFieldLooseBase(this, _rear)[_rear] = _classPrivateFieldLooseBase(this, _capacity)[_capacity] - 1;
}
var _proto = Queue.prototype;
_proto.dequeue = function dequeue() {
if (this.isEmpty()) {
return null;
}
var element = _classPrivateFieldLooseBase(this, _storage$1)[_storage$1][_classPrivateFieldLooseBase(this, _front)[_front]];
_classPrivateFieldLooseBase(this, _front)[_front] = (_classPrivateFieldLooseBase(this, _front)[_front] + 1) % _classPrivateFieldLooseBase(this, _capacity)[_capacity];
_classPrivateFieldLooseBase(this, _size)[_size]--;
return element;
};
_proto.enqueue = function enqueue(element) {
if (this.isFull()) {
var message = "IllegalStateException: There is no space available for current element";
throw new Error(message);
}
_classPrivateFieldLooseBase(this, _rear)[_rear] = (_classPrivateFieldLooseBase(this, _rear)[_rear] + 1) % _classPrivateFieldLooseBase(this, _capacity)[_capacity];
_classPrivateFieldLooseBase(this, _storage$1)[_storage$1][_classPrivateFieldLooseBase(this, _rear)[_rear]] = element;
_classPrivateFieldLooseBase(this, _size)[_size]++;
return true;
};
_proto.isEmpty = function isEmpty() {
return _classPrivateFieldLooseBase(this, _size)[_size] === 0;
};
_proto.isFull = function isFull() {
return _classPrivateFieldLooseBase(this, _size)[_size] === _classPrivateFieldLooseBase(this, _capacity)[_capacity];
};
_proto.peek = function peek() {
return _classPrivateFieldLooseBase(this, _storage$1)[_storage$1][_classPrivateFieldLooseBase(this, _front)[_front]];
};
_proto.toArray = function toArray() {
return _classPrivateFieldLooseBase(this, _storage$1)[_storage$1];
};
_proto.toString = function toString() {
return _classPrivateFieldLooseBase(this, _storage$1)[_storage$1].map(function (item) {
return JSON.stringify(item);
}).toString();
};
return Queue;
}();
var _storage$1 = /*#__PURE__*/_classPrivateFieldLooseKey("storage");
var _front = /*#__PURE__*/_classPrivateFieldLooseKey("front");
var _rear = /*#__PURE__*/_classPrivateFieldLooseKey("rear");
var _size = /*#__PURE__*/_classPrivateFieldLooseKey("size");
var _capacity = /*#__PURE__*/_classPrivateFieldLooseKey("capacity");
exports.LinkedList = LinkedList;
exports.Queue = Queue;
exports.Stack = Stack;
//# sourceMappingURL=rahome.cjs.development.js.map

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=0;function i(i){return"__private_"+t+++"_"+i}function n(t,i){if(!Object.prototype.hasOwnProperty.call(t,i))throw new TypeError("attempted to use private field on non-instance");return t}var r=function(t,i){void 0===i&&(i=null),this.value=t,this.next=i};r.prototype.toString=function(){return"object"==typeof this.value&&null!==this.value?JSON.stringify(this.value):""+this.value};var e=function(t,i){return JSON.stringify(t)===JSON.stringify(i)},u=function(){function t(){Object.defineProperty(this,o,{writable:!0,value:void 0}),Object.defineProperty(this,s,{writable:!0,value:void 0}),Object.defineProperty(this,l,{writable:!0,value:void 0}),n(this,o)[o]=null,n(this,s)[s]=null,n(this,l)[l]=0}var i=t.prototype;return i.add=function(t,i){if(void 0===i&&(i=null),i&&i>n(this,l)[l]+1)throw new Error("invalid position");if(null===i)return this.isEmpty()?this.addFirst(t):this.addLast(t),this;if(0===i)return this.addFirst(t),this;for(var e=n(this,o)[o],u=0,s=new r(t,null);null!==i&&u<i-1;){var h;e=(null===(h=e)||void 0===h?void 0:h.next)||null,u++}return s.next=e||null,e=s,n(this,l)[l]++,null!==n(this,o)[o]&&(n(this,o)[o].next=e||null),this},i.addFirst=function(t){var i=new r(t,n(this,o)[o]);return n(this,o)[o]=i,n(this,l)[l]++,n(this,s)[s]||(n(this,s)[s]=i),this},i.addLast=function(t){var i=new r(t);return this.isEmpty()&&(n(this,o)[o]=i,n(this,s)[s]=i),null!==n(this,s)[s]&&(n(this,s)[s].next=i,n(this,s)[s]=i),n(this,l)[l]++,this},i.clear=function(){n(this,o)[o]=null,n(this,s)[s]=null,n(this,l)[l]=0},i.contains=function(t){if(this.isEmpty())return!1;for(var i=n(this,o)[o];i;){if(e(i.value,t))return!0;i=i.next}return!1},i.isEmpty=function(){return null===n(this,o)[o]},i.remove=function(t){var i;if(null===n(this,o)[o])return null;var r=null;e(n(this,o)[o].value,t)&&(r=n(this,o)[o],n(this,o)[o]=n(this,o)[o].next);for(var u=n(this,o)[o];u&&null!==(null===(l=u)||void 0===l?void 0:l.next);){var l,h,a,v,f;e(null===(h=u)||void 0===h?void 0:h.next.value,t)?(r=null===(a=u)||void 0===a?void 0:a.next,u.next=null===(v=u)||void 0===v?void 0:v.next.next):u=null===(f=u)||void 0===f?void 0:f.next}return e(null===(i=n(this,s)[s])||void 0===i?void 0:i.value,t)&&(n(this,s)[s]=u),r},i.removeFirst=function(){if(null===n(this,o)[o])return null;var t=n(this,o)[o];return n(this,o)[o]=n(this,o)[o].next,t.next=null,t},i.removeLast=function(){if(null===n(this,o)[o])return null;var t=null;if(n(this,o)[o]===n(this,s)[s])return t=n(this,o)[o],n(this,o)[o]=null,n(this,s)[s]=null,t;for(var i=n(this,o)[o];null!==(null===(r=i)||void 0===r?void 0:r.next);){var r,e,u;(null===(e=i)||void 0===e?void 0:e.next.next)?i=i.next:(null===(u=i)||void 0===u?void 0:u.next)&&(t=i.next,i.next=null)}return n(this,s)[s]=i,t},i.size=function(){return n(this,l)[l]},i.toArray=function(){for(var t=[],i=n(this,o)[o];i;)t.push(i),i=i.next;return t},i.toString=function(){return this.toArray().map((function(t){return t.toString()})).toString()},t}(),o=i("head"),s=i("tail"),l=i("numberOfNodes"),h=function(){function t(){Object.defineProperty(this,a,{writable:!0,value:void 0}),n(this,a)[a]=[]}var i=t.prototype;return i.isEmpty=function(){return 0===n(this,a)[a].length},i.pop=function(){if(this.isEmpty())throw new Error("EmptyStackException: Trying to perform pop operation on empty stack");return n(this,a)[a].pop()},i.push=function(t){n(this,a)[a].push(t)},i.toArray=function(){return n(this,a)[a]},i.toString=function(){return n(this,a)[a].map((function(t){return JSON.stringify(t)})).toString()},t}(),a=i("storage");exports.LinkedList=u,exports.Stack=h;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=0;function i(i){return"__private_"+t+++"_"+i}function n(t,i){if(!Object.prototype.hasOwnProperty.call(t,i))throw new TypeError("attempted to use private field on non-instance");return t}var r=function(t,i){void 0===i&&(i=null),this.value=t,this.next=i};r.prototype.toString=function(){return"object"==typeof this.value&&null!==this.value?JSON.stringify(this.value):""+this.value};var e=function(t,i){return JSON.stringify(t)===JSON.stringify(i)},s=function(){function t(){Object.defineProperty(this,u,{writable:!0,value:void 0}),Object.defineProperty(this,o,{writable:!0,value:void 0}),Object.defineProperty(this,l,{writable:!0,value:void 0}),n(this,u)[u]=null,n(this,o)[o]=null,n(this,l)[l]=0}var i=t.prototype;return i.add=function(t,i){if(void 0===i&&(i=null),i&&i>n(this,l)[l]+1)throw new Error("invalid position");if(null===i)return this.isEmpty()?this.addFirst(t):this.addLast(t),this;if(0===i)return this.addFirst(t),this;for(var e=n(this,u)[u],s=0,o=new r(t,null);null!==i&&s<i-1;){var h;e=(null===(h=e)||void 0===h?void 0:h.next)||null,s++}return o.next=e||null,e=o,n(this,l)[l]++,null!==n(this,u)[u]&&(n(this,u)[u].next=e||null),this},i.addFirst=function(t){var i=new r(t,n(this,u)[u]);return n(this,u)[u]=i,n(this,l)[l]++,n(this,o)[o]||(n(this,o)[o]=i),this},i.addLast=function(t){var i=new r(t);return this.isEmpty()&&(n(this,u)[u]=i,n(this,o)[o]=i),null!==n(this,o)[o]&&(n(this,o)[o].next=i,n(this,o)[o]=i),n(this,l)[l]++,this},i.clear=function(){n(this,u)[u]=null,n(this,o)[o]=null,n(this,l)[l]=0},i.contains=function(t){if(this.isEmpty())return!1;for(var i=n(this,u)[u];i;){if(e(i.value,t))return!0;i=i.next}return!1},i.isEmpty=function(){return null===n(this,u)[u]},i.remove=function(t){var i;if(null===n(this,u)[u])return null;var r=null;e(n(this,u)[u].value,t)&&(r=n(this,u)[u],n(this,u)[u]=n(this,u)[u].next);for(var s=n(this,u)[u];s&&null!==(null===(l=s)||void 0===l?void 0:l.next);){var l,h,a,v,f;e(null===(h=s)||void 0===h?void 0:h.next.value,t)?(r=null===(a=s)||void 0===a?void 0:a.next,s.next=null===(v=s)||void 0===v?void 0:v.next.next):s=null===(f=s)||void 0===f?void 0:f.next}return e(null===(i=n(this,o)[o])||void 0===i?void 0:i.value,t)&&(n(this,o)[o]=s),r},i.removeFirst=function(){if(null===n(this,u)[u])return null;var t=n(this,u)[u];return n(this,u)[u]=n(this,u)[u].next,t.next=null,t},i.removeLast=function(){if(null===n(this,u)[u])return null;var t=null;if(n(this,u)[u]===n(this,o)[o])return t=n(this,u)[u],n(this,u)[u]=null,n(this,o)[o]=null,t;for(var i=n(this,u)[u];null!==(null===(r=i)||void 0===r?void 0:r.next);){var r,e,s;(null===(e=i)||void 0===e?void 0:e.next.next)?i=i.next:(null===(s=i)||void 0===s?void 0:s.next)&&(t=i.next,i.next=null)}return n(this,o)[o]=i,t},i.size=function(){return n(this,l)[l]},i.toArray=function(){for(var t=[],i=n(this,u)[u];i;)t.push(i),i=i.next;return t},i.toString=function(){return this.toArray().map((function(t){return t.toString()})).toString()},t}(),u=i("head"),o=i("tail"),l=i("numberOfNodes"),h=function(){function t(){Object.defineProperty(this,a,{writable:!0,value:void 0}),n(this,a)[a]=[]}var i=t.prototype;return i.isEmpty=function(){return 0===n(this,a)[a].length},i.pop=function(){if(this.isEmpty())throw new Error("EmptyStackException: Trying to perform pop operation on empty stack");return n(this,a)[a].pop()},i.push=function(t){n(this,a)[a].push(t)},i.toArray=function(){return n(this,a)[a]},i.toString=function(){return n(this,a)[a].map((function(t){return JSON.stringify(t)})).toString()},t}(),a=i("storage"),v=function(){function t(t){void 0===t&&(t=100),Object.defineProperty(this,f,{writable:!0,value:void 0}),Object.defineProperty(this,c,{writable:!0,value:void 0}),Object.defineProperty(this,d,{writable:!0,value:void 0}),Object.defineProperty(this,p,{writable:!0,value:void 0}),Object.defineProperty(this,y,{writable:!0,value:void 0}),n(this,f)[f]=[],n(this,c)[c]=0,n(this,d)[d]=99,n(this,p)[p]=0,n(this,y)[y]=100;var i=Math.abs(t);n(this,y)[y]=i>0?i:100,n(this,f)[f]=new Array(n(this,y)[y]).fill(null),n(this,d)[d]=n(this,y)[y]-1}var i=t.prototype;return i.dequeue=function(){if(this.isEmpty())return null;var t=n(this,f)[f][n(this,c)[c]];return n(this,c)[c]=(n(this,c)[c]+1)%n(this,y)[y],n(this,p)[p]--,t},i.enqueue=function(t){if(this.isFull())throw new Error("IllegalStateException: There is no space available for current element");return n(this,d)[d]=(n(this,d)[d]+1)%n(this,y)[y],n(this,f)[f][n(this,d)[d]]=t,n(this,p)[p]++,!0},i.isEmpty=function(){return 0===n(this,p)[p]},i.isFull=function(){return n(this,p)[p]===n(this,y)[y]},i.peek=function(){return n(this,f)[f][n(this,c)[c]]},i.toArray=function(){return n(this,f)[f]},i.toString=function(){return n(this,f)[f].map((function(t){return JSON.stringify(t)})).toString()},t}(),f=i("storage"),c=i("front"),d=i("rear"),p=i("size"),y=i("capacity");exports.LinkedList=s,exports.Queue=v,exports.Stack=h;
//# sourceMappingURL=rahome.cjs.production.min.js.map

@@ -436,3 +436,103 @@ var id = 0;

export { LinkedList, Stack };
var DEFAULT_CAPACITY = 100;
var Queue = /*#__PURE__*/function () {
function Queue(capacity) {
if (capacity === void 0) {
capacity = DEFAULT_CAPACITY;
}
Object.defineProperty(this, _storage$1, {
writable: true,
value: void 0
});
Object.defineProperty(this, _front, {
writable: true,
value: void 0
});
Object.defineProperty(this, _rear, {
writable: true,
value: void 0
});
Object.defineProperty(this, _size, {
writable: true,
value: void 0
});
Object.defineProperty(this, _capacity, {
writable: true,
value: void 0
});
_classPrivateFieldLooseBase(this, _storage$1)[_storage$1] = [];
_classPrivateFieldLooseBase(this, _front)[_front] = 0;
_classPrivateFieldLooseBase(this, _rear)[_rear] = DEFAULT_CAPACITY - 1;
_classPrivateFieldLooseBase(this, _size)[_size] = 0;
_classPrivateFieldLooseBase(this, _capacity)[_capacity] = DEFAULT_CAPACITY;
var absoluteCapacity = Math.abs(capacity);
_classPrivateFieldLooseBase(this, _capacity)[_capacity] = absoluteCapacity > 0 ? absoluteCapacity : DEFAULT_CAPACITY;
_classPrivateFieldLooseBase(this, _storage$1)[_storage$1] = new Array(_classPrivateFieldLooseBase(this, _capacity)[_capacity]).fill(null);
_classPrivateFieldLooseBase(this, _rear)[_rear] = _classPrivateFieldLooseBase(this, _capacity)[_capacity] - 1;
}
var _proto = Queue.prototype;
_proto.dequeue = function dequeue() {
if (this.isEmpty()) {
return null;
}
var element = _classPrivateFieldLooseBase(this, _storage$1)[_storage$1][_classPrivateFieldLooseBase(this, _front)[_front]];
_classPrivateFieldLooseBase(this, _front)[_front] = (_classPrivateFieldLooseBase(this, _front)[_front] + 1) % _classPrivateFieldLooseBase(this, _capacity)[_capacity];
_classPrivateFieldLooseBase(this, _size)[_size]--;
return element;
};
_proto.enqueue = function enqueue(element) {
if (this.isFull()) {
var message = "IllegalStateException: There is no space available for current element";
throw new Error(message);
}
_classPrivateFieldLooseBase(this, _rear)[_rear] = (_classPrivateFieldLooseBase(this, _rear)[_rear] + 1) % _classPrivateFieldLooseBase(this, _capacity)[_capacity];
_classPrivateFieldLooseBase(this, _storage$1)[_storage$1][_classPrivateFieldLooseBase(this, _rear)[_rear]] = element;
_classPrivateFieldLooseBase(this, _size)[_size]++;
return true;
};
_proto.isEmpty = function isEmpty() {
return _classPrivateFieldLooseBase(this, _size)[_size] === 0;
};
_proto.isFull = function isFull() {
return _classPrivateFieldLooseBase(this, _size)[_size] === _classPrivateFieldLooseBase(this, _capacity)[_capacity];
};
_proto.peek = function peek() {
return _classPrivateFieldLooseBase(this, _storage$1)[_storage$1][_classPrivateFieldLooseBase(this, _front)[_front]];
};
_proto.toArray = function toArray() {
return _classPrivateFieldLooseBase(this, _storage$1)[_storage$1];
};
_proto.toString = function toString() {
return _classPrivateFieldLooseBase(this, _storage$1)[_storage$1].map(function (item) {
return JSON.stringify(item);
}).toString();
};
return Queue;
}();
var _storage$1 = /*#__PURE__*/_classPrivateFieldLooseKey("storage");
var _front = /*#__PURE__*/_classPrivateFieldLooseKey("front");
var _rear = /*#__PURE__*/_classPrivateFieldLooseKey("rear");
var _size = /*#__PURE__*/_classPrivateFieldLooseKey("size");
var _capacity = /*#__PURE__*/_classPrivateFieldLooseKey("capacity");
export { LinkedList, Queue, Stack };
//# sourceMappingURL=rahome.esm.js.map
{
"version": "0.2.3",
"version": "0.2.4",
"license": "MIT",

@@ -16,2 +16,3 @@ "main": "dist/index.js",

"test:coverage": "tsdx test --coverage",
"test:coverage:ci": "cross-env CI=true tsdx test --coverage",
"test:coverage:open": "open ./coverage/lcov-report/index.html",

@@ -18,0 +19,0 @@ "lint": "tsdx lint src",

@@ -1,10 +0,50 @@

# data structure
# rahome
1. Linked List
2. Stack
3. Queue
4. Hash Table
5. Heaps
6. Trie
7. Tree
8. Graph
Popular data structures for writing efficient programs in JavaScript.
## Badges
![npm version](https://img.shields.io/npm/v/rahome?style=flat-square)
![npm issues](https://img.shields.io/npm/dm/rahome?style=flat-square)
![npm license](https://img.shields.io/npm/l/rahome?style=flat-square)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/rahome?style=flat-square)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/sagar-gavhane/rahome/CI?style=flat-square)
[![GitHub issues](https://img.shields.io/github/issues/sagar-gavhane/rahome?style=flat-square)](https://github.com/sagar-gavhane/rahome/issues)
![GitHub contributors](https://img.shields.io/github/contributors-anon/sagar-gavhane/rahome?style=flat-square)
![GitHub top language](https://img.shields.io/github/languages/top/sagar-gavhane/rahome?style=flat-square)
## Installing
This module is distributed via `npm` which is bundled with `node` and should be installed as one of your project's dependence.
```bash
npm install rahome --save
```
## Usage
```javascript
import { LinkedList } from 'rahome'
const list = new LinkedList()
list.add(10) // add 10 to list => [10]
list.add(20) // add 20 to list => [10] -> [20]
list.add(30) // add 20 to list => [10] -> [20] -> [30]
list.addFirst(5) // add 10 to list => [5] -> [10] -> [20] -> [30]
list.addLast(40) // add 40 to list => [5] -> [10] -> [20] -> [30] -> [40]
```
## Contributing
Pull requests are welcome. Please read [CONTRIBUTING.md](https://github.com/sagar-gavhane/rahome/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
## Versioning
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/sagar-gavhane/rahome/tags).
## License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/sagar-gavhane/rahome/blob/master/LICENSE) file for details

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc