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

mnemonist

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mnemonist - npm Package Compare versions

Comparing version 0.27.2 to 0.28.0

critbit-tree-map.js

4

CHANGELOG.md
# Changelog
## 0.28.0
* Adding `LRUCache.peek` and `LRUMap.peek` (@veggiesaurus).
## 0.27.2

@@ -4,0 +8,0 @@

@@ -21,2 +21,3 @@ /**

get(key: K): V | undefined;
peek(key: K): V | undefined;
has(key: K): boolean;

@@ -23,0 +24,0 @@ forEach(callback: (value: V, key: K, cache: this) => void, scope?: any): void;

@@ -171,2 +171,18 @@ /**

/**
* Method used to get the value attached to the given key. Does not modify
* the ordering of the underlying linked list.
*
* @param {any} key - Key.
* @return {any}
*/
LRUCache.prototype.peek = function(key) {
var pointer = this.items[key];
if (typeof pointer === 'undefined')
return;
return this.V[pointer];
};
/**
* Method used to iterate over the cache's entries using a callback.

@@ -173,0 +189,0 @@ *

@@ -21,2 +21,3 @@ /**

get(key: K): V | undefined;
peek(key: K): V | undefined;
has(key: K): boolean;

@@ -23,0 +24,0 @@ forEach(callback: (value: V, key: K, cache: this) => void, scope?: any): void;

@@ -130,3 +130,18 @@ /**

/**
* Method used to get the value attached to the given key. Does not modify
* the ordering of the underlying linked list.
*
* @param {any} key - Key.
* @return {any}
*/
LRUMap.prototype.peek = function(key) {
var pointer = this.items.get(key);
if (typeof pointer === 'undefined')
return;
return this.V[pointer];
};
/**

@@ -133,0 +148,0 @@ * Methods that can be reused as-is from LRUCache.

3

package.json
{
"name": "mnemonist",
"version": "0.27.2",
"version": "0.28.0",
"description": "Curated collection of data structures for the JavaScript language.",

@@ -73,2 +73,3 @@ "scripts": {

"@yomguithereal/eslint-config": "^4.0.0",
"asciitree": "^1.0.2",
"damerau-levenshtein": "^1.0.3",

@@ -75,0 +76,0 @@ "eslint": "^5.12.1",

@@ -108,2 +108,4 @@ /* eslint no-constant-condition: 0 */

var offset = this.maps.length;
this.maps.resize(offset + 255);
this.maps.set(offset + 255, 0);

@@ -110,0 +112,0 @@

@@ -9,3 +9,69 @@ /**

/**
* Takes a max 32bits integer and returns its population count (number of 1 of
* Takes a 32 bits integer and returns its MSB using SWAR strategy.
*
* @param {number} x - Target number.
* @return {number}
*/
function msb32(x) {
x |= (x >> 1);
x |= (x >> 2);
x |= (x >> 4);
x |= (x >> 8);
x |= (x >> 16);
return (x & ~(x >> 1));
}
exports.msb32 = msb32;
/**
* Takes a byte and returns its MSB using SWAR strategy.
*
* @param {number} x - Target number.
* @return {number}
*/
function msb8(x) {
x |= (x >> 1);
x |= (x >> 2);
x |= (x >> 4);
return (x & ~(x >> 1));
}
exports.msb8 = msb8;
/**
* Takes a number and return bit at position.
*
* @param {number} x - Target number.
* @param {number} pos - Position.
* @return {number}
*/
exports.test = function(x, pos) {
return (x >> pos) & 1;
};
/**
* Compare two bytes and return their critical bit.
*
* @param {number} a - First byte.
* @param {number} b - Second byte.
* @return {number}
*/
exports.criticalBit8 = function(a, b) {
return msb8(a ^ b);
};
exports.criticalBit8Mask = function(a, b) {
return (~msb8(a ^ b) >>> 0) & 0xff;
};
exports.testCriticalBit8 = function(x, mask) {
return (1 + (x | mask)) >> 8;
};
exports.criticalBit32Mask = function(a, b) {
return (~msb32(a ^ b) >>> 0) & 0xffffffff;
};
/**
* Takes a 32 bits integer and returns its population count (number of 1 of
* the binary representation).

@@ -12,0 +78,0 @@ *

@@ -22,2 +22,6 @@ /**

var MAX_SIGNED_8BIT_INTEGER = Math.pow(2, 7) - 1,
MAX_SIGNED_16BIT_INTEGER = Math.pow(2, 15) - 1,
MAX_SIGNED_32BIT_INTEGER = Math.pow(2, 31) - 1;
exports.getPointerArray = function(size) {

@@ -38,2 +42,17 @@ var maxIndex = size - 1;

exports.getSignedPointerArray = function(size) {
var maxIndex = size - 1;
if (maxIndex <= MAX_SIGNED_8BIT_INTEGER)
return Int8Array;
if (maxIndex <= MAX_SIGNED_16BIT_INTEGER)
return Int16Array;
if (maxIndex <= MAX_SIGNED_32BIT_INTEGER)
return Int32Array;
return Float64Array;
};
/**

@@ -40,0 +59,0 @@ * Function returning the minimal type able to represent the given number.

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