New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

peerjs-js-binarypack

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

peerjs-js-binarypack - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0-rc.1

__test__/blobs.spec.ts

4

__test__/bugs.spec.ts

@@ -13,4 +13,4 @@ import { expect, describe, it } from "@jest/globals";

it("gives back wrong value on INT64_MAX ", async () => {
expect(await packAndUnpack(0x7fffffffffffffff)).toBe(
-9223372036854776000,
expect(await packAndUnpack(0x7fffffffffffffff)).not.toEqual(
0x7fffffffffffffff,
);

@@ -17,0 +17,0 @@ });

@@ -27,3 +27,3 @@ import { expect, describe, it } from "@jest/globals";

];
expect.assertions(values.length);
// expect.assertions(values.length);
for (const v of values) {

@@ -30,0 +30,0 @@ expect(await packAndUnpack(v)).toEqual(v);

import { expect, describe, it } from "@jest/globals";
import commit_data from "./data.json";
import commit_data from "./data";
import { packAndUnpack } from "./util";

@@ -9,3 +9,3 @@

const values = commit_data;
expect.assertions(values.length);
// expect.assertions(values.length);
for (const v of values) {

@@ -27,3 +27,3 @@ expect(await packAndUnpack(v)).toEqual(v);

const values = [[], Array(0xffff).fill(0)];
expect.assertions(values.length);
// expect.assertions(values.length);
for (const v of values) {

@@ -56,3 +56,3 @@ expect(await packAndUnpack(v)).toEqual(v);

];
expect.assertions(values.length);
// expect.assertions(values.length);
for (const v of values) {

@@ -77,3 +77,3 @@ expect(new Uint8Array(await packAndUnpack<ArrayBuffer>(v))).toEqual(v);

];
expect.assertions(values.length);
// expect.assertions(values.length);
for (const v of values) {

@@ -95,3 +95,3 @@ expect(new Int32Array(await packAndUnpack<ArrayBuffer>(v))).toEqual(v);

];
expect.assertions(values.length);
// expect.assertions(values.length);
for (const v of values) {

@@ -104,3 +104,3 @@ expect(await packAndUnpack<ArrayBuffer>(v)).toEqual(v);

const values = [new Date(), new Date(Date.UTC(1, 1, 1, 1, 1, 1, 1))];
expect.assertions(values.length);
// expect.assertions(values.length);
for (const v of values) {

@@ -107,0 +107,0 @@ expect(await packAndUnpack(v)).toEqual(v.toString());

@@ -15,3 +15,3 @@ import { expect, describe, it } from "@jest/globals";

];
expect.assertions(values.length);
// expect.assertions(values.length);
for (const v of values) {

@@ -18,0 +18,0 @@ expect(await packAndUnpack(v)).toEqual(v);

import { pack, Packable, unpack, Unpackable } from "../lib/binarypack";
export const packAndUnpack = async <T extends Unpackable>(data: Packable) => {
const encoded = pack(data);
const encoded = await pack(data);
return unpack<T>(encoded);
};
{
"standard.semistandard": true,
"standard.usePackageJson": true,
"standard.autoFixOnSave": true,
"javascript.validate.enable": false,
"eslint.autoFixOnSave": true
"editor.defaultFormatter": "biomejs.biome"
}

@@ -0,1 +1,19 @@

# [3.0.0-rc.1](https://github.com/peers/js-binarypack/compare/v2.0.0...v3.0.0-rc.1) (2023-12-01)
### Bug Fixes
* re-add Blob support ([12f0e75](https://github.com/peers/js-binarypack/commit/12f0e75ab8a7e699330e53541901dbe07be536b1))
### Features
* return `ArrayBuffer` instead of `Blob` ([689eafd](https://github.com/peers/js-binarypack/commit/689eafd471fccb7eae0d68528b764d691e9d96b2))
### BREAKING CHANGES
* Blobs require making the `pack` interface async
* Return type of `pack` is now `ArrayBuffer`
# [2.0.0](https://github.com/peers/js-binarypack/compare/v1.0.2...v2.0.0) (2023-06-22)

@@ -2,0 +20,0 @@

@@ -1,2 +0,2 @@

export type Packable = null | undefined | string | number | boolean | Date | ArrayBuffer | Array<Packable> | {
export type Packable = null | undefined | string | number | boolean | Date | ArrayBuffer | Blob | Array<Packable> | {
[key: string]: Packable;

@@ -10,6 +10,6 @@ } | ({

export function unpack<T extends Unpackable>(data: ArrayBuffer): T;
export function pack(data: Packable): ArrayBufferLike;
export function pack(data: Packable): Promise<ArrayBufferLike>;
export class Packer {
getBuffer(): ArrayBufferLike;
pack(value: Packable): void;
pack(value: Packable): Promise<void>;
pack_bin(blob: Uint8Array): void;

@@ -16,0 +16,0 @@ pack_string(str: string): void;

@@ -11,2 +11,3 @@ import { BufferBuilder } from "./bufferbuilder";

| ArrayBuffer
| Blob
| Array<Packable>

@@ -30,5 +31,5 @@ | { [key: string]: Packable }

export function pack(data: Packable) {
export async function pack(data: Packable) {
const packer = new Packer();
packer.pack(data);
await packer.pack(data);
return packer.getBuffer();

@@ -301,3 +302,3 @@ }

pack(value: Packable) {
async pack(value: Packable) {
if (typeof value === "string") {

@@ -333,2 +334,4 @@ this.pack_string(value);

this.pack_string(value.toString());
} else if (value instanceof Blob) {
this.pack_bin(new Uint8Array(await value.arrayBuffer()));
} else if (

@@ -335,0 +338,0 @@ constructor == Object ||

{
"name": "peerjs-js-binarypack",
"version": "2.0.0",
"version": "3.0.0-rc.1",
"description": "BinaryPack serialization",

@@ -26,5 +26,3 @@ "homepage": "https://github.com/peers/js-binarypack",

"build": "parcel build",
"test": "jest",
"coverage": "jest --coverage",
"format": "prettier --write .",
"format": "biome format --write .",
"lint": "eslint --ext .js,.ts .",

@@ -105,2 +103,4 @@ "check": "tsc --noEmit"

"devDependencies": {
"@biomejs/biome": "1.4.1",
"@jest/globals": "^29.7.0",
"@parcel/packager-ts": "^2.8.3",

@@ -110,13 +110,7 @@ "@parcel/transformer-typescript-types": "^2.8.3",

"@semantic-release/git": "^10.0.1",
"@swc/core": "^1.3.35",
"@swc/jest": "^0.2.24",
"@types/jest": "^29.4.0",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"eslint": "^8.34.0",
"jest": "^29.4.3",
"jest-environment-jsdom": "^29.4.3",
"parcel": "^2.8.3",
"prettier": "^2.8.4",
"semantic-release": "^20.1.0",
"typescript": "^4.9.5"
"typescript": "^5.0.0"
},

@@ -123,0 +117,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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