
Security News
Potemkin Understanding in LLMs: New Study Reveals Flaws in AI Benchmarks
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
binary-heap.js
Advanced tools
A package for general purpose binary heap data structure that can contain any type of data
npm i binary-heap.js
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
extractor | function | false | function that extracts the key used for sorting elements in the heap (should be equal to identity for primitive data types) |
Name | Description | Return |
---|---|---|
Insert | Insert a single element into the heap | void |
InsertMany | Inserts Many elements into the heap | void |
pop | Pops the top element (maximum or minimum depending on the type of the heap) | type T (type of elements inserted) |
isEmpty | Checks if the heap is empty or not | boolean |
const maxHeap = new MaxHeap( (x) =>x );
maxHeap.insert(3);
maxHeap.insertMany([5,7].values())
maxHeap.pop() // 7
maxHeap.pop() // 5
maxHeap.pop() // 3
maxHeap.pop() // undefined
const minHeap = new MinHeap( (x) =>x );
maxHeap.insert(5);
maxHeap.insertMany([3,7].values())
maxHeap.pop() // 3
maxHeap.pop() // 5
maxHeap.pop() // 7
maxHeap.pop() // undefined
Works with any data structure that implements the iteratable interface to provide it's elements
// Works with arrays, maps, sets
const arr = [1,2,3];
const set = new Set([1,2,3])
const map = new Map();
map.set(1,1)
map.set(2,2)
map.set(3,3);
const maxHeapOne = new MaxHeap((x) =>x);
maxHeapOne.insertMany(arr.values());
const maxHeapTwo = new MaxHeap((x) =>x);
maxHeapTwo.insertMany(set.values());
const maxHeapThree = new MaxHeap((x) =>x);
maxHeapThree.insertMany(map.keys().values());
Works with complex objects as long as you provide the right extractor
const arr = [{id:1},{id:2},{id:3}];
const maxHeap = new MaxHeap((x) =>x.id);
maxHeap.insertMany(arr.values());
FAQs
A package for binary heap (heap tree) data structure
The npm package binary-heap.js receives a total of 23 weekly downloads. As such, binary-heap.js popularity was classified as not popular.
We found that binary-heap.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.