New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

js-native-unordered-buffer-set

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-native-unordered-buffer-set

C++ unordered_set, for Node Buffers

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

js-native-unordered-buffer-set

A native Node module implementing an unsorted set of C strings.

The goal is for super-duper-fast string matching. That means inputs and outputs are always Buffers.

The implementation is a C++-standard unsorted_set. That's probably a hashtable. But it's far, far faster than a Node hashtable.

Usage

var BufferSet = require('js-native-unsorted-buffer-set');
// Input is a single Buffer: newline-separated Strings
var set = new BufferSet(new Buffer('foo\nbar\nbaz\nthe foo\nmoo', 'utf-8'));

console.log(set.contains('foo')); // true
console.log(set.contains('moo')); // false

console.log(set.findAllMatches('the foo drove over the moo', 2)); // [ 'the foo', 'foo', 'moo' ]

findAllMatches

This method is interesting in that it can search for tokens that span multiple words (the second argument specifies the number of words), in a memory-efficient manner. The memory used is the size of the output Array. The time complexity is on the order of the size of the input times the number of tokens.

Developing

Download, npm install.

Run mocha -w in the background as you implement features. Write tests in test and code in src.

LICENSE

AGPL-3.0. This project is (c) Overview Services Inc. Please contact us should you desire a more permissive license.

Keywords

unordered_set

FAQs

Package last updated on 27 Jul 2015

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