{"versions":{"0.1.0":{"name":"heap","version":"0.1.0","description":"binary heap (priority queue) algorithms (ported from Python's heapq module)","homepage":"https://github.com/qiao/heap.js","keywords":["algorithm","data structure","heap"],"author":{"name":"Xueqiao Xu","email":"xueqiaoxu@gmail.com"},"main":"./index.js","dependencies":{},"devDependencies":{"coffee-script":">= 1.2.0","mocha":">= 0.14.0","should":">= 0.6.0"},"repository":{"type":"git","url":"git://github.com/qiao/heap.js.git"},"licenses":[{"type":"MIT","url":"http://opensource.org/licenses/mit-license.php"}],"_npmUser":{"name":"anonymous","email":"xueqiaoxu@gmail.com"},"_id":"heap@0.1.0","optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.9","_nodeVersion":"v0.6.13","_defaultsLoaded":true,"dist":{"shasum":"d601715c7717fd9915fbbc35c8805f4a49f6f229","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/heap/-/heap-0.1.0.tgz"},"maintainers":[{"name":"anonymous","email":"xueqiaoxu@gmail.com"}],"directories":{},"contributors":[]},"0.1.2":{"name":"heap","version":"0.1.2","description":"binary heap (priority queue) algorithms (ported from Python's heapq module)","homepage":"https://github.com/qiao/heap.js","keywords":["algorithm","data structure","heap"],"author":{"name":"Xueqiao Xu","email":"xueqiaoxu@gmail.com"},"main":"./index.js","dependencies":{},"devDependencies":{"coffee-script":">= 1.2.0","mocha":">= 0.14.0","should":">= 0.6.0"},"repository":{"type":"git","url":"git://github.com/qiao/heap.js.git"},"licenses":[{"type":"PSF","url":"http://docs.python.org/license.html"}],"_npmUser":{"name":"anonymous","email":"xueqiaoxu@gmail.com"},"_id":"heap@0.1.2","optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.9","_nodeVersion":"v0.6.13","_defaultsLoaded":true,"dist":{"shasum":"fb43eb55ad974c7b17b8942d05740dc44cc27ac8","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/heap/-/heap-0.1.2.tgz"},"maintainers":[{"name":"anonymous","email":"xueqiaoxu@gmail.com"}],"directories":{},"contributors":[]},"0.2.0":{"name":"heap","version":"0.2.0","description":"binary heap (priority queue) algorithms (ported from Python's heapq module)","homepage":"https://github.com/qiao/heap.js","keywords":["algorithm","data structure","heap"],"author":{"name":"Xueqiao Xu","email":"xueqiaoxu@gmail.com"},"main":"./index.js","dependencies":{},"devDependencies":{"coffee-script":">= 1.3.0","mocha":">= 0.14.0","should":">= 0.6.0"},"repository":{"type":"git","url":"git://github.com/qiao/heap.js.git"},"licenses":[{"type":"PSF","url":"http://docs.python.org/license.html"}],"_npmUser":{"name":"anonymous","email":"xueqiaoxu@gmail.com"},"_id":"heap@0.2.0","optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.18","_nodeVersion":"v0.6.15","_defaultsLoaded":true,"dist":{"shasum":"8ea3bbd03f9cc17509dc0aed4502523eb4963486","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/heap/-/heap-0.2.0.tgz"},"maintainers":[{"name":"anonymous","email":"xueqiaoxu@gmail.com"}],"directories":{},"contributors":[]},"0.2.1":{"name":"heap","version":"0.2.1","description":"binary heap (priority queue) algorithms (ported from Python's heapq module)","homepage":"https://github.com/qiao/heap.js","keywords":["algorithm","data structure","heap"],"author":{"name":"Xueqiao Xu","email":"xueqiaoxu@gmail.com"},"main":"./index.js","dependencies":{},"devDependencies":{"coffee-script":"1.3.x","mocha":"1.0.x","should":"0.6.x"},"repository":{"type":"git","url":"git://github.com/qiao/heap.js.git"},"licenses":[{"type":"PSF","url":"http://docs.python.org/license.html"}],"_npmUser":{"name":"anonymous","email":"xueqiaoxu@gmail.com"},"_id":"heap@0.2.1","optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.18","_nodeVersion":"v0.6.15","_defaultsLoaded":true,"dist":{"shasum":"85829b1ea798ce41a548fa908c069baa075152ad","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/heap/-/heap-0.2.1.tgz"},"maintainers":[{"name":"anonymous","email":"xueqiaoxu@gmail.com"}],"directories":{},"contributors":[]},"0.2.2":{"name":"heap","version":"0.2.2","description":"binary heap (priority queue) algorithms (ported from Python's heapq module)","homepage":"https://github.com/qiao/heap.js","keywords":["algorithm","data structure","heap"],"author":{"name":"Xueqiao Xu","email":"xueqiaoxu@gmail.com"},"main":"./index.js","dependencies":{},"devDependencies":{"coffee-script":"1.3.x","mocha":"1.0.x","should":"0.6.x"},"repository":{"type":"git","url":"git://github.com/qiao/heap.js.git"},"licenses":[{"type":"PSF","url":"http://docs.python.org/license.html"}],"bugs":{"url":"https://github.com/qiao/heap.js/issues"},"_id":"heap@0.2.2","dist":{"shasum":"fc204a17e6bc58a4ef75a98bc1ac795f147c8a1f","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/heap/-/heap-0.2.2.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"anonymous","email":"xueqiaoxu@gmail.com"},"maintainers":[{"name":"anonymous","email":"xueqiaoxu@gmail.com"}],"directories":{},"contributors":[]},"0.2.3":{"name":"heap","version":"0.2.3","description":"binary heap (priority queue) algorithms (ported from Python's heapq module)","homepage":"https://github.com/qiao/heap.js","keywords":["algorithm","data structure","heap"],"author":{"name":"Xueqiao Xu","email":"xueqiaoxu@gmail.com"},"main":"./index.js","dependencies":{},"devDependencies":{"coffee-script":"1.3.x","mocha":"1.0.x","should":"0.6.x"},"repository":{"type":"git","url":"git://github.com/qiao/heap.js.git"},"licenses":[{"type":"PSF","url":"http://docs.python.org/license.html"}],"bugs":{"url":"https://github.com/qiao/heap.js/issues"},"_id":"heap@0.2.3","dist":{"shasum":"59f1466e0f40e9fec41866e5261d01780f90577b","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/heap/-/heap-0.2.3.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"anonymous","email":"xueqiaoxu@gmail.com"},"maintainers":[{"name":"anonymous","email":"xueqiaoxu@gmail.com"}],"directories":{},"contributors":[]},"0.2.4":{"name":"heap","version":"0.2.4","description":"binary heap (priority queue) algorithms (ported from Python's heapq module)","homepage":"https://github.com/qiao/heap.js","keywords":["algorithm","data structure","heap"],"author":{"name":"Xueqiao Xu","email":"xueqiaoxu@gmail.com"},"main":"./index.js","dependencies":{},"devDependencies":{"coffee-script":"1.3.x","mocha":"1.0.x","should":"0.6.x"},"scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/qiao/heap.js.git"},"licenses":[{"type":"PSF","url":"http://docs.python.org/license.html"}],"gitHead":"c782fab6f0bb8bfc16c72387d2916034c84debbe","bugs":{"url":"https://github.com/qiao/heap.js/issues"},"_id":"heap@0.2.4","_shasum":"e96b141eb7956882de41945a6c5bbb985fd3cfae","_from":".","_npmVersion":"1.4.16","_npmUser":{"name":"anonymous","email":"xueqiaoxu@gmail.com"},"maintainers":[{"name":"anonymous","email":"xueqiaoxu@gmail.com"}],"dist":{"shasum":"e96b141eb7956882de41945a6c5bbb985fd3cfae","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/heap/-/heap-0.2.4.tgz"},"directories":{},"contributors":[]},"0.2.5":{"name":"heap","version":"0.2.5","description":"binary heap (priority queue) algorithms (ported from Python's heapq module)","homepage":"https://github.com/qiao/heap.js","keywords":["algorithm","data structure","heap"],"author":{"name":"Xueqiao Xu","email":"xueqiaoxu@gmail.com"},"main":"./index.js","dependencies":{},"devDependencies":{"coffee-script":"1.3.x","mocha":"1.0.x","should":"0.6.x"},"scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/qiao/heap.js.git"},"licenses":[{"type":"PSF","url":"http://docs.python.org/license.html"}],"gitHead":"0eda661c983504ee239aeae6191401fad3ef4c55","bugs":{"url":"https://github.com/qiao/heap.js/issues"},"_id":"heap@0.2.5","_shasum":"713b65590ebcc40fcbeeaf55e851694092b39af1","_from":".","_npmVersion":"1.4.16","_npmUser":{"name":"anonymous","email":"xueqiaoxu@gmail.com"},"maintainers":[{"name":"anonymous","email":"xueqiaoxu@gmail.com"}],"dist":{"shasum":"713b65590ebcc40fcbeeaf55e851694092b39af1","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/heap/-/heap-0.2.5.tgz"},"directories":{},"contributors":[]},"0.2.6":{"name":"heap","version":"0.2.6","description":"binary heap (priority queue) algorithms (ported from Python's heapq module)","homepage":"https://github.com/qiao/heap.js","keywords":["algorithm","data structure","heap"],"author":{"name":"Xueqiao Xu","email":"xueqiaoxu@gmail.com"},"main":"./index.js","dependencies":{},"devDependencies":{"coffee-script":"1.3.x","mocha":"2.1.x","should":"0.6.x"},"scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/qiao/heap.js.git"},"licenses":[{"type":"PSF","url":"http://docs.python.org/license.html"}],"gitHead":"6244ef82933f42ae0e8e0e60aff7196f3f2feb61","bugs":{"url":"https://github.com/qiao/heap.js/issues"},"_id":"heap@0.2.6","_shasum":"087e1f10b046932fc8594dd9e6d378afc9d1e5ac","_from":".","_npmVersion":"2.1.6","_nodeVersion":"0.10.33","_npmUser":{"name":"anonymous","email":"xueqiaoxu@gmail.com"},"maintainers":[{"name":"anonymous","email":"xueqiaoxu@gmail.com"}],"dist":{"shasum":"087e1f10b046932fc8594dd9e6d378afc9d1e5ac","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/heap/-/heap-0.2.6.tgz"},"directories":{},"contributors":[]},"0.2.7":{"name":"heap","version":"0.2.7","description":"binary heap (priority queue) algorithms (ported from Python's heapq module)","homepage":"https://github.com/qiao/heap.js","keywords":["algorithm","data structure","heap"],"author":{"name":"Xueqiao Xu","email":"xueqiaoxu@gmail.com"},"main":"./index.js","devDependencies":{"coffee-script":"1.3.x","mocha":"2.1.x","should":"0.6.x"},"scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/qiao/heap.js.git"},"license":"MIT","gitHead":"21701c0b9c22039de6f948ed5f6d44e53ae79231","bugs":{"url":"https://github.com/qiao/heap.js/issues"},"_id":"heap@0.2.7","_nodeVersion":"17.0.1","_npmVersion":"8.1.0","dist":{"integrity":"sha512-2bsegYkkHO+h/9MGbn6KWcE45cHZgPANo5LXF7EvWdT0yT2EguSVO1nDgU5c8+ZOPwp2vMNa7YFsJhVcDR9Sdg==","shasum":"1e6adf711d3f27ce35a81fe3b7bd576c2260a8fc","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/heap/-/heap-0.2.7.tgz","fileCount":10,"unpackedSize":23093,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhqICJCRA9TVsSAnZWagAAZHgP+wWdPeqMxVG3Kl0STO4n\ni4fu0mjzget+KR79uwqozeCHjc/M08zLDG+fsqyEENfQuT99Uxg94tyDejtR\nZTn4IH2GMYh+uO7Cu3pTNULs8eMCxym/sx21xwDdm7vUJRp4XJWdNg8StsKs\ncY46tr5ESThqMPfBHnu+z57ubndbPD6prkNyjZ5luc7RjwtLb2wcCsjXjMnV\nExWcIiThjWMM/l2TNQVB4J3DL15s8FPAdV5MGYPsQ7aJkf4HNMDX6CLtLJq3\ndS1vEMNVbnrezzV4/U1I9xawbj4b2GbZ2N6Qq+nRId/fmNsa//wj6QlidClF\n+OJd5bwuj1biY5RSXy/BwqgMedhmkED9nyN9f8EpQ0fUx0oFmhQ0UWkYafaU\n7tsIG6ksZoSqH9uSB5iQEYO4tFSuPDLJNMJe72iTZa1mvUqyFR4XPSxl9DvC\nWuUHKyL7fz1A/wkRxq1ONO99AnCHGcmEophZK6HoL1yEYb+xooQqtHfTMUx7\nQweYIsyGTyuRQm6AeryiZH79iB6oJMVwKrETBOnXP5BbHcPX0DoN8DvFliHf\nSHRndolJ30+Zc0RX1wbHO4BbPQWPhaYcMM6V2dCpzcnxUoYkeRieEPC0SPDv\n0hTSMKRx5tRitgSkzo6Vu29XO2NJVjvu6BowfPG6mxlyCHxZVo6dCH6IaQ42\nrLs1\r\n=P+NH\r\n-----END PGP SIGNATURE-----\r\n","size":6718,"noattachment":false},"_npmUser":{"name":"anonymous","email":"xueqiaoxu@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"xueqiaoxu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/heap_0.2.7_1638432905165_0.29257309632662976"},"_hasShrinkwrap":false,"publish_time":1638432905314,"_cnpm_publish_time":1638432905314,"_cnpmcore_publish_time":"2021-12-16T18:49:03.566Z","contributors":[]}},"dist-tags":{"latest":"0.2.7"},"name":"heap","time":{"modified":"2023-08-02T14:38:53.127Z","created":"2022-01-26T13:05:41.197Z","0.1.0":"2012-03-23T17:42:10.947Z","0.1.2":"2012-03-24T03:21:50.261Z","0.2.0":"2012-04-22T16:50:06.403Z","0.2.1":"2012-04-29T06:21:25.285Z","0.2.2":"2013-10-16T01:45:20.902Z","0.2.3":"2013-10-23T08:49:10.721Z","0.2.4":"2014-08-13T06:06:50.545Z","0.2.5":"2014-09-10T18:30:11.140Z","0.2.6":"2015-02-09T07:09:00.041Z","0.2.7":"2021-12-02T08:15:05.314Z"},"readme":"Heap.js\n=======\n\n[![Build Status](https://travis-ci.org/qiao/heap.js.svg?branch=master)](https://travis-ci.org/qiao/heap.js)\n\nA binary heap implementation in CoffeeScript/JavaScript. Ported from Python's [heapq](http://docs.python.org/library/heapq.html) module.\n\n\nDownload\n--------\n\nThis module can be used in either the browser or node.js.\n\nfor browser use, you may [download the script](https://raw.github.com/qiao/heap.js/master/lib/heap.js) and include it in you web page.\n\n```html\n<script type=\"text/javascript\" src=\"./heap.js\"></script>\n```\n\nfor node.js, you may install it via npm:\n\n```bash\nnpm install heap\n```\n\nthen require it:\n\n```\nvar Heap = require('heap');\n```\n\nExamples\n-------\n\n\npush and pop\n\n```js\nvar heap = new Heap();\nheap.push(3);\nheap.push(1);\nheap.push(2);\nheap.pop(); // 1\n```\n\ncustom comparison function\n\n```js\nvar heap = new Heap(function(a, b) {\n    return a.foo - b.foo;\n});\nheap.push({foo: 3});\nheap.push({foo: 1});\nheap.push({foo: 2});\nheap.pop(); // {foo: 1}\n```\n\nfind 3 largest/smallest items in an array\n\n```js\nvar array = [1, 3, 4, 2, 5];\nHeap.nlargest(array, 3);  // [5, 4, 3]\nHeap.nsmallest(array, 3); // [1, 2, 3]\n```\n\nDocument\n--------\n\nThis module exposes only one object, namely the Heap class.\n\n### Constructor: Heap([cmp]) ###\n\nThe constructor receives a comparison function as an optional parameter. If omitted, the heap is built as a min-heap, which means that the smallest element will be popped out first.\n\nIf the comparison function is supplied, the heap will be built according to the \nreturn value of the comparison function.\n\n* if cmp(a, b) < 0, then item a will come prior to b\n* if cmp(a, b) > 0, then item b will come prior to a\n\nSo, the comparison function has the following form:\n\n```js\nfunction cmp(a, b) {\n  if (a is prior to b) {\n    return -1;\n  } \n  if (b is prior to a) {\n    return 1;\n  }\n  return 0;\n}\n```\n\nTo compare numbers, simply: \n\n```js\nfunction cmp(a, b) {\n  return a - b;\n}\n```\n\n### Instance Methods ###\n\n**push(item)** (alias: **insert**) \n\nPush item onto heap.\n\n**pop()**\n\nPop the smallest item off the heap and return it.\n\n**peek()** (alias: **top** / **front**)\n\nReturn the smallest item of the heap.\n\n**replace(item)**\n\nPop and return the current smallest value, and add the new item.\n\nThis is more efficient than pop() followed by push(), and can be \nmore appropriate when using a fixed size heap. Note that the value\nreturned may be larger than item! \n\n**pushpop(item)**\n\nFast version of a push followed by a pop.\n\n**heapify()**\n\nRebuild the heap. This method may come handy when the priority of the \ninternal data is being modified.\n\n**updateItem(item)**\n\nUpdate the position of the given item in the heap.\nThis function should be called every time the item is being modified.\n\n**empty()**\n\nDetermine whether the heap is empty.\n\n**size()**\n\nGet the number of elements stored in the heap.\n\n**toArray()**\n\nReturn the array representation of the heap. (note: the array is a shallow copy of the heap's internal nodes)\n\n**clone()** (alias: **copy**)\n\nReturn a clone of the heap. (note: the internal data is a shallow copy of the original one)\n\n### Static Methods ###\n\nNOTE: All the static methods are designed to be applied on arrays.\n\n**push(array, item, [cmp])** \n\nPush item onto array, maintaining the heap invariant.\n\n**pop(array, [cmp])**\n\nPop the smallest item off the array, maintaining the heap invariant.\n\n**replace(array, item, [cmp])**\n\nPop and return the current smallest value, and add the new item.\n\nThis is more efficient than heappop() followed by heappush(), and can be \nmore appropriate when using a fixed size heap. Note that the value\nreturned may be larger than item! \n\n**pushpop(array, item, [cmp])**\n\nFast version of a heappush followed by a heappop.\n\n**heapify(array, [cmp])**\n\nBuild the heap.\n\n**updateItem(array, item, [cmp])**\n\nUpdate the position of the given item in the heap.\nThis function should be called every time the item is being modified.\n\n**nlargest(array, n, [cmp])**\n\nFind the n largest elements in a dataset.\n\n**nsmallest(array, n, [cmp])**\n\nFind the n smallest elements in a dataset.","users":{}}