Comparing version 0.2.4 to 0.2.5
@@ -1,4 +0,5 @@ | ||
import LinkedList from './data-structure/LinkedList'; | ||
import Stack from './data-structure/Stack'; | ||
import Queue from './data-structure/Queue'; | ||
export { LinkedList, Stack, Queue }; | ||
import LinkedList from './LinkedList'; | ||
import Stack from './Stack'; | ||
import Queue from './Queue'; | ||
import HashTable from './HashTable'; | ||
export { LinkedList, Stack, Queue, HashTable }; |
@@ -540,2 +540,189 @@ 'use strict'; | ||
var HashTable = /*#__PURE__*/function () { | ||
/** | ||
* Creates an instance of HashTable. | ||
* @memberof HashTable | ||
*/ | ||
function HashTable() { | ||
Object.defineProperty(this, _buckets, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, _keys, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
_classPrivateFieldLooseBase(this, _keys)[_keys] = {}; | ||
_classPrivateFieldLooseBase(this, _buckets)[_buckets] = new Map(); | ||
} | ||
var _proto = HashTable.prototype; | ||
/** | ||
* Returns the hash code passed key | ||
* | ||
* @param {K} key | ||
* @returns {K} hash code of passed key | ||
* @memberof HashTable | ||
*/ | ||
_proto.hashCode = function hashCode(key) { | ||
// copied from https://gist.github.com/hyamamoto/fd435505d29ebfa3d9716fd2be8d42f0#gistcomment-2694461 | ||
var i, h; | ||
for (i = 0, h = 0; i < ("" + key).length; i++) { | ||
h = Math.imul(31, h) + ("" + key).charCodeAt(i) | 0; | ||
} | ||
return h; | ||
} | ||
/** | ||
* Returns the value to which the specified key is mapped, or undefined if this HashTable contains no mapping for the key. | ||
* | ||
* @param {K} key | ||
* @returns {(V | undefined)} value or undefined | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.get = function get(key) { | ||
var keyHash = this.hashCode(key); | ||
return _classPrivateFieldLooseBase(this, _buckets)[_buckets].get(keyHash); | ||
} | ||
/** | ||
* Adds or updates an value with a specified key | ||
* | ||
* @param {K} key | ||
* @param {V} value | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.set = function set(key, value) { | ||
var keyHash = this.hashCode(key); | ||
_classPrivateFieldLooseBase(this, _keys)[_keys][keyHash] = key; | ||
_classPrivateFieldLooseBase(this, _buckets)[_buckets].set(keyHash, value); | ||
} | ||
/** | ||
* Removes the specified key and value from a HashTable | ||
* | ||
* @param {K} key | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto["delete"] = function _delete(key) { | ||
var keyHash = this.hashCode(key); | ||
delete _classPrivateFieldLooseBase(this, _keys)[_keys][keyHash]; | ||
_classPrivateFieldLooseBase(this, _buckets)[_buckets]["delete"](keyHash); | ||
} | ||
/** | ||
* Tests if some key is exist into HashTable. | ||
* | ||
* @param {K} key | ||
* @returns {boolean} | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.contains = function contains(key) { | ||
var keyHash = this.hashCode(key); | ||
return _classPrivateFieldLooseBase(this, _buckets)[_buckets].has(keyHash); | ||
} | ||
/** | ||
* Returns an enumeration of the keys in this hashtable. | ||
* | ||
* @returns {Array<any>} | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.keys = function keys() { | ||
return this.toArray().map(function (value) { | ||
var key = value[0]; | ||
return key; | ||
}); | ||
} | ||
/** | ||
* Clears this hashtable so that it contains no keys. | ||
* | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.clear = function clear() { | ||
_classPrivateFieldLooseBase(this, _keys)[_keys] = {}; | ||
_classPrivateFieldLooseBase(this, _buckets)[_buckets].clear(); | ||
} | ||
/** | ||
* Returns the number of keys in this hashtable. | ||
* | ||
* @returns {number} number of keys in this hashtable | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.size = function size() { | ||
return _classPrivateFieldLooseBase(this, _buckets)[_buckets].size; | ||
} | ||
/** | ||
* Returns true if hashtable is empty | ||
* | ||
* @returns {boolean} true if hashtable is empty | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.isEmpty = function isEmpty() { | ||
return this.size() === 0; | ||
} | ||
/** | ||
* Returns an array containing all of the hashtable | ||
* | ||
* @returns {Array} | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.toArray = function toArray() { | ||
var _this = this; | ||
return Array.from(_classPrivateFieldLooseBase(this, _buckets)[_buckets]).map(function (pairs) { | ||
var hashCode = pairs[0], | ||
value = pairs[1]; | ||
return [_classPrivateFieldLooseBase(_this, _keys)[_keys][hashCode], value]; | ||
}); | ||
} | ||
/** | ||
* Returns string representation of hashtable | ||
* | ||
* @returns {string} | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.toString = function toString() { | ||
var _this2 = this; | ||
var output = []; | ||
_classPrivateFieldLooseBase(this, _buckets)[_buckets].forEach(function (value, key) { | ||
var decodedHashKey = _classPrivateFieldLooseBase(_this2, _keys)[_keys][key]; | ||
output.push(decodedHashKey + "=" + JSON.stringify(value)); | ||
}); | ||
return output.join(','); | ||
}; | ||
return HashTable; | ||
}(); | ||
var _buckets = /*#__PURE__*/_classPrivateFieldLooseKey("buckets"); | ||
var _keys = /*#__PURE__*/_classPrivateFieldLooseKey("keys"); | ||
exports.HashTable = HashTable; | ||
exports.LinkedList = LinkedList; | ||
@@ -542,0 +729,0 @@ exports.Queue = Queue; |
@@ -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)},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; | ||
"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,h,{writable:!0,value:void 0}),n(this,u)[u]=null,n(this,o)[o]=null,n(this,h)[h]=0}var i=t.prototype;return i.add=function(t,i){if(void 0===i&&(i=null),i&&i>n(this,h)[h]+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 l;e=(null===(l=e)||void 0===l?void 0:l.next)||null,s++}return o.next=e||null,e=o,n(this,h)[h]++,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,h)[h]++,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,h)[h]++,this},i.clear=function(){n(this,u)[u]=null,n(this,o)[o]=null,n(this,h)[h]=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===(h=s)||void 0===h?void 0:h.next);){var h,l,a,f,v;e(null===(l=s)||void 0===l?void 0:l.next.value,t)?(r=null===(a=s)||void 0===a?void 0:a.next,s.next=null===(f=s)||void 0===f?void 0:f.next.next):s=null===(v=s)||void 0===v?void 0:v.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,h)[h]},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"),h=i("numberOfNodes"),l=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"),f=function(){function t(t){void 0===t&&(t=100),Object.defineProperty(this,v,{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,v)[v]=[],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,v)[v]=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,v)[v][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,v)[v][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,v)[v][n(this,c)[c]]},i.toArray=function(){return n(this,v)[v]},i.toString=function(){return n(this,v)[v].map((function(t){return JSON.stringify(t)})).toString()},t}(),v=i("storage"),c=i("front"),d=i("rear"),p=i("size"),y=i("capacity"),x=function(){function t(){Object.defineProperty(this,b,{writable:!0,value:void 0}),Object.defineProperty(this,m,{writable:!0,value:void 0}),n(this,m)[m]={},n(this,b)[b]=new Map}var i=t.prototype;return i.hashCode=function(t){var i,n;for(i=0,n=0;i<(""+t).length;i++)n=Math.imul(31,n)+(""+t).charCodeAt(i)|0;return n},i.get=function(t){var i=this.hashCode(t);return n(this,b)[b].get(i)},i.set=function(t,i){var r=this.hashCode(t);n(this,m)[m][r]=t,n(this,b)[b].set(r,i)},i.delete=function(t){var i=this.hashCode(t);delete n(this,m)[m][i],n(this,b)[b].delete(i)},i.contains=function(t){var i=this.hashCode(t);return n(this,b)[b].has(i)},i.keys=function(){return this.toArray().map((function(t){return t[0]}))},i.clear=function(){n(this,m)[m]={},n(this,b)[b].clear()},i.size=function(){return n(this,b)[b].size},i.isEmpty=function(){return 0===this.size()},i.toArray=function(){var t=this;return Array.from(n(this,b)[b]).map((function(i){var r=i[0],e=i[1];return[n(t,m)[m][r],e]}))},i.toString=function(){var t=this,i=[];return n(this,b)[b].forEach((function(r,e){var s=n(t,m)[m][e];i.push(s+"="+JSON.stringify(r))})),i.join(",")},t}(),b=i("buckets"),m=i("keys");exports.HashTable=x,exports.LinkedList=s,exports.Queue=f,exports.Stack=l; | ||
//# sourceMappingURL=rahome.cjs.production.min.js.map |
@@ -536,3 +536,189 @@ var id = 0; | ||
export { LinkedList, Queue, Stack }; | ||
var HashTable = /*#__PURE__*/function () { | ||
/** | ||
* Creates an instance of HashTable. | ||
* @memberof HashTable | ||
*/ | ||
function HashTable() { | ||
Object.defineProperty(this, _buckets, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, _keys, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
_classPrivateFieldLooseBase(this, _keys)[_keys] = {}; | ||
_classPrivateFieldLooseBase(this, _buckets)[_buckets] = new Map(); | ||
} | ||
var _proto = HashTable.prototype; | ||
/** | ||
* Returns the hash code passed key | ||
* | ||
* @param {K} key | ||
* @returns {K} hash code of passed key | ||
* @memberof HashTable | ||
*/ | ||
_proto.hashCode = function hashCode(key) { | ||
// copied from https://gist.github.com/hyamamoto/fd435505d29ebfa3d9716fd2be8d42f0#gistcomment-2694461 | ||
var i, h; | ||
for (i = 0, h = 0; i < ("" + key).length; i++) { | ||
h = Math.imul(31, h) + ("" + key).charCodeAt(i) | 0; | ||
} | ||
return h; | ||
} | ||
/** | ||
* Returns the value to which the specified key is mapped, or undefined if this HashTable contains no mapping for the key. | ||
* | ||
* @param {K} key | ||
* @returns {(V | undefined)} value or undefined | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.get = function get(key) { | ||
var keyHash = this.hashCode(key); | ||
return _classPrivateFieldLooseBase(this, _buckets)[_buckets].get(keyHash); | ||
} | ||
/** | ||
* Adds or updates an value with a specified key | ||
* | ||
* @param {K} key | ||
* @param {V} value | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.set = function set(key, value) { | ||
var keyHash = this.hashCode(key); | ||
_classPrivateFieldLooseBase(this, _keys)[_keys][keyHash] = key; | ||
_classPrivateFieldLooseBase(this, _buckets)[_buckets].set(keyHash, value); | ||
} | ||
/** | ||
* Removes the specified key and value from a HashTable | ||
* | ||
* @param {K} key | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto["delete"] = function _delete(key) { | ||
var keyHash = this.hashCode(key); | ||
delete _classPrivateFieldLooseBase(this, _keys)[_keys][keyHash]; | ||
_classPrivateFieldLooseBase(this, _buckets)[_buckets]["delete"](keyHash); | ||
} | ||
/** | ||
* Tests if some key is exist into HashTable. | ||
* | ||
* @param {K} key | ||
* @returns {boolean} | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.contains = function contains(key) { | ||
var keyHash = this.hashCode(key); | ||
return _classPrivateFieldLooseBase(this, _buckets)[_buckets].has(keyHash); | ||
} | ||
/** | ||
* Returns an enumeration of the keys in this hashtable. | ||
* | ||
* @returns {Array<any>} | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.keys = function keys() { | ||
return this.toArray().map(function (value) { | ||
var key = value[0]; | ||
return key; | ||
}); | ||
} | ||
/** | ||
* Clears this hashtable so that it contains no keys. | ||
* | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.clear = function clear() { | ||
_classPrivateFieldLooseBase(this, _keys)[_keys] = {}; | ||
_classPrivateFieldLooseBase(this, _buckets)[_buckets].clear(); | ||
} | ||
/** | ||
* Returns the number of keys in this hashtable. | ||
* | ||
* @returns {number} number of keys in this hashtable | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.size = function size() { | ||
return _classPrivateFieldLooseBase(this, _buckets)[_buckets].size; | ||
} | ||
/** | ||
* Returns true if hashtable is empty | ||
* | ||
* @returns {boolean} true if hashtable is empty | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.isEmpty = function isEmpty() { | ||
return this.size() === 0; | ||
} | ||
/** | ||
* Returns an array containing all of the hashtable | ||
* | ||
* @returns {Array} | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.toArray = function toArray() { | ||
var _this = this; | ||
return Array.from(_classPrivateFieldLooseBase(this, _buckets)[_buckets]).map(function (pairs) { | ||
var hashCode = pairs[0], | ||
value = pairs[1]; | ||
return [_classPrivateFieldLooseBase(_this, _keys)[_keys][hashCode], value]; | ||
}); | ||
} | ||
/** | ||
* Returns string representation of hashtable | ||
* | ||
* @returns {string} | ||
* @memberof HashTable | ||
*/ | ||
; | ||
_proto.toString = function toString() { | ||
var _this2 = this; | ||
var output = []; | ||
_classPrivateFieldLooseBase(this, _buckets)[_buckets].forEach(function (value, key) { | ||
var decodedHashKey = _classPrivateFieldLooseBase(_this2, _keys)[_keys][key]; | ||
output.push(decodedHashKey + "=" + JSON.stringify(value)); | ||
}); | ||
return output.join(','); | ||
}; | ||
return HashTable; | ||
}(); | ||
var _buckets = /*#__PURE__*/_classPrivateFieldLooseKey("buckets"); | ||
var _keys = /*#__PURE__*/_classPrivateFieldLooseKey("keys"); | ||
export { HashTable, LinkedList, Queue, Stack }; | ||
//# sourceMappingURL=rahome.esm.js.map |
{ | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"license": "MIT", | ||
@@ -11,3 +11,3 @@ "main": "dist/index.js", | ||
"start": "tsdx watch", | ||
"build": "tsdx build", | ||
"build": "tsdx build --format cjs,esm,umd", | ||
"test": "tsdx test", | ||
@@ -20,3 +20,3 @@ "test:ci": "cross-env CI=true tsdx test", | ||
"lint": "tsdx lint src", | ||
"prettier": "prettier \"src/**/*.+(js|jsx|ts|tsx|json|css|scss|md|html|yaml)\"", | ||
"prettier": "prettier \"**/*.+(js|jsx|ts|tsx|json|css|scss|md|html|yml|yaml)\"", | ||
"format": "npm run prettier -- --write", | ||
@@ -41,3 +41,18 @@ "prepare": "tsdx build", | ||
"name": "rahome", | ||
"author": "sagar", | ||
"description": "Popular data structures for writing efficient programs in JavaScript", | ||
"author": "Sagar <sgavhane70@gmail.com> (https://dev.to/sagar)", | ||
"homepage": "https://github.com/sagar-gavhane/rahome", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/sagar-gavhane/rahome" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/sagar-gavhane/rahome/issues" | ||
}, | ||
"keywords": [ | ||
"data structure", | ||
"linked list", | ||
"stack", | ||
"queue" | ||
], | ||
"module": "dist/rahome.esm.js", | ||
@@ -44,0 +59,0 @@ "devDependencies": { |
@@ -12,3 +12,4 @@ # rahome | ||
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/sagar-gavhane/rahome/CI?style=flat-square) | ||
![tests](https://github.com/sagar-gavhane/rahome/workflows/tests/badge.svg) | ||
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/sagar-gavhane/rahome/tests?style=flat-square) | ||
[![GitHub issues](https://img.shields.io/github/issues/sagar-gavhane/rahome?style=flat-square)](https://github.com/sagar-gavhane/rahome/issues) | ||
@@ -15,0 +16,0 @@ ![GitHub contributors](https://img.shields.io/github/contributors-anon/sagar-gavhane/rahome?style=flat-square) |
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
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
121391
22
1483
0
1
52
1