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

ml-hash-table

Package Overview
Dependencies
Maintainers
7
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-hash-table - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

12

package.json
{
"name": "ml-hash-table",
"version": "0.1.1",
"version": "0.1.2",
"description": "Open addressing hash table",
"main": "dist/HashTable.js",
"jsnext:main": "src/HashTable.js",
"main": "src/HashTable.js",
"scripts": {
"test": "npm run build && mocha",
"build": "rollup -c"
"test": "mocha"
},
"files": [
"dist",
"src"

@@ -36,5 +33,2 @@ ],

"mocha": "^2.4.5",
"rollup": "^0.26.3",
"rollup-plugin-commonjs": "^2.2.1",
"rollup-plugin-node-resolve": "^1.5.0",
"should": "^8.3.1"

@@ -41,0 +35,0 @@ },

@@ -1,4 +0,9 @@

import {nextPrime, largestPrime} from './primeFinder';
import newArray from 'new-array';
'use strict';
const newArray = require('new-array');
const primeFinder = require('./primeFinder');
const nextPrime = primeFinder.nextPrime;
const largestPrime = primeFinder.largestPrime;
const FREE = 0;

@@ -8,5 +13,5 @@ const FULL = 1;

const defaultInitialCapacity = 277;
const defaultMinLoadFactor = 0.2;
const defaultMaxLoadFactor = 0.5;
const defaultInitialCapacity = 150;
const defaultMinLoadFactor = 1 / 6;
const defaultMaxLoadFactor = 2 / 3;

@@ -46,2 +51,6 @@ class HashTable {

let capacity = initialCapacity;
// User wants to put at least capacity elements. We need to choose the size based on the maxLoadFactor to
// avoid the need to rehash before this capacity is reached.
// actualCapacity * maxLoadFactor >= capacity
capacity = (capacity / maxLoadFactor) | 0;
capacity = nextPrime(capacity);

@@ -279,3 +288,3 @@ if (capacity === 0) capacity = 1;

export default HashTable;
module.exports = HashTable;

@@ -282,0 +291,0 @@ function chooseLowWaterMark(capacity, minLoad) {

@@ -1,4 +0,4 @@

import binarySearch from 'ml-binary-search';
const binarySearch = require('ml-binary-search');
export const largestPrime = 0x7fffffff;
const largestPrime = 0x7fffffff;

@@ -76,3 +76,3 @@ const primeNumbers = [

export function nextPrime(value) {
function nextPrime(value) {
let index = binarySearch(primeNumbers, value);

@@ -84,1 +84,4 @@ if (index < 0) {

}
exports.nextPrime = nextPrime;
exports.largestPrime = largestPrime;
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