hashcoll-fast
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

hashcoll-fast

Fast hashset and hashmap implementation, written in Rust and compiled to Webassembly, based on hashbrown, a Rust port of Google's high-performance SwissTable hash map.

Usage

$ yarn add hashcoll-fast

String

HashSet<String>
const HashSet = require("hashcoll-fast").HashSet;
 
const set = new HashSet(4);
 
set.insert('foo');
set.insert('bar');
 
set.contains('foo'); // true
set.contains('tree'); // false
 
set.remove('foo');
HashMap<String, String>
const HashMap = require("hashcoll-fast").HashMap;
 
const map = new HashMap(4);
 
map.insert('foo', 'bar');
map.insert('tree', 'house');
 
map.contains('foo'); // true
map.contains('zig'); // false
 
map.remove('foo'); // 'bar'

Vec<u8>

HashSetRaw<Vec<u8>>
const HashSetRaw = require("./pkg").HashSetRaw;
 
const set = new HashSetRaw(4);
 
set.insert(Buffer.from('foo'));
set.insert(Buffer.from('bar'));
 
set.contains(Buffer.from('foo')); // true
set.contains(Buffer.from('tree')); // false
 
set.remove(Buffer.from('foo')); // Uint8Array(3) [ 102, 111, 111 ]
HashMap<String, Vec<u8>>
const HashMapRaw = require("hashcoll-fast").HashMap;
 
const map = new HashMapRaw(4);
 
map.insert('foo', Buffer.from('bar'));
map.insert('tree', Buffer.from('house'));
 
map.get('foo'); // // Uint8Array(3) [ 102, 111, 111 ]
map.get('trexe'); // undefined
 
map.contains('foo'); // true
map.contains('zig'); // false
 
map.remove('foo'); // Uint8Array(3) [ 102, 111, 111 ]

Build

$ make

Readme

Keywords

none

Package Sidebar

Install

npm i hashcoll-fast

Weekly Downloads

1

Version

1.1.0

License

none

Unpacked Size

44 kB

Total Files

6

Last publish

Collaborators

  • kenansulayman