@matrixai/db
Advanced tools
Comparing version 4.0.2 to 4.0.4
@@ -282,4 +282,3 @@ "use strict"; | ||
if (options_.lt == null && options_.lte == null) { | ||
const levelKeyStart = utils.levelPathToKey(levelPath); | ||
const levelKeyEnd = Buffer.from(levelKeyStart); | ||
const levelKeyEnd = utils.levelPathToKey(levelPath); | ||
levelKeyEnd[levelKeyEnd.length - 1] += 1; | ||
@@ -286,0 +285,0 @@ options_.lt = levelKeyEnd; |
@@ -5,4 +5,3 @@ /// <reference types="node" /> | ||
* Separator is a single null byte | ||
* During iteration acquiring a sublevel requires iterating | ||
* between 0x00 and 0x01 | ||
* This special symbol must not appear in the encoded parts | ||
*/ | ||
@@ -12,2 +11,3 @@ declare const sep: Buffer; | ||
* Encode level or key part using base 128 encoding | ||
* Empty parts are encoded with the special empty symbol | ||
*/ | ||
@@ -17,2 +17,3 @@ declare function encodePart(part: Buffer): Buffer; | ||
* Decode level or key part from base 128 | ||
* The special empty symbol is decoded as an empty buffer | ||
*/ | ||
@@ -46,3 +47,3 @@ declare function decodePart(data: Buffer): Buffer; | ||
* levels => level:l levels:ls -> [l, ...ls] | '' -> [] | ||
* level => sep .*?:l (?<!escape) sep (?>.*) -> l | ||
* level => sep .*?:l sep -> l | ||
* sep => 0x00 | ||
@@ -49,0 +50,0 @@ * keyActual => .*:k -> [k] |
@@ -30,17 +30,25 @@ "use strict"; | ||
* Separator is a single null byte | ||
* During iteration acquiring a sublevel requires iterating | ||
* between 0x00 and 0x01 | ||
* This special symbol must not appear in the encoded parts | ||
*/ | ||
const sep = Buffer.from([0]); | ||
const sep = Buffer.from([0x00]); | ||
exports.sep = sep; | ||
/** | ||
* Empty parts will be encoded as a single 0x01 byte | ||
*/ | ||
const empty = Buffer.from([0x01]); | ||
/** | ||
* Lexicographically ordered base 128 alphabet | ||
* The alphabet starts at 0x02 (skipping 0x00 and 0x01) | ||
*/ | ||
const alphabet = Buffer.from(Array.from({ length: 128 }, (_, i) => { | ||
return i + 1; | ||
return i + 2; | ||
})); | ||
/** | ||
* Encode level or key part using base 128 encoding | ||
* Empty parts are encoded with the special empty symbol | ||
*/ | ||
function encodePart(part) { | ||
if (part.byteLength === 0) { | ||
return empty; | ||
} | ||
// Start encoding | ||
@@ -70,4 +78,8 @@ const mask = (1 << 7) - 1; | ||
* Decode level or key part from base 128 | ||
* The special empty symbol is decoded as an empty buffer | ||
*/ | ||
function decodePart(data) { | ||
if (data.equals(empty)) { | ||
return Buffer.allocUnsafe(0); | ||
} | ||
const codes = {}; | ||
@@ -154,3 +166,3 @@ for (let i = 0; i < alphabet.length; ++i) { | ||
* levels => level:l levels:ls -> [l, ...ls] | '' -> [] | ||
* level => sep .*?:l (?<!escape) sep (?>.*) -> l | ||
* level => sep .*?:l sep -> l | ||
* sep => 0x00 | ||
@@ -157,0 +169,0 @@ * keyActual => .*:k -> [k] |
{ | ||
"name": "@matrixai/db", | ||
"version": "4.0.2", | ||
"version": "4.0.4", | ||
"author": "Roger Qiu", | ||
@@ -5,0 +5,0 @@ "description": "DB", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111075
1668
1