npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

asino

v0.3.3

Published

Asino, a stubborn, simple and fast Bloom filter for the rest of us.

Downloads

29

Readme

Asino

NPM VERSION CODACY BADGE CODECLIMATE-TEST-COVERAGE LICENSE

NODE VERSION TRAVIS CI BUILD BUILD STATUS DEVDEPENDENCY STATUS

NPM MONTHLY NPM YEARLY NPM TOTAL

NPM GRAPH

Asino, a stubborn, simple and fast Bloom filter for the rest of us.

Install

$ npm install asino [-g]

require:

var Asino  = require( 'asino' );

Run Tests

to run all test files, install devDependencies:

 $ cd asino/
 # install or update devDependencies
 $ npm install 
 # run tests
 $ npm test

Constructor

Asino( [ Object opt ] )
// or
new Asino( [ Object opt ] )

Options

Default options are listed.

opt = {
	/*
	 * expected population of elements
	 */
	epop : 10000
	
	/*
	 * The max number of bytes to parse from every 
	 * input element, using the pseudo-random table.
	 * In normal mode you should specify this property
	 * generally sizing it on the expected input length.
	 *
	 * When dunce mode is on, this property is ignored,
	 * because no pseduo-random table will be generated.
	 */
	, ilen : 32
	
	/*
	 * The number of hash functions to use.
	 * The greater the number, lesser is the probability
	 * of collisions.
	 *
	 * - the false positive probability:
	 *
	 *   fpp ~= - 1 / ( 10 ^ hfn )
	 *
 	 * In dunce mode this number is limited to 16.
	 */ 
	, hfn : 6
	
	/*
	 * Dunce mode, it is off for default.
	 *
	 * It is a fast way for testing collisions/duplicates on 
	 * long inputs ( > ~ 64 bytes ), without the construction
	 * and the use of pseudo-random table, because it uses a
	 * crypto digest to simulate 16 different hash functions.
	 *
	 * However, no randomness is involved for producing values,
	 * then, for every distinct function (0-15): 
	 *
	 * Same input -> Same hash result. Every time.
	 *
	 * In dunce mode the integer produced by hash functions
	 * are limited to the range [2^24, 2^32 -1].
	 */
	, dunce: false
}

Properties

/*
 * the internal bitmap.
 */
Asino.vector

/*
 * the internal pseudo-random table used to generate k
 * indipendent hash functions.
 */
Asino.hash

/*
 * the total number of bits used for the bitmap vector.
 */
Asino.bits

/*
 * the total number of hash functions
 */
Asino.hfn

/*
 * the max bytes to parse from input
 */
Asino.ilen

/*
 * the current false positive probability
 */
Asino.fpp

Methods

Arguments between [] are optional.

/*
 * Check if an element exists.
 * When it returns false, we are sure that the element
 * does not exist in the filter. 
 * When it returns true, there is a probability of a
 * false positive, equal to the current fpp.
 */
Asino#key( Buffer data ) : Boolean

/*
 * try to add the element if it doesn't exist.
 * It returns the same result of Asino#key
 */
Asino#try( Buffer data ) : Boolean

/*
 * Reset/regenerate the filter
 */
Asino#yoke() : Asino

/*
 * Re-build Bloom filter, via a config object.
 */
Asino#grow( [ Object opt ] ) : Asino

opt : { [ hfn: Number ] [, epop: Number] [, ilen : Number] [, dunce: Boolean] }

See examples.

MIT License

Copyright (c) 2017-present < Guglielmo Ferri : [email protected] >

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.