Usage
The code needs a ES2015+ polyfill to work, for example regenerator-runtime/runtime.
await import( 'regenerator-runtime/runtime.js' ) ;
// or
import 'regenerator-runtime/runtime.js' ;
Then
const number = await import( '@data-structure/heapq' ) ;
// or
import number from '@data-structure/heapq' ;
Examples
See Python's docs:
Changes w.r.t. Python's API
import {heapify, heappop} from '@data-structure/heapq';
import {increasing} from '@total-order/primitive';
let array = [2, 1, 3];
let heap = heapify(increasing, array);
array[0] ; // 1
heappop( heap ) ; // 1
heappop( heap ) ; // 2
heappop( heap ) ; // 3
array.length ; // 0