Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hashset-native

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hashset-native

Native hashset for Node.js

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

node-hashset

Provides a native hashset implementation for node.

Often, when you need to use a set in JavaScript, you may instead use a JavaScript object like so:

var cache = {};

cache['foobar'] = true;

if (!cache['foobar']) {
  ...
}

This works well for up to a few million items, but after that it starts to grind v8 down to a halt.

node-hashset implements a stricly typed hashset with std::unsorted_set to enable working with extremely large sets.

Installation

$ npm install hashset-native

Quick start

var HashSet = require('hashset-native');
var set = new HashSet.string();
set.add('foobar');

Checkout the tests for more examples.

HashSet

There are currently two HashSet constructors, HashSet.int32 and HashSet.string.

add(value)

Adds value to the set.

contains(value)

Returns a boolean value indicating if the set contains value.

iterator()

Returns an iterator to iterate over the values in the set.

var it = set.iterator();

while (it.hasNext()) {
  console.log(it.next());
}

remove(value)

Removes value from the set.

clear()

Removes all values from the set.

size()

Returns the numbers of values in the set.

Keywords

FAQs

Package last updated on 11 Dec 2013

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc