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

@typeberry/trie

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@typeberry/trie - npm Package Compare versions

Comparing version 0.0.1-6053b62 to 0.0.1-67e835b

32

index.d.ts

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

/** Compare the sequence to another one lexicographically. */
isLessThan(other: BytesBlob): boolean {
const min = Math.min(this.length, other.length);
const thisRaw = this.raw;
const otherRaw = other.raw;
for (let i = 0; i < min; i++) {
if (thisRaw[i] < otherRaw[i]) {
return true;
}
if (thisRaw[i] > otherRaw[i]) {
return false;
}
}
return this.length < other.length;
}
/** Create a new [`BytesBlob'] by converting given UTF-u encoded string into bytes. */

@@ -493,3 +512,3 @@ static blobFromString(v: string): BytesBlob {

// This has to be benchmarked and re-written to a custom map most likely.
private readonly map = new Map<string, V>();
private readonly map = new Map<string, [K, V]>();

@@ -508,3 +527,3 @@ /** Return number of items in the dictionary. */

get(key: K): V | undefined {
return this.map.get(key.toString());
return this.map.get(key.toString())?.[1];
}

@@ -514,3 +533,3 @@

set(key: K, value: V) {
this.map.set(key.toString(), value);
this.map.set(key.toString(), [key, value]);
}

@@ -522,2 +541,9 @@

}
/** it allows to use HashDictionary in for-of loop */
*[Symbol.iterator]() {
for (const value of this.map.values()) {
yield value;
}
}
}

@@ -524,0 +550,0 @@

@@ -71,2 +71,17 @@ 'use strict';

}
/** Compare the sequence to another one lexicographically. */
isLessThan(other) {
const min = Math.min(this.length, other.length);
const thisRaw = this.raw;
const otherRaw = other.raw;
for (let i = 0; i < min; i++) {
if (thisRaw[i] < otherRaw[i]) {
return true;
}
if (thisRaw[i] > otherRaw[i]) {
return false;
}
}
return this.length < other.length;
}
/** Create a new [`BytesBlob'] by converting given UTF-u encoded string into bytes. */

@@ -479,7 +494,7 @@ static blobFromString(v) {

get(key) {
return this.map.get(key.toString());
return this.map.get(key.toString())?.[1];
}
/** Insert/overwrite the value at given key. */
set(key, value) {
this.map.set(key.toString(), value);
this.map.set(key.toString(), [key, value]);
}

@@ -490,2 +505,8 @@ /** Remove the key and any value from the dictionary. */

}
/** it allows to use HashDictionary in for-of loop */
*[Symbol.iterator]() {
for (const value of this.map.values()) {
yield value;
}
}
}

@@ -492,0 +513,0 @@

2

package.json
{
"name": "@typeberry/trie",
"version": "0.0.1-6053b62",
"version": "0.0.1-67e835b",
"main": "index.js",

@@ -5,0 +5,0 @@ "author": "Fluffy Labs",

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