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

@solana/codecs-numbers

Package Overview
Dependencies
Maintainers
14
Versions
1183
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/codecs-numbers - npm Package Compare versions

Comparing version 2.0.0-experimental.ab12c29 to 2.0.0-experimental.aef0571

110

dist/index.browser.js

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

import { combineCodec, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';
import { combineCodec, createEncoder, createDecoder, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';

@@ -18,21 +18,9 @@ // src/assertions.ts

})(Endian || {});
function sharedNumberFactory(input) {
let littleEndian;
let defaultDescription = input.name;
if (input.size > 1) {
littleEndian = !("endian" in input.config) || input.config.endian === 0 /* LITTLE */;
defaultDescription += littleEndian ? "(le)" : "(be)";
}
return {
description: input.config.description ?? defaultDescription,
fixedSize: input.size,
littleEndian,
maxSize: input.size
};
function isLittleEndian(config) {
return config?.endian === 1 /* BIG */ ? false : true;
}
function numberEncoderFactory(input) {
const codecData = sharedNumberFactory(input);
return {
description: codecData.description,
encode(value) {
return createEncoder({
fixedSize: input.size,
write(value, bytes, offset) {
if (input.range) {

@@ -42,22 +30,18 @@ assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);

const arrayBuffer = new ArrayBuffer(input.size);
input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
return new Uint8Array(arrayBuffer);
},
fixedSize: codecData.fixedSize,
maxSize: codecData.maxSize
};
input.set(new DataView(arrayBuffer), value, isLittleEndian(input.config));
bytes.set(new Uint8Array(arrayBuffer), offset);
return offset + input.size;
}
});
}
function numberDecoderFactory(input) {
const codecData = sharedNumberFactory(input);
return {
decode(bytes, offset = 0) {
assertByteArrayIsNotEmptyForCodec(codecData.description, bytes, offset);
assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes, offset);
return createDecoder({
fixedSize: input.size,
read(bytes, offset = 0) {
assertByteArrayIsNotEmptyForCodec(input.name, bytes, offset);
assertByteArrayHasEnoughBytesForCodec(input.name, input.size, bytes, offset);
const view = new DataView(toArrayBuffer(bytes, offset, input.size));
return [input.get(view, codecData.littleEndian), offset + input.size];
},
description: codecData.description,
fixedSize: codecData.fixedSize,
maxSize: codecData.maxSize
};
return [input.get(view, isLittleEndian(input.config)), offset + input.size];
}
});
}

@@ -165,4 +149,3 @@ function toArrayBuffer(bytes, offset, length) {

var getI64Codec = (config = {}) => combineCodec(getI64Encoder(config), getI64Decoder(config));
var getI8Encoder = (config = {}) => numberEncoderFactory({
config,
var getI8Encoder = () => numberEncoderFactory({
name: "i8",

@@ -173,4 +156,3 @@ range: [-Number("0x7f") - 1, Number("0x7f")],

});
var getI8Decoder = (config = {}) => numberDecoderFactory({
config,
var getI8Decoder = () => numberDecoderFactory({
get: (view) => view.getInt8(0),

@@ -180,8 +162,15 @@ name: "i8",

});
var getI8Codec = (config = {}) => combineCodec(getI8Encoder(config), getI8Decoder(config));
var getShortU16Encoder = (config = {}) => ({
description: config.description ?? "shortU16",
encode: (value) => {
var getI8Codec = () => combineCodec(getI8Encoder(), getI8Decoder());
var getShortU16Encoder = () => createEncoder({
getSizeFromValue: (value) => {
if (value <= 127)
return 1;
if (value <= 16383)
return 2;
return 3;
},
maxSize: 3,
write: (value, bytes, offset) => {
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
const bytes = [0];
const shortU16Bytes = [0];
for (let ii = 0; ; ii += 1) {

@@ -193,14 +182,14 @@ const alignedValue = value >> ii * 7;

const nextSevenBits = 127 & alignedValue;
bytes[ii] = nextSevenBits;
shortU16Bytes[ii] = nextSevenBits;
if (ii > 0) {
bytes[ii - 1] |= 128;
shortU16Bytes[ii - 1] |= 128;
}
}
return new Uint8Array(bytes);
},
fixedSize: null,
maxSize: 3
bytes.set(shortU16Bytes, offset);
return offset + shortU16Bytes.length;
}
});
var getShortU16Decoder = (config = {}) => ({
decode: (bytes, offset = 0) => {
var getShortU16Decoder = () => createDecoder({
maxSize: 3,
read: (bytes, offset) => {
let value = 0;

@@ -218,8 +207,5 @@ let byteCount = 0;

return [value, offset + byteCount];
},
description: config.description ?? "shortU16",
fixedSize: null,
maxSize: 3
}
});
var getShortU16Codec = (config = {}) => combineCodec(getShortU16Encoder(config), getShortU16Decoder(config));
var getShortU16Codec = () => combineCodec(getShortU16Encoder(), getShortU16Decoder());
var getU128Encoder = (config = {}) => numberEncoderFactory({

@@ -293,4 +279,3 @@ config,

var getU64Codec = (config = {}) => combineCodec(getU64Encoder(config), getU64Decoder(config));
var getU8Encoder = (config = {}) => numberEncoderFactory({
config,
var getU8Encoder = () => numberEncoderFactory({
name: "u8",

@@ -301,4 +286,3 @@ range: [0, Number("0xff")],

});
var getU8Decoder = (config = {}) => numberDecoderFactory({
config,
var getU8Decoder = () => numberDecoderFactory({
get: (view) => view.getUint8(0),

@@ -308,6 +292,4 @@ name: "u8",

});
var getU8Codec = (config = {}) => combineCodec(getU8Encoder(config), getU8Decoder(config));
var getU8Codec = () => combineCodec(getU8Encoder(), getU8Decoder());
export { Endian, assertNumberIsBetweenForCodec, getF32Codec, getF32Decoder, getF32Encoder, getF64Codec, getF64Decoder, getF64Encoder, getI128Codec, getI128Decoder, getI128Encoder, getI16Codec, getI16Decoder, getI16Encoder, getI32Codec, getI32Decoder, getI32Encoder, getI64Codec, getI64Decoder, getI64Encoder, getI8Codec, getI8Decoder, getI8Encoder, getShortU16Codec, getShortU16Decoder, getShortU16Encoder, getU128Codec, getU128Decoder, getU128Encoder, getU16Codec, getU16Decoder, getU16Encoder, getU32Codec, getU32Decoder, getU32Encoder, getU64Codec, getU64Decoder, getU64Encoder, getU8Codec, getU8Decoder, getU8Encoder };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.browser.js.map

@@ -33,4 +33,29 @@ this.globalThis = this.globalThis || {};

}
function combineCodec(encoder, decoder, description) {
if (encoder.fixedSize !== decoder.fixedSize) {
function getEncodedSize(value, encoder) {
return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value);
}
function createEncoder(encoder) {
return Object.freeze({
...encoder,
encode: (value) => {
const bytes = new Uint8Array(getEncodedSize(value, encoder));
encoder.write(value, bytes, 0);
return bytes;
}
});
}
function createDecoder(decoder) {
return Object.freeze({
...decoder,
decode: (bytes, offset = 0) => decoder.read(bytes, offset)[0]
});
}
function isFixedSize(codec) {
return "fixedSize" in codec && typeof codec.fixedSize === "number";
}
function combineCodec(encoder, decoder) {
if (isFixedSize(encoder) !== isFixedSize(decoder)) {
throw new Error(`Encoder and decoder must either both be fixed-size or variable-size.`);
}
if (isFixedSize(encoder) && isFixedSize(decoder) && encoder.fixedSize !== decoder.fixedSize) {
throw new Error(

@@ -40,3 +65,3 @@ `Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`

}
if (encoder.maxSize !== decoder.maxSize) {
if (!isFixedSize(encoder) && !isFixedSize(decoder) && encoder.maxSize !== decoder.maxSize) {
throw new Error(

@@ -46,13 +71,9 @@ `Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`

}
if (description === void 0 && encoder.description !== decoder.description) {
throw new Error(
`Encoder and decoder must have the same description, got [${encoder.description}] and [${decoder.description}]. Pass a custom description as a third argument if you want to override the description and bypass this error.`
);
}
return {
...decoder,
...encoder,
decode: decoder.decode,
description: description != null ? description : encoder.description,
encode: encoder.encode,
fixedSize: encoder.fixedSize,
maxSize: encoder.maxSize
read: decoder.read,
write: encoder.write
};

@@ -62,22 +83,9 @@ }

// src/utils.ts
function sharedNumberFactory(input) {
var _a;
let littleEndian;
let defaultDescription = input.name;
if (input.size > 1) {
littleEndian = !("endian" in input.config) || input.config.endian === 0 /* LITTLE */;
defaultDescription += littleEndian ? "(le)" : "(be)";
}
return {
description: (_a = input.config.description) != null ? _a : defaultDescription,
fixedSize: input.size,
littleEndian,
maxSize: input.size
};
function isLittleEndian(config) {
return (config == null ? void 0 : config.endian) === 1 /* BIG */ ? false : true;
}
function numberEncoderFactory(input) {
const codecData = sharedNumberFactory(input);
return {
description: codecData.description,
encode(value) {
return createEncoder({
fixedSize: input.size,
write(value, bytes, offset) {
if (input.range) {

@@ -87,22 +95,18 @@ assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);

const arrayBuffer = new ArrayBuffer(input.size);
input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
return new Uint8Array(arrayBuffer);
},
fixedSize: codecData.fixedSize,
maxSize: codecData.maxSize
};
input.set(new DataView(arrayBuffer), value, isLittleEndian(input.config));
bytes.set(new Uint8Array(arrayBuffer), offset);
return offset + input.size;
}
});
}
function numberDecoderFactory(input) {
const codecData = sharedNumberFactory(input);
return {
decode(bytes, offset = 0) {
assertByteArrayIsNotEmptyForCodec(codecData.description, bytes, offset);
assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes, offset);
return createDecoder({
fixedSize: input.size,
read(bytes, offset = 0) {
assertByteArrayIsNotEmptyForCodec(input.name, bytes, offset);
assertByteArrayHasEnoughBytesForCodec(input.name, input.size, bytes, offset);
const view = new DataView(toArrayBuffer(bytes, offset, input.size));
return [input.get(view, codecData.littleEndian), offset + input.size];
},
description: codecData.description,
fixedSize: codecData.fixedSize,
maxSize: codecData.maxSize
};
return [input.get(view, isLittleEndian(input.config)), offset + input.size];
}
});
}

@@ -222,4 +226,3 @@ function toArrayBuffer(bytes, offset, length) {

// src/i8.ts
var getI8Encoder = (config = {}) => numberEncoderFactory({
config,
var getI8Encoder = () => numberEncoderFactory({
name: "i8",

@@ -230,4 +233,3 @@ range: [-Number("0x7f") - 1, Number("0x7f")],

});
var getI8Decoder = (config = {}) => numberDecoderFactory({
config,
var getI8Decoder = () => numberDecoderFactory({
get: (view) => view.getInt8(0),

@@ -237,52 +239,50 @@ name: "i8",

});
var getI8Codec = (config = {}) => combineCodec(getI8Encoder(config), getI8Decoder(config));
var getI8Codec = () => combineCodec(getI8Encoder(), getI8Decoder());
// src/short-u16.ts
var getShortU16Encoder = (config = {}) => {
var _a;
return {
description: (_a = config.description) != null ? _a : "shortU16",
encode: (value) => {
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
const bytes = [0];
for (let ii = 0; ; ii += 1) {
const alignedValue = value >> ii * 7;
if (alignedValue === 0) {
break;
}
const nextSevenBits = 127 & alignedValue;
bytes[ii] = nextSevenBits;
if (ii > 0) {
bytes[ii - 1] |= 128;
}
var getShortU16Encoder = () => createEncoder({
getSizeFromValue: (value) => {
if (value <= 127)
return 1;
if (value <= 16383)
return 2;
return 3;
},
maxSize: 3,
write: (value, bytes, offset) => {
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
const shortU16Bytes = [0];
for (let ii = 0; ; ii += 1) {
const alignedValue = value >> ii * 7;
if (alignedValue === 0) {
break;
}
return new Uint8Array(bytes);
},
fixedSize: null,
maxSize: 3
};
};
var getShortU16Decoder = (config = {}) => {
var _a;
return {
decode: (bytes, offset = 0) => {
let value = 0;
let byteCount = 0;
while (++byteCount) {
const byteIndex = byteCount - 1;
const currentByte = bytes[offset + byteIndex];
const nextSevenBits = 127 & currentByte;
value |= nextSevenBits << byteIndex * 7;
if ((currentByte & 128) === 0) {
break;
}
const nextSevenBits = 127 & alignedValue;
shortU16Bytes[ii] = nextSevenBits;
if (ii > 0) {
shortU16Bytes[ii - 1] |= 128;
}
return [value, offset + byteCount];
},
description: (_a = config.description) != null ? _a : "shortU16",
fixedSize: null,
maxSize: 3
};
};
var getShortU16Codec = (config = {}) => combineCodec(getShortU16Encoder(config), getShortU16Decoder(config));
}
bytes.set(shortU16Bytes, offset);
return offset + shortU16Bytes.length;
}
});
var getShortU16Decoder = () => createDecoder({
maxSize: 3,
read: (bytes, offset) => {
let value = 0;
let byteCount = 0;
while (++byteCount) {
const byteIndex = byteCount - 1;
const currentByte = bytes[offset + byteIndex];
const nextSevenBits = 127 & currentByte;
value |= nextSevenBits << byteIndex * 7;
if ((currentByte & 128) === 0) {
break;
}
}
return [value, offset + byteCount];
}
});
var getShortU16Codec = () => combineCodec(getShortU16Encoder(), getShortU16Decoder());

@@ -366,4 +366,3 @@ // src/u128.ts

// src/u8.ts
var getU8Encoder = (config = {}) => numberEncoderFactory({
config,
var getU8Encoder = () => numberEncoderFactory({
name: "u8",

@@ -374,4 +373,3 @@ range: [0, Number("0xff")],

});
var getU8Decoder = (config = {}) => numberDecoderFactory({
config,
var getU8Decoder = () => numberDecoderFactory({
get: (view) => view.getUint8(0),

@@ -381,3 +379,3 @@ name: "u8",

});
var getU8Codec = (config = {}) => combineCodec(getU8Encoder(config), getU8Decoder(config));
var getU8Codec = () => combineCodec(getU8Encoder(), getU8Decoder());

@@ -384,0 +382,0 @@ exports.Endian = Endian;

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

import { combineCodec, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';
import { combineCodec, createEncoder, createDecoder, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';

@@ -18,21 +18,9 @@ // src/assertions.ts

})(Endian || {});
function sharedNumberFactory(input) {
let littleEndian;
let defaultDescription = input.name;
if (input.size > 1) {
littleEndian = !("endian" in input.config) || input.config.endian === 0 /* LITTLE */;
defaultDescription += littleEndian ? "(le)" : "(be)";
}
return {
description: input.config.description ?? defaultDescription,
fixedSize: input.size,
littleEndian,
maxSize: input.size
};
function isLittleEndian(config) {
return config?.endian === 1 /* BIG */ ? false : true;
}
function numberEncoderFactory(input) {
const codecData = sharedNumberFactory(input);
return {
description: codecData.description,
encode(value) {
return createEncoder({
fixedSize: input.size,
write(value, bytes, offset) {
if (input.range) {

@@ -42,22 +30,18 @@ assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);

const arrayBuffer = new ArrayBuffer(input.size);
input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
return new Uint8Array(arrayBuffer);
},
fixedSize: codecData.fixedSize,
maxSize: codecData.maxSize
};
input.set(new DataView(arrayBuffer), value, isLittleEndian(input.config));
bytes.set(new Uint8Array(arrayBuffer), offset);
return offset + input.size;
}
});
}
function numberDecoderFactory(input) {
const codecData = sharedNumberFactory(input);
return {
decode(bytes, offset = 0) {
assertByteArrayIsNotEmptyForCodec(codecData.description, bytes, offset);
assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes, offset);
return createDecoder({
fixedSize: input.size,
read(bytes, offset = 0) {
assertByteArrayIsNotEmptyForCodec(input.name, bytes, offset);
assertByteArrayHasEnoughBytesForCodec(input.name, input.size, bytes, offset);
const view = new DataView(toArrayBuffer(bytes, offset, input.size));
return [input.get(view, codecData.littleEndian), offset + input.size];
},
description: codecData.description,
fixedSize: codecData.fixedSize,
maxSize: codecData.maxSize
};
return [input.get(view, isLittleEndian(input.config)), offset + input.size];
}
});
}

@@ -165,4 +149,3 @@ function toArrayBuffer(bytes, offset, length) {

var getI64Codec = (config = {}) => combineCodec(getI64Encoder(config), getI64Decoder(config));
var getI8Encoder = (config = {}) => numberEncoderFactory({
config,
var getI8Encoder = () => numberEncoderFactory({
name: "i8",

@@ -173,4 +156,3 @@ range: [-Number("0x7f") - 1, Number("0x7f")],

});
var getI8Decoder = (config = {}) => numberDecoderFactory({
config,
var getI8Decoder = () => numberDecoderFactory({
get: (view) => view.getInt8(0),

@@ -180,8 +162,15 @@ name: "i8",

});
var getI8Codec = (config = {}) => combineCodec(getI8Encoder(config), getI8Decoder(config));
var getShortU16Encoder = (config = {}) => ({
description: config.description ?? "shortU16",
encode: (value) => {
var getI8Codec = () => combineCodec(getI8Encoder(), getI8Decoder());
var getShortU16Encoder = () => createEncoder({
getSizeFromValue: (value) => {
if (value <= 127)
return 1;
if (value <= 16383)
return 2;
return 3;
},
maxSize: 3,
write: (value, bytes, offset) => {
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
const bytes = [0];
const shortU16Bytes = [0];
for (let ii = 0; ; ii += 1) {

@@ -193,14 +182,14 @@ const alignedValue = value >> ii * 7;

const nextSevenBits = 127 & alignedValue;
bytes[ii] = nextSevenBits;
shortU16Bytes[ii] = nextSevenBits;
if (ii > 0) {
bytes[ii - 1] |= 128;
shortU16Bytes[ii - 1] |= 128;
}
}
return new Uint8Array(bytes);
},
fixedSize: null,
maxSize: 3
bytes.set(shortU16Bytes, offset);
return offset + shortU16Bytes.length;
}
});
var getShortU16Decoder = (config = {}) => ({
decode: (bytes, offset = 0) => {
var getShortU16Decoder = () => createDecoder({
maxSize: 3,
read: (bytes, offset) => {
let value = 0;

@@ -218,8 +207,5 @@ let byteCount = 0;

return [value, offset + byteCount];
},
description: config.description ?? "shortU16",
fixedSize: null,
maxSize: 3
}
});
var getShortU16Codec = (config = {}) => combineCodec(getShortU16Encoder(config), getShortU16Decoder(config));
var getShortU16Codec = () => combineCodec(getShortU16Encoder(), getShortU16Decoder());
var getU128Encoder = (config = {}) => numberEncoderFactory({

@@ -293,4 +279,3 @@ config,

var getU64Codec = (config = {}) => combineCodec(getU64Encoder(config), getU64Decoder(config));
var getU8Encoder = (config = {}) => numberEncoderFactory({
config,
var getU8Encoder = () => numberEncoderFactory({
name: "u8",

@@ -301,4 +286,3 @@ range: [0, Number("0xff")],

});
var getU8Decoder = (config = {}) => numberDecoderFactory({
config,
var getU8Decoder = () => numberDecoderFactory({
get: (view) => view.getUint8(0),

@@ -308,3 +292,3 @@ name: "u8",

});
var getU8Codec = (config = {}) => combineCodec(getU8Encoder(config), getU8Decoder(config));
var getU8Codec = () => combineCodec(getU8Encoder(), getU8Decoder());

@@ -311,0 +295,0 @@ export { Endian, assertNumberIsBetweenForCodec, getF32Codec, getF32Decoder, getF32Encoder, getF64Codec, getF64Decoder, getF64Encoder, getI128Codec, getI128Decoder, getI128Encoder, getI16Codec, getI16Decoder, getI16Encoder, getI32Codec, getI32Decoder, getI32Encoder, getI64Codec, getI64Decoder, getI64Encoder, getI8Codec, getI8Decoder, getI8Encoder, getShortU16Codec, getShortU16Decoder, getShortU16Encoder, getU128Codec, getU128Decoder, getU128Encoder, getU16Codec, getU16Decoder, getU16Encoder, getU32Codec, getU32Decoder, getU32Encoder, getU64Codec, getU64Decoder, getU64Encoder, getU8Codec, getU8Decoder, getU8Encoder };

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

import { combineCodec, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';
import { combineCodec, createEncoder, createDecoder, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';

@@ -18,21 +18,9 @@ // src/assertions.ts

})(Endian || {});
function sharedNumberFactory(input) {
let littleEndian;
let defaultDescription = input.name;
if (input.size > 1) {
littleEndian = !("endian" in input.config) || input.config.endian === 0 /* LITTLE */;
defaultDescription += littleEndian ? "(le)" : "(be)";
}
return {
description: input.config.description ?? defaultDescription,
fixedSize: input.size,
littleEndian,
maxSize: input.size
};
function isLittleEndian(config) {
return config?.endian === 1 /* BIG */ ? false : true;
}
function numberEncoderFactory(input) {
const codecData = sharedNumberFactory(input);
return {
description: codecData.description,
encode(value) {
return createEncoder({
fixedSize: input.size,
write(value, bytes, offset) {
if (input.range) {

@@ -42,22 +30,18 @@ assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);

const arrayBuffer = new ArrayBuffer(input.size);
input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
return new Uint8Array(arrayBuffer);
},
fixedSize: codecData.fixedSize,
maxSize: codecData.maxSize
};
input.set(new DataView(arrayBuffer), value, isLittleEndian(input.config));
bytes.set(new Uint8Array(arrayBuffer), offset);
return offset + input.size;
}
});
}
function numberDecoderFactory(input) {
const codecData = sharedNumberFactory(input);
return {
decode(bytes, offset = 0) {
assertByteArrayIsNotEmptyForCodec(codecData.description, bytes, offset);
assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes, offset);
return createDecoder({
fixedSize: input.size,
read(bytes, offset = 0) {
assertByteArrayIsNotEmptyForCodec(input.name, bytes, offset);
assertByteArrayHasEnoughBytesForCodec(input.name, input.size, bytes, offset);
const view = new DataView(toArrayBuffer(bytes, offset, input.size));
return [input.get(view, codecData.littleEndian), offset + input.size];
},
description: codecData.description,
fixedSize: codecData.fixedSize,
maxSize: codecData.maxSize
};
return [input.get(view, isLittleEndian(input.config)), offset + input.size];
}
});
}

@@ -165,4 +149,3 @@ function toArrayBuffer(bytes, offset, length) {

var getI64Codec = (config = {}) => combineCodec(getI64Encoder(config), getI64Decoder(config));
var getI8Encoder = (config = {}) => numberEncoderFactory({
config,
var getI8Encoder = () => numberEncoderFactory({
name: "i8",

@@ -173,4 +156,3 @@ range: [-Number("0x7f") - 1, Number("0x7f")],

});
var getI8Decoder = (config = {}) => numberDecoderFactory({
config,
var getI8Decoder = () => numberDecoderFactory({
get: (view) => view.getInt8(0),

@@ -180,8 +162,15 @@ name: "i8",

});
var getI8Codec = (config = {}) => combineCodec(getI8Encoder(config), getI8Decoder(config));
var getShortU16Encoder = (config = {}) => ({
description: config.description ?? "shortU16",
encode: (value) => {
var getI8Codec = () => combineCodec(getI8Encoder(), getI8Decoder());
var getShortU16Encoder = () => createEncoder({
getSizeFromValue: (value) => {
if (value <= 127)
return 1;
if (value <= 16383)
return 2;
return 3;
},
maxSize: 3,
write: (value, bytes, offset) => {
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
const bytes = [0];
const shortU16Bytes = [0];
for (let ii = 0; ; ii += 1) {

@@ -193,14 +182,14 @@ const alignedValue = value >> ii * 7;

const nextSevenBits = 127 & alignedValue;
bytes[ii] = nextSevenBits;
shortU16Bytes[ii] = nextSevenBits;
if (ii > 0) {
bytes[ii - 1] |= 128;
shortU16Bytes[ii - 1] |= 128;
}
}
return new Uint8Array(bytes);
},
fixedSize: null,
maxSize: 3
bytes.set(shortU16Bytes, offset);
return offset + shortU16Bytes.length;
}
});
var getShortU16Decoder = (config = {}) => ({
decode: (bytes, offset = 0) => {
var getShortU16Decoder = () => createDecoder({
maxSize: 3,
read: (bytes, offset) => {
let value = 0;

@@ -218,8 +207,5 @@ let byteCount = 0;

return [value, offset + byteCount];
},
description: config.description ?? "shortU16",
fixedSize: null,
maxSize: 3
}
});
var getShortU16Codec = (config = {}) => combineCodec(getShortU16Encoder(config), getShortU16Decoder(config));
var getShortU16Codec = () => combineCodec(getShortU16Encoder(), getShortU16Decoder());
var getU128Encoder = (config = {}) => numberEncoderFactory({

@@ -293,4 +279,3 @@ config,

var getU64Codec = (config = {}) => combineCodec(getU64Encoder(config), getU64Decoder(config));
var getU8Encoder = (config = {}) => numberEncoderFactory({
config,
var getU8Encoder = () => numberEncoderFactory({
name: "u8",

@@ -301,4 +286,3 @@ range: [0, Number("0xff")],

});
var getU8Decoder = (config = {}) => numberDecoderFactory({
config,
var getU8Decoder = () => numberDecoderFactory({
get: (view) => view.getUint8(0),

@@ -308,6 +292,4 @@ name: "u8",

});
var getU8Codec = (config = {}) => combineCodec(getU8Encoder(config), getU8Decoder(config));
var getU8Codec = () => combineCodec(getU8Encoder(), getU8Decoder());
export { Endian, assertNumberIsBetweenForCodec, getF32Codec, getF32Decoder, getF32Encoder, getF64Codec, getF64Decoder, getF64Encoder, getI128Codec, getI128Decoder, getI128Encoder, getI16Codec, getI16Decoder, getI16Encoder, getI32Codec, getI32Decoder, getI32Encoder, getI64Codec, getI64Decoder, getI64Encoder, getI8Codec, getI8Decoder, getI8Encoder, getShortU16Codec, getShortU16Decoder, getShortU16Encoder, getU128Codec, getU128Decoder, getU128Encoder, getU16Codec, getU16Decoder, getU16Encoder, getU32Codec, getU32Decoder, getU32Encoder, getU64Codec, getU64Decoder, getU64Encoder, getU8Codec, getU8Decoder, getU8Encoder };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.node.js.map

@@ -5,45 +5,45 @@ this.globalThis = this.globalThis || {};

function g(e,r,o,n){if(n<r||n>o)throw new Error(`Codec [${e}] expected number to be in the range [${r}, ${o}], got ${n}.`)}var x=(o=>(o[o.LITTLE=0]="LITTLE",o[o.BIG=1]="BIG",o))(x||{});function b(e,r,o=0){if(r.length-o<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function s(e,r,o,n=0){let f=o.length-n;if(f<r)throw new Error(`Codec [${e}] expected ${r} bytes, got ${f}.`)}function t(e,r,o){if(e.fixedSize!==r.fixedSize)throw new Error(`Encoder and decoder must have the same fixed size, got [${e.fixedSize}] and [${r.fixedSize}].`);if(e.maxSize!==r.maxSize)throw new Error(`Encoder and decoder must have the same max size, got [${e.maxSize}] and [${r.maxSize}].`);if(o===void 0&&e.description!==r.description)throw new Error(`Encoder and decoder must have the same description, got [${e.description}] and [${r.description}]. Pass a custom description as a third argument if you want to override the description and bypass this error.`);return {decode:r.decode,description:o!=null?o:e.description,encode:e.encode,fixedSize:e.fixedSize,maxSize:e.maxSize}}function C(e){var n;let r,o=e.name;return e.size>1&&(r=!("endian"in e.config)||e.config.endian===0,o+=r?"(le)":"(be)"),{description:(n=e.config.description)!=null?n:o,fixedSize:e.size,littleEndian:r,maxSize:e.size}}function i(e){let r=C(e);return {description:r.description,encode(o){e.range&&g(e.name,e.range[0],e.range[1],o);let n=new ArrayBuffer(e.size);return e.set(new DataView(n),o,r.littleEndian),new Uint8Array(n)},fixedSize:r.fixedSize,maxSize:r.maxSize}}function c(e){let r=C(e);return {decode(o,n=0){b(r.description,o,n),s(r.description,e.size,o,n);let f=new DataView(E(o,n,e.size));return [e.get(f,r.littleEndian),n+e.size]},description:r.description,fixedSize:r.fixedSize,maxSize:r.maxSize}}function E(e,r,o){let n=e.byteOffset+(r!=null?r:0),f=o!=null?o:e.byteLength;return e.buffer.slice(n,n+f)}var z=(e={})=>i({config:e,name:"f32",set:(r,o,n)=>r.setFloat32(0,o,n),size:4}),N=(e={})=>c({config:e,get:(r,o)=>r.getFloat32(0,o),name:"f32",size:4}),ue=(e={})=>t(z(e),N(e));var D=(e={})=>i({config:e,name:"f64",set:(r,o,n)=>r.setFloat64(0,o,n),size:8}),y=(e={})=>c({config:e,get:(r,o)=>r.getFloat64(0,o),name:"f64",size:8}),Ee=(e={})=>t(D(e),y(e));var S=(e={})=>i({config:e,name:"i128",range:[-BigInt("0x7fffffffffffffffffffffffffffffff")-1n,BigInt("0x7fffffffffffffffffffffffffffffff")],set:(r,o,n)=>{let f=n?8:0,m=n?0:8,u=0xffffffffffffffffn;r.setBigInt64(f,BigInt(o)>>64n,n),r.setBigUint64(m,BigInt(o)&u,n);},size:16}),l=(e={})=>c({config:e,get:(r,o)=>{let n=o?8:0,f=o?0:8,m=r.getBigInt64(n,o),u=r.getBigUint64(f,o);return (m<<64n)+u},name:"i128",size:16}),Be=(e={})=>t(S(e),l(e));var h=(e={})=>i({config:e,name:"i16",range:[-+"0x7fff"-1,+"0x7fff"],set:(r,o,n)=>r.setInt16(0,o,n),size:2}),B=(e={})=>c({config:e,get:(r,o)=>r.getInt16(0,o),name:"i16",size:2}),Ae=(e={})=>t(h(e),B(e));var I=(e={})=>i({config:e,name:"i32",range:[-+"0x7fffffff"-1,+"0x7fffffff"],set:(r,o,n)=>r.setInt32(0,o,n),size:4}),F=(e={})=>c({config:e,get:(r,o)=>r.getInt32(0,o),name:"i32",size:4}),Ge=(e={})=>t(I(e),F(e));var U=(e={})=>i({config:e,name:"i64",range:[-BigInt("0x7fffffffffffffff")-1n,BigInt("0x7fffffffffffffff")],set:(r,o,n)=>r.setBigInt64(0,BigInt(o),n),size:8}),w=(e={})=>c({config:e,get:(r,o)=>r.getBigInt64(0,o),name:"i64",size:8}),We=(e={})=>t(U(e),w(e));var v=(e={})=>i({config:e,name:"i8",range:[-+"0x7f"-1,+"0x7f"],set:(r,o)=>r.setInt8(0,o),size:1}),T=(e={})=>c({config:e,get:r=>r.getInt8(0),name:"i8",size:1}),tr=(e={})=>t(v(e),T(e));var $=(e={})=>{var r;return {description:(r=e.description)!=null?r:"shortU16",encode:o=>{g("shortU16",0,65535,o);let n=[0];for(let f=0;;f+=1){let m=o>>f*7;if(m===0)break;let u=127&m;n[f]=u,f>0&&(n[f-1]|=128);}return new Uint8Array(n)},fixedSize:null,maxSize:3}},A=(e={})=>{var r;return {decode:(o,n=0)=>{let f=0,m=0;for(;++m;){let u=m-1,a=o[n+u],p=127&a;if(f|=p<<u*7,!(a&128))break}return [f,n+m]},description:(r=e.description)!=null?r:"shortU16",fixedSize:null,maxSize:3}},br=(e={})=>t($(e),A(e));var O=(e={})=>i({config:e,name:"u128",range:[0,BigInt("0xffffffffffffffffffffffffffffffff")],set:(r,o,n)=>{let f=n?8:0,m=n?0:8,u=0xffffffffffffffffn;r.setBigUint64(f,BigInt(o)>>64n,n),r.setBigUint64(m,BigInt(o)&u,n);},size:16}),L=(e={})=>c({config:e,get:(r,o)=>{let n=o?8:0,f=o?0:8,m=r.getBigUint64(n,o),u=r.getBigUint64(f,o);return (m<<64n)+u},name:"u128",size:16}),Dr=(e={})=>t(O(e),L(e));var V=(e={})=>i({config:e,name:"u16",range:[0,+"0xffff"],set:(r,o,n)=>r.setUint16(0,o,n),size:2}),_=(e={})=>c({config:e,get:(r,o)=>r.getUint16(0,o),name:"u16",size:2}),Ur=(e={})=>t(V(e),_(e));var k=(e={})=>i({config:e,name:"u32",range:[0,+"0xffffffff"],set:(r,o,n)=>r.setUint32(0,o,n),size:4}),H=(e={})=>c({config:e,get:(r,o)=>r.getUint32(0,o),name:"u32",size:4}),Vr=(e={})=>t(k(e),H(e));var M=(e={})=>i({config:e,name:"u64",range:[0,BigInt("0xffffffffffffffff")],set:(r,o,n)=>r.setBigUint64(0,BigInt(o),n),size:8}),G=(e={})=>c({config:e,get:(r,o)=>r.getBigUint64(0,o),name:"u64",size:8}),qr=(e={})=>t(M(e),G(e));var P=(e={})=>i({config:e,name:"u8",range:[0,+"0xff"],set:(r,o)=>r.setUint8(0,o),size:1}),j=(e={})=>c({config:e,get:r=>r.getUint8(0),name:"u8",size:1}),Zr=(e={})=>t(P(e),j(e));
function x(e,r,o,t){if(t<r||t>o)throw new Error(`Codec [${e}] expected number to be in the range [${r}, ${o}], got ${t}.`)}var S=(o=>(o[o.LITTLE=0]="LITTLE",o[o.BIG=1]="BIG",o))(S||{});function s(e,r,o=0){if(r.length-o<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function z(e,r,o,t=0){let n=o.length-t;if(n<r)throw new Error(`Codec [${e}] expected ${r} bytes, got ${n}.`)}function F(e,r){return "fixedSize"in r?r.fixedSize:r.getSizeFromValue(e)}function a(e){return Object.freeze({...e,encode:r=>{let o=new Uint8Array(F(r,e));return e.write(r,o,0),o}})}function g(e){return Object.freeze({...e,decode:(r,o=0)=>e.read(r,o)[0]})}function b(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function i(e,r){if(b(e)!==b(r))throw new Error("Encoder and decoder must either both be fixed-size or variable-size.");if(b(e)&&b(r)&&e.fixedSize!==r.fixedSize)throw new Error(`Encoder and decoder must have the same fixed size, got [${e.fixedSize}] and [${r.fixedSize}].`);if(!b(e)&&!b(r)&&e.maxSize!==r.maxSize)throw new Error(`Encoder and decoder must have the same max size, got [${e.maxSize}] and [${r.maxSize}].`);return {...r,...e,decode:r.decode,encode:e.encode,read:r.read,write:e.write}}function C(e){return (e==null?void 0:e.endian)!==1}function c(e){return a({fixedSize:e.size,write(r,o,t){e.range&&x(e.name,e.range[0],e.range[1],r);let n=new ArrayBuffer(e.size);return e.set(new DataView(n),r,C(e.config)),o.set(new Uint8Array(n),t),t+e.size}})}function d(e){return g({fixedSize:e.size,read(r,o=0){s(e.name,r,o),z(e.name,e.size,r,o);let t=new DataView(p(r,o,e.size));return [e.get(t,C(e.config)),o+e.size]}})}function p(e,r,o){let t=e.byteOffset+(r!=null?r:0),n=o!=null?o:e.byteLength;return e.buffer.slice(t,t+n)}var E=(e={})=>c({config:e,name:"f32",set:(r,o,t)=>r.setFloat32(0,o,t),size:4}),D=(e={})=>d({config:e,get:(r,o)=>r.getFloat32(0,o),name:"f32",size:4}),xe=(e={})=>i(E(e),D(e));var N=(e={})=>c({config:e,name:"f64",set:(r,o,t)=>r.setFloat64(0,o,t),size:8}),y=(e={})=>d({config:e,get:(r,o)=>r.getFloat64(0,o),name:"f64",size:8}),pe=(e={})=>i(N(e),y(e));var I=(e={})=>c({config:e,name:"i128",range:[-BigInt("0x7fffffffffffffffffffffffffffffff")-1n,BigInt("0x7fffffffffffffffffffffffffffffff")],set:(r,o,t)=>{let n=t?8:0,m=t?0:8,u=0xffffffffffffffffn;r.setBigInt64(n,BigInt(o)>>64n,t),r.setBigUint64(m,BigInt(o)&u,t);},size:16}),l=(e={})=>d({config:e,get:(r,o)=>{let t=o?8:0,n=o?0:8,m=r.getBigInt64(t,o),u=r.getBigUint64(n,o);return (m<<64n)+u},name:"i128",size:16}),we=(e={})=>i(I(e),l(e));var h=(e={})=>c({config:e,name:"i16",range:[-+"0x7fff"-1,+"0x7fff"],set:(r,o,t)=>r.setInt16(0,o,t),size:2}),w=(e={})=>d({config:e,get:(r,o)=>r.getInt16(0,o),name:"i16",size:2}),$e=(e={})=>i(h(e),w(e));var U=(e={})=>c({config:e,name:"i32",range:[-+"0x7fffffff"-1,+"0x7fffffff"],set:(r,o,t)=>r.setInt32(0,o,t),size:4}),B=(e={})=>d({config:e,get:(r,o)=>r.getInt32(0,o),name:"i32",size:4}),qe=(e={})=>i(U(e),B(e));var T=(e={})=>c({config:e,name:"i64",range:[-BigInt("0x7fffffffffffffff")-1n,BigInt("0x7fffffffffffffff")],set:(r,o,t)=>r.setBigInt64(0,BigInt(o),t),size:8}),O=(e={})=>d({config:e,get:(r,o)=>r.getBigInt64(0,o),name:"i64",size:8}),Ye=(e={})=>i(T(e),O(e));var v=()=>c({name:"i8",range:[-+"0x7f"-1,+"0x7f"],set:(e,r)=>e.setInt8(0,r),size:1}),V=()=>d({get:e=>e.getInt8(0),name:"i8",size:1}),cr=()=>i(v(),V());var A=()=>a({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,r,o)=>{x("shortU16",0,65535,e);let t=[0];for(let n=0;;n+=1){let m=e>>n*7;if(m===0)break;let u=127&m;t[n]=u,n>0&&(t[n-1]|=128);}return r.set(t,o),o+t.length}}),$=()=>g({maxSize:3,read:(e,r)=>{let o=0,t=0;for(;++t;){let n=t-1,m=e[r+n],u=127&m;if(o|=u<<n*7,!(m&128))break}return [o,r+t]}}),sr=()=>i(A(),$());var L=(e={})=>c({config:e,name:"u128",range:[0,BigInt("0xffffffffffffffffffffffffffffffff")],set:(r,o,t)=>{let n=t?8:0,m=t?0:8,u=0xffffffffffffffffn;r.setBigUint64(n,BigInt(o)>>64n,t),r.setBigUint64(m,BigInt(o)&u,t);},size:16}),_=(e={})=>d({config:e,get:(r,o)=>{let t=o?8:0,n=o?0:8,m=r.getBigUint64(t,o),u=r.getBigUint64(n,o);return (m<<64n)+u},name:"u128",size:16}),Nr=(e={})=>i(L(e),_(e));var k=(e={})=>c({config:e,name:"u16",range:[0,+"0xffff"],set:(r,o,t)=>r.setUint16(0,o,t),size:2}),j=(e={})=>d({config:e,get:(r,o)=>r.getUint16(0,o),name:"u16",size:2}),Tr=(e={})=>i(k(e),j(e));var G=(e={})=>c({config:e,name:"u32",range:[0,+"0xffffffff"],set:(r,o,t)=>r.setUint32(0,o,t),size:4}),H=(e={})=>d({config:e,get:(r,o)=>r.getUint32(0,o),name:"u32",size:4}),kr=(e={})=>i(G(e),H(e));var M=(e={})=>c({config:e,name:"u64",range:[0,BigInt("0xffffffffffffffff")],set:(r,o,t)=>r.setBigUint64(0,BigInt(o),t),size:8}),q=(e={})=>d({config:e,get:(r,o)=>r.getBigUint64(0,o),name:"u64",size:8}),Pr=(e={})=>i(M(e),q(e));var J=()=>c({name:"u8",range:[0,+"0xff"],set:(e,r)=>e.setUint8(0,r),size:1}),K=()=>d({get:e=>e.getUint8(0),name:"u8",size:1}),ro=()=>i(J(),K());
exports.Endian = x;
exports.assertNumberIsBetweenForCodec = g;
exports.getF32Codec = ue;
exports.getF32Decoder = N;
exports.getF32Encoder = z;
exports.getF64Codec = Ee;
exports.Endian = S;
exports.assertNumberIsBetweenForCodec = x;
exports.getF32Codec = xe;
exports.getF32Decoder = D;
exports.getF32Encoder = E;
exports.getF64Codec = pe;
exports.getF64Decoder = y;
exports.getF64Encoder = D;
exports.getI128Codec = Be;
exports.getF64Encoder = N;
exports.getI128Codec = we;
exports.getI128Decoder = l;
exports.getI128Encoder = S;
exports.getI16Codec = Ae;
exports.getI16Decoder = B;
exports.getI128Encoder = I;
exports.getI16Codec = $e;
exports.getI16Decoder = w;
exports.getI16Encoder = h;
exports.getI32Codec = Ge;
exports.getI32Decoder = F;
exports.getI32Encoder = I;
exports.getI64Codec = We;
exports.getI64Decoder = w;
exports.getI64Encoder = U;
exports.getI8Codec = tr;
exports.getI8Decoder = T;
exports.getI32Codec = qe;
exports.getI32Decoder = B;
exports.getI32Encoder = U;
exports.getI64Codec = Ye;
exports.getI64Decoder = O;
exports.getI64Encoder = T;
exports.getI8Codec = cr;
exports.getI8Decoder = V;
exports.getI8Encoder = v;
exports.getShortU16Codec = br;
exports.getShortU16Decoder = A;
exports.getShortU16Encoder = $;
exports.getU128Codec = Dr;
exports.getU128Decoder = L;
exports.getU128Encoder = O;
exports.getU16Codec = Ur;
exports.getU16Decoder = _;
exports.getU16Encoder = V;
exports.getU32Codec = Vr;
exports.getShortU16Codec = sr;
exports.getShortU16Decoder = $;
exports.getShortU16Encoder = A;
exports.getU128Codec = Nr;
exports.getU128Decoder = _;
exports.getU128Encoder = L;
exports.getU16Codec = Tr;
exports.getU16Decoder = j;
exports.getU16Encoder = k;
exports.getU32Codec = kr;
exports.getU32Decoder = H;
exports.getU32Encoder = k;
exports.getU64Codec = qr;
exports.getU64Decoder = G;
exports.getU32Encoder = G;
exports.getU64Codec = Pr;
exports.getU64Decoder = q;
exports.getU64Encoder = M;
exports.getU8Codec = Zr;
exports.getU8Decoder = j;
exports.getU8Encoder = P;
exports.getU8Codec = ro;
exports.getU8Decoder = K;
exports.getU8Encoder = J;

@@ -50,0 +50,0 @@ return exports;

@@ -1,12 +0,16 @@

import { BaseCodecConfig, Codec, Decoder, Encoder } from '@solana/codecs-core';
import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
/** Defines a encoder for numbers and bigints. */
export type NumberEncoder = Encoder<number> | Encoder<number | bigint>;
/** Defines a fixed-size encoder for numbers and bigints. */
export type FixedSizeNumberEncoder<TSize extends number = number> = FixedSizeEncoder<number, TSize> | FixedSizeEncoder<number | bigint, TSize>;
/** Defines a decoder for numbers and bigints. */
export type NumberDecoder = Decoder<number> | Decoder<bigint>;
/** Defines a fixed-size decoder for numbers and bigints. */
export type FixedSizeNumberDecoder<TSize extends number = number> = FixedSizeDecoder<number, TSize> | FixedSizeDecoder<bigint, TSize>;
/** Defines a codec for numbers and bigints. */
export type NumberCodec = Codec<number> | Codec<number | bigint, bigint>;
/** Defines the config for u8 and i8 codecs. */
export type SingleByteNumberCodecConfig = BaseCodecConfig;
/** Defines a fixed-size codec for numbers and bigints. */
export type FixedSizeNumberCodec<TSize extends number = number> = FixedSizeCodec<number, number, TSize> | FixedSizeCodec<number | bigint, bigint, TSize>;
/** Defines the config for number codecs that use more than one byte. */
export type NumberCodecConfig = BaseCodecConfig & {
export type NumberCodecConfig = {
/**

@@ -13,0 +17,0 @@ * Whether the serializer should use little-endian or big-endian encoding.

@@ -1,6 +0,6 @@

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common';
export declare const getF32Encoder: (config?: NumberCodecConfig) => Encoder<number>;
export declare const getF32Decoder: (config?: NumberCodecConfig) => Decoder<number>;
export declare const getF32Codec: (config?: NumberCodecConfig) => Codec<number>;
export declare const getF32Encoder: (config?: NumberCodecConfig) => FixedSizeEncoder<number, 4>;
export declare const getF32Decoder: (config?: NumberCodecConfig) => FixedSizeDecoder<number, 4>;
export declare const getF32Codec: (config?: NumberCodecConfig) => FixedSizeCodec<number, number, 4>;
//# sourceMappingURL=f32.d.ts.map

@@ -1,6 +0,6 @@

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common';
export declare const getF64Encoder: (config?: NumberCodecConfig) => Encoder<number>;
export declare const getF64Decoder: (config?: NumberCodecConfig) => Decoder<number>;
export declare const getF64Codec: (config?: NumberCodecConfig) => Codec<number>;
export declare const getF64Encoder: (config?: NumberCodecConfig) => FixedSizeEncoder<number, 8>;
export declare const getF64Decoder: (config?: NumberCodecConfig) => FixedSizeDecoder<number, 8>;
export declare const getF64Codec: (config?: NumberCodecConfig) => FixedSizeCodec<number, number, 8>;
//# sourceMappingURL=f64.d.ts.map

@@ -1,6 +0,6 @@

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common';
export declare const getI128Encoder: (config?: NumberCodecConfig) => Encoder<number | bigint>;
export declare const getI128Decoder: (config?: NumberCodecConfig) => Decoder<bigint>;
export declare const getI128Codec: (config?: NumberCodecConfig) => Codec<number | bigint, bigint>;
export declare const getI128Encoder: (config?: NumberCodecConfig) => FixedSizeEncoder<number | bigint, 16>;
export declare const getI128Decoder: (config?: NumberCodecConfig) => FixedSizeDecoder<bigint, 16>;
export declare const getI128Codec: (config?: NumberCodecConfig) => FixedSizeCodec<number | bigint, bigint, 16>;
//# sourceMappingURL=i128.d.ts.map

@@ -1,6 +0,6 @@

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common';
export declare const getI16Encoder: (config?: NumberCodecConfig) => Encoder<number>;
export declare const getI16Decoder: (config?: NumberCodecConfig) => Decoder<number>;
export declare const getI16Codec: (config?: NumberCodecConfig) => Codec<number>;
export declare const getI16Encoder: (config?: NumberCodecConfig) => FixedSizeEncoder<number, 2>;
export declare const getI16Decoder: (config?: NumberCodecConfig) => FixedSizeDecoder<number, 2>;
export declare const getI16Codec: (config?: NumberCodecConfig) => FixedSizeCodec<number, number, 2>;
//# sourceMappingURL=i16.d.ts.map

@@ -1,6 +0,6 @@

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common';
export declare const getI32Encoder: (config?: NumberCodecConfig) => Encoder<number>;
export declare const getI32Decoder: (config?: NumberCodecConfig) => Decoder<number>;
export declare const getI32Codec: (config?: NumberCodecConfig) => Codec<number>;
export declare const getI32Encoder: (config?: NumberCodecConfig) => FixedSizeEncoder<number, 4>;
export declare const getI32Decoder: (config?: NumberCodecConfig) => FixedSizeDecoder<number, 4>;
export declare const getI32Codec: (config?: NumberCodecConfig) => FixedSizeCodec<number, number, 4>;
//# sourceMappingURL=i32.d.ts.map

@@ -1,6 +0,6 @@

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common';
export declare const getI64Encoder: (config?: NumberCodecConfig) => Encoder<number | bigint>;
export declare const getI64Decoder: (config?: NumberCodecConfig) => Decoder<bigint>;
export declare const getI64Codec: (config?: NumberCodecConfig) => Codec<number | bigint, bigint>;
export declare const getI64Encoder: (config?: NumberCodecConfig) => FixedSizeEncoder<number | bigint, 8>;
export declare const getI64Decoder: (config?: NumberCodecConfig) => FixedSizeDecoder<bigint, 8>;
export declare const getI64Codec: (config?: NumberCodecConfig) => FixedSizeCodec<number | bigint, bigint, 8>;
//# sourceMappingURL=i64.d.ts.map

@@ -1,6 +0,5 @@

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { SingleByteNumberCodecConfig } from './common';
export declare const getI8Encoder: (config?: SingleByteNumberCodecConfig) => Encoder<number>;
export declare const getI8Decoder: (config?: SingleByteNumberCodecConfig) => Decoder<number>;
export declare const getI8Codec: (config?: SingleByteNumberCodecConfig) => Codec<number>;
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
export declare const getI8Encoder: () => FixedSizeEncoder<number, 1>;
export declare const getI8Decoder: () => FixedSizeDecoder<number, 1>;
export declare const getI8Codec: () => FixedSizeCodec<number, number, 1>;
//# sourceMappingURL=i8.d.ts.map

@@ -1,11 +0,7 @@

import { BaseCodecConfig, Codec, Decoder, Encoder } from '@solana/codecs-core';
import { VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
/**
* Defines the config for the shortU16 serializer.
*/
export type ShortU16CodecConfig = BaseCodecConfig;
/**
* Encodes short u16 numbers.
* @see {@link getShortU16Codec} for a more detailed description.
*/
export declare const getShortU16Encoder: (config?: ShortU16CodecConfig) => Encoder<number>;
export declare const getShortU16Encoder: () => VariableSizeEncoder<number>;
/**

@@ -15,3 +11,3 @@ * Decodes short u16 numbers.

*/
export declare const getShortU16Decoder: (config?: ShortU16CodecConfig) => Decoder<number>;
export declare const getShortU16Decoder: () => VariableSizeDecoder<number>;
/**

@@ -26,3 +22,3 @@ * Encodes and decodes short u16 numbers.

*/
export declare const getShortU16Codec: (config?: ShortU16CodecConfig) => Codec<number>;
export declare const getShortU16Codec: () => VariableSizeCodec<number>;
//# sourceMappingURL=short-u16.d.ts.map

@@ -1,6 +0,6 @@

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common';
export declare const getU128Encoder: (config?: NumberCodecConfig) => Encoder<number | bigint>;
export declare const getU128Decoder: (config?: NumberCodecConfig) => Decoder<bigint>;
export declare const getU128Codec: (config?: NumberCodecConfig) => Codec<number | bigint, bigint>;
export declare const getU128Encoder: (config?: NumberCodecConfig) => FixedSizeEncoder<number | bigint, 16>;
export declare const getU128Decoder: (config?: NumberCodecConfig) => FixedSizeDecoder<bigint, 16>;
export declare const getU128Codec: (config?: NumberCodecConfig) => FixedSizeCodec<number | bigint, bigint, 16>;
//# sourceMappingURL=u128.d.ts.map

@@ -1,6 +0,6 @@

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common';
export declare const getU16Encoder: (config?: NumberCodecConfig) => Encoder<number>;
export declare const getU16Decoder: (config?: NumberCodecConfig) => Decoder<number>;
export declare const getU16Codec: (config?: NumberCodecConfig) => Codec<number>;
export declare const getU16Encoder: (config?: NumberCodecConfig) => FixedSizeEncoder<number, 2>;
export declare const getU16Decoder: (config?: NumberCodecConfig) => FixedSizeDecoder<number, 2>;
export declare const getU16Codec: (config?: NumberCodecConfig) => FixedSizeCodec<number, number, 2>;
//# sourceMappingURL=u16.d.ts.map

@@ -1,6 +0,6 @@

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common';
export declare const getU32Encoder: (config?: NumberCodecConfig) => Encoder<number>;
export declare const getU32Decoder: (config?: NumberCodecConfig) => Decoder<number>;
export declare const getU32Codec: (config?: NumberCodecConfig) => Codec<number>;
export declare const getU32Encoder: (config?: NumberCodecConfig) => FixedSizeEncoder<number, 4>;
export declare const getU32Decoder: (config?: NumberCodecConfig) => FixedSizeDecoder<number, 4>;
export declare const getU32Codec: (config?: NumberCodecConfig) => FixedSizeCodec<number, number, 4>;
//# sourceMappingURL=u32.d.ts.map

@@ -1,6 +0,6 @@

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common';
export declare const getU64Encoder: (config?: NumberCodecConfig) => Encoder<number | bigint>;
export declare const getU64Decoder: (config?: NumberCodecConfig) => Decoder<bigint>;
export declare const getU64Codec: (config?: NumberCodecConfig) => Codec<number | bigint, bigint>;
export declare const getU64Encoder: (config?: NumberCodecConfig) => FixedSizeEncoder<number | bigint, 8>;
export declare const getU64Decoder: (config?: NumberCodecConfig) => FixedSizeDecoder<bigint, 8>;
export declare const getU64Codec: (config?: NumberCodecConfig) => FixedSizeCodec<number | bigint, bigint, 8>;
//# sourceMappingURL=u64.d.ts.map

@@ -1,6 +0,5 @@

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { SingleByteNumberCodecConfig } from './common';
export declare const getU8Encoder: (config?: SingleByteNumberCodecConfig) => Encoder<number>;
export declare const getU8Decoder: (config?: SingleByteNumberCodecConfig) => Decoder<number>;
export declare const getU8Codec: (config?: SingleByteNumberCodecConfig) => Codec<number>;
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
export declare const getU8Encoder: () => FixedSizeEncoder<number, 1>;
export declare const getU8Decoder: () => FixedSizeDecoder<number, 1>;
export declare const getU8Codec: () => FixedSizeCodec<number, number, 1>;
//# sourceMappingURL=u8.d.ts.map

@@ -1,18 +0,18 @@

import { Decoder, Encoder } from '@solana/codecs-core';
import { NumberCodecConfig, SingleByteNumberCodecConfig } from './common';
type NumberFactorySharedInput = {
import { FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common';
type NumberFactorySharedInput<TSize extends number> = {
name: string;
size: number;
config: SingleByteNumberCodecConfig | NumberCodecConfig;
size: TSize;
config?: NumberCodecConfig;
};
type NumberFactoryEncoderInput<T> = NumberFactorySharedInput & {
type NumberFactoryEncoderInput<TFrom, TSize extends number> = NumberFactorySharedInput<TSize> & {
range?: [number | bigint, number | bigint];
set: (view: DataView, value: T, littleEndian?: boolean) => void;
set: (view: DataView, value: TFrom, littleEndian?: boolean) => void;
};
type NumberFactoryDecoderInput<T> = NumberFactorySharedInput & {
get: (view: DataView, littleEndian?: boolean) => T;
type NumberFactoryDecoderInput<TTo, TSize extends number> = NumberFactorySharedInput<TSize> & {
get: (view: DataView, littleEndian?: boolean) => TTo;
};
export declare function numberEncoderFactory<T extends number | bigint>(input: NumberFactoryEncoderInput<T>): Encoder<T>;
export declare function numberDecoderFactory<T extends number | bigint>(input: NumberFactoryDecoderInput<T>): Decoder<T>;
export declare function numberEncoderFactory<TFrom extends number | bigint, TSize extends number>(input: NumberFactoryEncoderInput<TFrom, TSize>): FixedSizeEncoder<TFrom, TSize>;
export declare function numberDecoderFactory<TTo extends number | bigint, TSize extends number>(input: NumberFactoryDecoderInput<TTo, TSize>): FixedSizeDecoder<TTo, TSize>;
export {};
//# sourceMappingURL=utils.d.ts.map
{
"name": "@solana/codecs-numbers",
"version": "2.0.0-experimental.ab12c29",
"version": "2.0.0-experimental.aef0571",
"description": "Codecs for numbers of different sizes and endianness",

@@ -52,3 +52,3 @@ "exports": {

"dependencies": {
"@solana/codecs-core": "2.0.0-experimental.ab12c29"
"@solana/codecs-core": "2.0.0-experimental.aef0571"
},

@@ -69,3 +69,3 @@ "devDependencies": {

"jest-runner-prettier": "^1.0.0",
"prettier": "^2.8",
"prettier": "^3.1",
"tsup": "^8.0.1",

@@ -72,0 +72,0 @@ "typescript": "^5.2.2",

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

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