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

micro-packed

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

micro-packed - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

debugger.ts

13

index.ts

@@ -179,2 +179,3 @@ import { base64, bytes as baseBytes, hex as baseHex, str as baseStr, utf8 } from '@scure/base';

}
return;
}

@@ -674,2 +675,3 @@ finish() {

else if (def) inner.decodeStream(r);
return;
},

@@ -696,2 +698,3 @@ });

else if (def !== undefined) inner.decodeStream(r);
return;
},

@@ -705,3 +708,3 @@ });

size: inner.size,
encodeStream: (w: Writer, value: undefined) => inner.encodeStream(w, constant),
encodeStream: (w: Writer, _: undefined) => inner.encodeStream(w, constant),
decodeStream: (r: Reader): undefined => {

@@ -727,6 +730,6 @@ const value = inner.decodeStream(r);

return wrap({
encodeStream: (w: Writer, value: T) => {
encodeStream: (_: Writer, value: T) => {
if (value !== c) throw new Error(`constant: invalid value ${value} (exp: ${c})`);
},
decodeStream: (r: Reader): T => c,
decodeStream: (_: Reader): T => c,
});

@@ -738,3 +741,4 @@ }

for (let f of fields) {
if (!f.size) return;
if (f.size === undefined) return;
if (!Number.isSafeInteger(f.size)) throw new Error(`sizeof: wrong element size=${size}`);
size += f.size;

@@ -1107,2 +1111,3 @@ }

const log = (name: string, rw: Reader | Writer, value: any) => {
// @ts-ignore
console.log(`DEBUG/${name}(${rw.fieldPath.join('/')}):`, { type: typeof value, value });

@@ -1109,0 +1114,0 @@ return value;

{
"name": "micro-packed",
"version": "0.4.0",
"description": "Less painful binary encoding / decoding",
"version": "0.5.0",
"description": "Define complex binary structures using composable primitives.",
"files": [
"index.js",
"index.d.ts",
"index.d.ts.map",
"index.ts"
"lib/index.js",
"lib/debugger.js",
"lib/esm/index.js",
"lib/esm/debugger.js",
"lib/index.d.ts",
"lib/debugger.d.ts",
"lib/index.d.ts.map",
"lib/debugger.d.ts.map",
"index.ts",
"debugger.ts",
"lib/esm/package.json"
],
"type": "module",
"main": "index.js",
"module": "index.js",
"types": "index.d.ts",
"main": "lib/index.js",
"module": "lib/esm/index.js",
"types": "lib/index.d.ts",
"exports": {
".": {
"types": "./lib/index.d.ts",
"import": "./lib/esm/index.js",
"default": "./lib/index.js"
},
"./debugger": {
"types": "./lib/debugger.d.ts",
"import": "./lib/esm/debugger.js",
"default": "./lib/debugger.js"
}
},
"dependencies": {
"@scure/base": "~1.1.5"
},
"scripts": {
"build": "tsc",
"lint": "prettier --check index.ts",
"format": "prettier --write index.ts",
"test": "node test/index.js"
"build": "tsc && tsc -p tsconfig.esm.json",
"lint": "prettier --check index.ts debugger.ts",
"format": "prettier --write index.ts debugger.ts",
"test": "node test/index.js && node test/debugger.test.js"
},

@@ -28,5 +49,2 @@ "author": "Paul Miller (https://paulmillr.com)",

},
"dependencies": {
"@scure/base": "~1.1.3"
},
"devDependencies": {

@@ -46,8 +64,3 @@ "micro-should": "0.4.0",

],
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
]
"funding": "https://paulmillr.com/funding/"
}

@@ -5,6 +5,5 @@ # micro-packed

Allows declarative definition for complex structures (like in C/Rust) via composable primitives,
which enables encoding these structures into bytes and parsing back.
Define complex binary structures using composable primitives.
Comes with an separate [debugger package](./debugger/).
Comes with a friendly debugger.

@@ -34,5 +33,18 @@ ## Usage

field8: P.array(null, P.U64BE),
})
});
```
## Debugger
```ts
import * as PD from 'micro-packed/debugger';
PD.decode(<coder>, data);
PD.diff(<coder>, actual, expected);
```
![Decode](./test/screens/decode.png)
![Diff](./test/screens/diff.png)
## Utils

@@ -39,0 +51,0 @@

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