🚀 Socket Launch Week Day 4:Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection.Learn more
Sign In

bleb

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bleb - npm Package Compare versions

Comparing version
0.1.0-cb88776
to
0.1.0-ee2545a
+24
-0
index.d.ts

@@ -10,4 +10,28 @@ /**

export declare function fromBigInt(integer: bigint): number[];
/**
* @example Basic Usage
* ```ts
* import * as Bleb from "bleb"
*
* console.log(Bleb.toBigInt([ 232, 6 ])) // 1000n
* ```
*
* @example Less-Basic Usage
* ```ts
* import * as Bleb from "bleb"
*
* // some data with bleb at byte offset 2
* const u8View = new Uint8Array([ 177, 218, 232, 6, 197, 165, 75, 177 ])
* const index = { $: 2 }
*
* console.log(Bleb.toBigInt(u8View, index)) // 1000n
* console.log(index) // { $: 4 }
* ```
*/
export declare function toBigInt(data: Record<number, number>, index?: {
$: number;
}): bigint;
export declare function from(integer: number): number[];
export declare function to(data: Record<number, number>, index?: {
$: number;
}): number;
+22
-1

@@ -23,2 +23,23 @@ import { assert } from "@samual/lib/assert"

}
export { fromBigInt, toBigInt }
function from(integer) {
const result = []
for (; integer >= 0; ) {
let value = 127 & integer
integer = Math.floor(integer / 128)
integer-- && (value |= 128)
result.push(value)
}
return result
}
function to(data, index = { $: 0 }) {
let result = 0,
offset = 0
for (;;) {
const byte = data[index.$++]
assert(null != byte, "src/index.ts:90:29")
result += ((127 & byte) + (offset && 1)) * 2 ** offset
offset += 7
if (!(128 & byte)) return result
}
}
export { from, fromBigInt, to, toBigInt }
+1
-1
{
"name": "bleb",
"version": "0.1.0-cb88776",
"version": "0.1.0-ee2545a",
"description": "Better LEB128",

@@ -5,0 +5,0 @@ "repository": "github:samualtnorman/bleb",