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

protons-runtime

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protons-runtime - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

dist/src/utils/alloc.d.ts

6

dist/src/codecs/bytes.js
import { Uint8ArrayList } from 'uint8arraylist';
import { unsigned } from '../utils/varint.js';
import { unsigned } from 'uint8-varint';
import { createCodec, CODEC_TYPES } from '../codec.js';

@@ -9,5 +9,3 @@ const encodingLength = function bytesEncodingLength(val) {

const encode = function bytesEncode(val) {
const prefix = new Uint8Array(unsigned.encodingLength(val.byteLength));
unsigned.encode(val.byteLength, prefix);
return new Uint8ArrayList(prefix, val);
return new Uint8ArrayList(unsigned.encode(val.byteLength), val);
};

@@ -14,0 +12,0 @@ const decode = function bytesDecode(buf, offset) {

@@ -1,3 +0,4 @@

import { unsigned } from '../utils/varint.js';
import { unsigned } from 'uint8-varint';
import { createCodec, CODEC_TYPES } from '../codec.js';
import { allocUnsafe } from '../utils/alloc.js';
export function enumeration(v) {

@@ -18,3 +19,3 @@ function findValue(val) {

const enumValue = findValue(val);
const buf = new Uint8Array(unsigned.encodingLength(enumValue));
const buf = allocUnsafe(unsigned.encodingLength(enumValue));
unsigned.encode(enumValue, buf);

@@ -21,0 +22,0 @@ return buf;

@@ -1,4 +0,7 @@

import { signed } from '../utils/varint.js';
import { signed } from 'uint8-varint';
import { createCodec, CODEC_TYPES } from '../codec.js';
const encodingLength = function int32EncodingLength(val) {
if (val < 0) {
return 10; // 10 bytes per spec - https://developers.google.com/protocol-buffers/docs/encoding#signed-ints
}
return signed.encodingLength(val);

@@ -8,9 +11,8 @@ };

const buf = new Uint8Array(encodingLength(val));
signed.encode(val, buf);
return buf;
return signed.encode(val, buf);
};
const decode = function int32Decode(buf, offset) {
return signed.decode(buf, offset);
return signed.decode(buf, offset) | 0;
};
export const int32 = createCodec('int32', CODEC_TYPES.VARINT, encode, decode, encodingLength);
//# sourceMappingURL=int32.js.map

@@ -1,4 +0,7 @@

import { signed } from '../utils/big-varint.js';
import { signed } from 'uint8-varint/big';
import { createCodec, CODEC_TYPES } from '../codec.js';
const encodingLength = function int64EncodingLength(val) {
if (val < 0n) {
return 10; // 10 bytes per spec - https://developers.google.com/protocol-buffers/docs/encoding#signed-ints
}
return signed.encodingLength(val);

@@ -8,4 +11,3 @@ };

const buf = new Uint8Array(encodingLength(val));
signed.encode(val, buf);
return buf;
return signed.encode(val, buf);
};

@@ -12,0 +14,0 @@ const decode = function int64Decode(buf, offset) {

@@ -1,4 +0,5 @@

import { unsigned } from '../utils/varint.js';
import { unsigned } from 'uint8-varint';
import { createCodec, CODEC_TYPES } from '../codec.js';
import { Uint8ArrayList } from 'uint8arraylist';
import { allocUnsafe } from '../utils/alloc.js';
export function message(fieldDefs) {

@@ -22,3 +23,3 @@ const encodingLength = function messageEncodingLength(val) {

const key = (fieldNumber << 3) | fieldDef.codec.type;
const prefix = new Uint8Array(unsigned.encodingLength(key));
const prefix = allocUnsafe(unsigned.encodingLength(key));
unsigned.encode(key, prefix);

@@ -43,4 +44,3 @@ const encoded = fieldDef.codec.encode(value);

}
const prefix = new Uint8Array(unsigned.encodingLength(bytes.length));
unsigned.encode(bytes.length, prefix);
const prefix = unsigned.encode(bytes.length);
return new Uint8ArrayList(prefix, bytes);

@@ -47,0 +47,0 @@ };

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

import { zigzag } from '../utils/varint.js';
import { zigzag } from 'uint8-varint';
import { createCodec, CODEC_TYPES } from '../codec.js';

@@ -7,5 +7,3 @@ const encodingLength = function sint32EncodingLength(val) {

const encode = function svarintEncode(val) {
const buf = new Uint8Array(encodingLength(val));
zigzag.encode(val, buf);
return buf;
return zigzag.encode(val);
};

@@ -12,0 +10,0 @@ const decode = function svarintDecode(buf, offset) {

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

import { zigzag } from '../utils/big-varint.js';
import { zigzag } from 'uint8-varint/big';
import { createCodec, CODEC_TYPES } from '../codec.js';

@@ -7,5 +7,3 @@ const encodingLength = function int64EncodingLength(val) {

const encode = function int64Encode(val) {
const buf = new Uint8Array(encodingLength(val));
zigzag.encode(val, buf);
return buf;
return zigzag.encode(val);
};

@@ -12,0 +10,0 @@ const decode = function int64Decode(buf, offset) {

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

import { unsigned } from '../utils/varint.js';
import { unsigned } from 'uint8-varint';
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';

@@ -12,5 +12,3 @@ import { toString as uint8ArrayToString } from 'uint8arrays/to-string';

const asBuf = uint8ArrayFromString(val);
const prefix = new Uint8Array(unsigned.encodingLength(asBuf.byteLength));
unsigned.encode(asBuf.length, prefix);
return new Uint8ArrayList(prefix, asBuf);
return new Uint8ArrayList(unsigned.encode(asBuf.byteLength), asBuf);
};

@@ -17,0 +15,0 @@ const decode = function stringDecode(buf, offset) {

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

import { unsigned } from '../utils/varint.js';
import { unsigned } from 'uint8-varint';
import { createCodec, CODEC_TYPES } from '../codec.js';

@@ -8,5 +8,3 @@ const encodingLength = function uint32EncodingLength(val) {

// val = val < 0 ? val + 4294967296 : val
const buf = new Uint8Array(encodingLength(val));
unsigned.encode(val, buf);
return buf;
return unsigned.encode(val);
};

@@ -13,0 +11,0 @@ const decode = function uint32Decode(buf, offset) {

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

import { unsigned } from '../utils/big-varint.js';
import { unsigned } from 'uint8-varint/big';
import { createCodec, CODEC_TYPES } from '../codec.js';

@@ -7,5 +7,3 @@ const encodingLength = function uint64EncodingLength(val) {

const encode = function uint64Encode(val) {
const buf = new Uint8Array(unsigned.encodingLength(val));
unsigned.encode(val, buf);
return buf;
return unsigned.encode(val);
};

@@ -12,0 +10,0 @@ const decode = function uint64Decode(buf, offset) {

import { Uint8ArrayList } from 'uint8arraylist';
import { unsigned } from './utils/varint.js';
import { unsigned } from 'uint8-varint';
import { allocUnsafe } from './utils/alloc.js';
export function decodeMessage(buf, codec) {
// wrap root message
const prefix = new Uint8Array(unsigned.encodingLength(buf.byteLength));
const prefix = allocUnsafe(unsigned.encodingLength(buf.byteLength));
unsigned.encode(buf.byteLength, prefix);

@@ -7,0 +8,0 @@ return codec.decode(new Uint8ArrayList(prefix, buf), 0);

import { Uint8ArrayList } from 'uint8arraylist';
import { unsigned } from './utils/varint.js';
import { unsigned } from 'uint8-varint';
export function encodeMessage(message, codec) {

@@ -4,0 +4,0 @@ // unwrap root message

{
"name": "protons-runtime",
"version": "2.0.1",
"version": "2.0.2",
"description": "Shared code to make your bundle smaller when running protons in your app",

@@ -144,2 +144,3 @@ "license": "Apache-2.0 OR MIT",

"scripts": {
"clean": "aegir clean",
"lint": "aegir lint",

@@ -151,2 +152,5 @@ "dep-check": "aegir dep-check",

"dependencies": {
"byte-access": "^1.0.1",
"longbits": "^1.1.0",
"uint8-varint": "^1.0.2",
"uint8arraylist": "^2.0.0",

@@ -153,0 +157,0 @@ "uint8arrays": "^3.0.0"

import { Uint8ArrayList } from 'uint8arraylist'
import { unsigned } from '../utils/varint.js'
import { unsigned } from 'uint8-varint'
import { createCodec, CODEC_TYPES } from '../codec.js'

@@ -13,7 +13,6 @@ import type { DecodeFunction, EncodeFunction, EncodingLengthFunction } from '../codec.js'

const encode: EncodeFunction<Uint8Array> = function bytesEncode (val) {
const prefix = new Uint8Array(unsigned.encodingLength(val.byteLength))
unsigned.encode(val.byteLength, prefix)
return new Uint8ArrayList(prefix, val)
return new Uint8ArrayList(
unsigned.encode(val.byteLength),
val
)
}

@@ -20,0 +19,0 @@

import { unsigned } from '../utils/varint.js'
import { unsigned } from 'uint8-varint'
import { createCodec, CODEC_TYPES } from '../codec.js'
import type { DecodeFunction, EncodeFunction, EncodingLengthFunction, Codec } from '../codec.js'
import { allocUnsafe } from '../utils/alloc.js'

@@ -26,3 +27,3 @@ export function enumeration <T> (v: any): Codec<T> {

const buf = new Uint8Array(unsigned.encodingLength(enumValue))
const buf = allocUnsafe(unsigned.encodingLength(enumValue))
unsigned.encode(enumValue, buf)

@@ -29,0 +30,0 @@

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

import { signed } from '../utils/varint.js'
import { signed } from 'uint8-varint'
import { createCodec, CODEC_TYPES } from '../codec.js'

@@ -6,2 +6,6 @@ import type { DecodeFunction, EncodeFunction, EncodingLengthFunction } from '../codec.js'

const encodingLength: EncodingLengthFunction<number> = function int32EncodingLength (val) {
if (val < 0) {
return 10 // 10 bytes per spec - https://developers.google.com/protocol-buffers/docs/encoding#signed-ints
}
return signed.encodingLength(val)

@@ -12,11 +16,10 @@ }

const buf = new Uint8Array(encodingLength(val))
signed.encode(val, buf)
return buf
return signed.encode(val, buf)
}
const decode: DecodeFunction<number> = function int32Decode (buf, offset) {
return signed.decode(buf, offset)
return signed.decode(buf, offset) | 0
}
export const int32 = createCodec('int32', CODEC_TYPES.VARINT, encode, decode, encodingLength)

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

import { signed } from '../utils/big-varint.js'
import { signed } from 'uint8-varint/big'
import { createCodec, CODEC_TYPES } from '../codec.js'

@@ -6,2 +6,6 @@ import type { DecodeFunction, EncodeFunction, EncodingLengthFunction } from '../codec.js'

const encodingLength: EncodingLengthFunction<bigint> = function int64EncodingLength (val) {
if (val < 0n) {
return 10 // 10 bytes per spec - https://developers.google.com/protocol-buffers/docs/encoding#signed-ints
}
return signed.encodingLength(val)

@@ -12,5 +16,4 @@ }

const buf = new Uint8Array(encodingLength(val))
signed.encode(val, buf)
return buf
return signed.encode(val, buf)
}

@@ -17,0 +20,0 @@

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

import { unsigned } from '../utils/varint.js'
import { unsigned } from 'uint8-varint'
import { createCodec, CODEC_TYPES } from '../codec.js'

@@ -6,2 +6,3 @@ import type { DecodeFunction, EncodeFunction, EncodingLengthFunction, Codec } from '../codec.js'

import type { FieldDefs, FieldDef } from '../index.js'
import { allocUnsafe } from '../utils/alloc.js'

@@ -36,3 +37,3 @@ export interface Factory<A, T> {

const key = (fieldNumber << 3) | fieldDef.codec.type
const prefix = new Uint8Array(unsigned.encodingLength(key))
const prefix = allocUnsafe(unsigned.encodingLength(key))
unsigned.encode(key, prefix)

@@ -61,4 +62,3 @@ const encoded = fieldDef.codec.encode(value)

const prefix = new Uint8Array(unsigned.encodingLength(bytes.length))
unsigned.encode(bytes.length, prefix)
const prefix = unsigned.encode(bytes.length)

@@ -65,0 +65,0 @@ return new Uint8ArrayList(prefix, bytes)

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

import { zigzag } from '../utils/varint.js'
import { zigzag } from 'uint8-varint'
import { createCodec, CODEC_TYPES } from '../codec.js'

@@ -10,7 +10,3 @@ import type { DecodeFunction, EncodeFunction, EncodingLengthFunction } from '../codec.js'

const encode: EncodeFunction<number> = function svarintEncode (val) {
const buf = new Uint8Array(encodingLength(val))
zigzag.encode(val, buf)
return buf
return zigzag.encode(val)
}

@@ -17,0 +13,0 @@

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

import { zigzag } from '../utils/big-varint.js'
import { zigzag } from 'uint8-varint/big'
import { createCodec, CODEC_TYPES } from '../codec.js'

@@ -10,6 +10,3 @@ import type { DecodeFunction, EncodeFunction, EncodingLengthFunction } from '../codec.js'

const encode: EncodeFunction<bigint> = function int64Encode (val) {
const buf = new Uint8Array(encodingLength(val))
zigzag.encode(val, buf)
return buf
return zigzag.encode(val)
}

@@ -16,0 +13,0 @@

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

import { unsigned } from '../utils/varint.js'
import { unsigned } from 'uint8-varint'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'

@@ -15,7 +15,7 @@ import { toString as uint8ArrayToString } from 'uint8arrays/to-string'

const asBuf = uint8ArrayFromString(val)
const prefix = new Uint8Array(unsigned.encodingLength(asBuf.byteLength))
unsigned.encode(asBuf.length, prefix)
return new Uint8ArrayList(prefix, asBuf)
return new Uint8ArrayList(
unsigned.encode(asBuf.byteLength),
asBuf
)
}

@@ -22,0 +22,0 @@

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

import { unsigned } from '../utils/varint.js'
import { unsigned } from 'uint8-varint'
import { createCodec, CODEC_TYPES } from '../codec.js'

@@ -12,7 +12,3 @@ import type { DecodeFunction, EncodeFunction, EncodingLengthFunction } from '../codec.js'

const buf = new Uint8Array(encodingLength(val))
unsigned.encode(val, buf)
return buf
return unsigned.encode(val)
}

@@ -19,0 +15,0 @@

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

import { unsigned } from '../utils/big-varint.js'
import { unsigned } from 'uint8-varint/big'
import { createCodec, CODEC_TYPES } from '../codec.js'

@@ -10,7 +10,3 @@ import type { DecodeFunction, EncodeFunction, EncodingLengthFunction } from '../codec.js'

const encode: EncodeFunction<bigint> = function uint64Encode (val) {
const buf = new Uint8Array(unsigned.encodingLength(val))
unsigned.encode(val, buf)
return buf
return unsigned.encode(val)
}

@@ -17,0 +13,0 @@

import { Uint8ArrayList } from 'uint8arraylist'
import { unsigned } from './utils/varint.js'
import { unsigned } from 'uint8-varint'
import type { Codec } from './codec.js'
import { allocUnsafe } from './utils/alloc.js'
export function decodeMessage <T> (buf: Uint8Array | Uint8ArrayList, codec: Codec<T>): T {
// wrap root message
const prefix = new Uint8Array(unsigned.encodingLength(buf.byteLength))
const prefix = allocUnsafe(unsigned.encodingLength(buf.byteLength))
unsigned.encode(buf.byteLength, prefix)

@@ -9,0 +10,0 @@

import { Uint8ArrayList } from 'uint8arraylist'
import type { Codec } from './codec.js'
import { unsigned } from './utils/varint.js'
import { unsigned } from 'uint8-varint'

@@ -5,0 +5,0 @@ export function encodeMessage <T> (message: T, codec: Codec<T>): Uint8ArrayList {

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

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

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