🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
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-60dc504
to
0.1.0-6e3403a
+8
-0
index.d.ts

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

/**
* @example Basic Usage
* ```ts
* import * as Bleb from "bleb"
*
* console.log(Bleb.fromBigInt(1000n)) // [ 232, 6 ]
* ```
*/
export declare function fromBigInt(integer: bigint): number[];

@@ -2,0 +10,0 @@ export declare function toBigInt(data: Record<number, number>, index?: {

+2
-2
import { assert } from "@samual/lib/assert"
function fromBigInt(integer) {
const result = []
for (; integer >= 0; ) {
for (; integer >= 0n; ) {
let value = Number(0x7fn & integer)

@@ -17,3 +17,3 @@ integer >>= 7n

const byte = data[index.$++]
assert(null != byte, "src/index.ts:28:29")
assert(null != byte, "src/index.ts:55:29")
result += ((0x7fn & BigInt(byte)) + (offset && 1n)) << offset

@@ -20,0 +20,0 @@ offset += 7n

{
"name": "bleb",
"version": "0.1.0-60dc504",
"version": "0.1.0-6e3403a",
"description": "Better LEB128",

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

@@ -12,1 +12,29 @@ # Better LEB128

| ... |
## Encoding
### Basic Usage
```js
import * as Bleb from "bleb"
console.log(Bleb.fromBigInt(1000n)) // [ 232, 6 ]
```
## Decoding
### Basic Usage
```js
import * as Bleb from "bleb"
console.log(Bleb.toBigInt([ 232, 6 ])) // 1000n
```
### Less-Basic Usage
```js
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 }
```