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.1c6b6d6 to 2.0.0-experimental.1e2106f

208

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.options) || input.options.endian === 0 /* LITTLE */;
defaultDescription += littleEndian ? "(le)" : "(be)";
}
return {
description: input.options.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];
}
});
}

@@ -71,31 +55,31 @@ function toArrayBuffer(bytes, offset, length) {

// src/f32.ts
var getF32Encoder = (options = {}) => numberEncoderFactory({
var getF32Encoder = (config = {}) => numberEncoderFactory({
config,
name: "f32",
options,
set: (view, value, le) => view.setFloat32(0, value, le),
size: 4
});
var getF32Decoder = (options = {}) => numberDecoderFactory({
var getF32Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getFloat32(0, le),
name: "f32",
options,
size: 4
});
var getF32Codec = (options = {}) => combineCodec(getF32Encoder(options), getF32Decoder(options));
var getF64Encoder = (options = {}) => numberEncoderFactory({
var getF32Codec = (config = {}) => combineCodec(getF32Encoder(config), getF32Decoder(config));
var getF64Encoder = (config = {}) => numberEncoderFactory({
config,
name: "f64",
options,
set: (view, value, le) => view.setFloat64(0, value, le),
size: 8
});
var getF64Decoder = (options = {}) => numberDecoderFactory({
var getF64Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getFloat64(0, le),
name: "f64",
options,
size: 8
});
var getF64Codec = (options = {}) => combineCodec(getF64Encoder(options), getF64Decoder(options));
var getI128Encoder = (options = {}) => numberEncoderFactory({
var getF64Codec = (config = {}) => combineCodec(getF64Encoder(config), getF64Decoder(config));
var getI128Encoder = (config = {}) => numberEncoderFactory({
config,
name: "i128",
options,
range: [-BigInt("0x7fffffffffffffffffffffffffffffff") - 1n, BigInt("0x7fffffffffffffffffffffffffffffff")],

@@ -111,3 +95,4 @@ set: (view, value, le) => {

});
var getI128Decoder = (options = {}) => numberDecoderFactory({
var getI128Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => {

@@ -121,9 +106,8 @@ const leftOffset = le ? 8 : 0;

name: "i128",
options,
size: 16
});
var getI128Codec = (options = {}) => combineCodec(getI128Encoder(options), getI128Decoder(options));
var getI16Encoder = (options = {}) => numberEncoderFactory({
var getI128Codec = (config = {}) => combineCodec(getI128Encoder(config), getI128Decoder(config));
var getI16Encoder = (config = {}) => numberEncoderFactory({
config,
name: "i16",
options,
range: [-Number("0x7fff") - 1, Number("0x7fff")],

@@ -133,12 +117,12 @@ set: (view, value, le) => view.setInt16(0, value, le),

});
var getI16Decoder = (options = {}) => numberDecoderFactory({
var getI16Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getInt16(0, le),
name: "i16",
options,
size: 2
});
var getI16Codec = (options = {}) => combineCodec(getI16Encoder(options), getI16Decoder(options));
var getI32Encoder = (options = {}) => numberEncoderFactory({
var getI16Codec = (config = {}) => combineCodec(getI16Encoder(config), getI16Decoder(config));
var getI32Encoder = (config = {}) => numberEncoderFactory({
config,
name: "i32",
options,
range: [-Number("0x7fffffff") - 1, Number("0x7fffffff")],

@@ -148,12 +132,12 @@ set: (view, value, le) => view.setInt32(0, value, le),

});
var getI32Decoder = (options = {}) => numberDecoderFactory({
var getI32Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getInt32(0, le),
name: "i32",
options,
size: 4
});
var getI32Codec = (options = {}) => combineCodec(getI32Encoder(options), getI32Decoder(options));
var getI64Encoder = (options = {}) => numberEncoderFactory({
var getI32Codec = (config = {}) => combineCodec(getI32Encoder(config), getI32Decoder(config));
var getI64Encoder = (config = {}) => numberEncoderFactory({
config,
name: "i64",
options,
range: [-BigInt("0x7fffffffffffffff") - 1n, BigInt("0x7fffffffffffffff")],

@@ -163,12 +147,11 @@ set: (view, value, le) => view.setBigInt64(0, BigInt(value), le),

});
var getI64Decoder = (options = {}) => numberDecoderFactory({
var getI64Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getBigInt64(0, le),
name: "i64",
options,
size: 8
});
var getI64Codec = (options = {}) => combineCodec(getI64Encoder(options), getI64Decoder(options));
var getI8Encoder = (options = {}) => numberEncoderFactory({
var getI64Codec = (config = {}) => combineCodec(getI64Encoder(config), getI64Decoder(config));
var getI8Encoder = () => numberEncoderFactory({
name: "i8",
options,
range: [-Number("0x7f") - 1, Number("0x7f")],

@@ -178,14 +161,20 @@ set: (view, value) => view.setInt8(0, value),

});
var getI8Decoder = (options = {}) => numberDecoderFactory({
var getI8Decoder = () => numberDecoderFactory({
get: (view) => view.getInt8(0),
name: "i8",
options,
size: 1
});
var getI8Codec = (options = {}) => combineCodec(getI8Encoder(options), getI8Decoder(options));
var getShortU16Encoder = (options = {}) => ({
description: options.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) {

@@ -197,14 +186,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 = (options = {}) => ({
decode: (bytes, offset = 0) => {
var getShortU16Decoder = () => createDecoder({
maxSize: 3,
read: (bytes, offset) => {
let value = 0;

@@ -222,11 +211,8 @@ let byteCount = 0;

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

@@ -242,3 +228,4 @@ set: (view, value, le) => {

});
var getU128Decoder = (options = {}) => numberDecoderFactory({
var getU128Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => {

@@ -252,9 +239,8 @@ const leftOffset = le ? 8 : 0;

name: "u128",
options,
size: 16
});
var getU128Codec = (options = {}) => combineCodec(getU128Encoder(options), getU128Decoder(options));
var getU16Encoder = (options = {}) => numberEncoderFactory({
var getU128Codec = (config = {}) => combineCodec(getU128Encoder(config), getU128Decoder(config));
var getU16Encoder = (config = {}) => numberEncoderFactory({
config,
name: "u16",
options,
range: [0, Number("0xffff")],

@@ -264,12 +250,12 @@ set: (view, value, le) => view.setUint16(0, value, le),

});
var getU16Decoder = (options = {}) => numberDecoderFactory({
var getU16Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getUint16(0, le),
name: "u16",
options,
size: 2
});
var getU16Codec = (options = {}) => combineCodec(getU16Encoder(options), getU16Decoder(options));
var getU32Encoder = (options = {}) => numberEncoderFactory({
var getU16Codec = (config = {}) => combineCodec(getU16Encoder(config), getU16Decoder(config));
var getU32Encoder = (config = {}) => numberEncoderFactory({
config,
name: "u32",
options,
range: [0, Number("0xffffffff")],

@@ -279,12 +265,12 @@ set: (view, value, le) => view.setUint32(0, value, le),

});
var getU32Decoder = (options = {}) => numberDecoderFactory({
var getU32Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getUint32(0, le),
name: "u32",
options,
size: 4
});
var getU32Codec = (options = {}) => combineCodec(getU32Encoder(options), getU32Decoder(options));
var getU64Encoder = (options = {}) => numberEncoderFactory({
var getU32Codec = (config = {}) => combineCodec(getU32Encoder(config), getU32Decoder(config));
var getU64Encoder = (config = {}) => numberEncoderFactory({
config,
name: "u64",
options,
range: [0, BigInt("0xffffffffffffffff")],

@@ -294,12 +280,11 @@ set: (view, value, le) => view.setBigUint64(0, BigInt(value), le),

});
var getU64Decoder = (options = {}) => numberDecoderFactory({
var getU64Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getBigUint64(0, le),
name: "u64",
options,
size: 8
});
var getU64Codec = (options = {}) => combineCodec(getU64Encoder(options), getU64Decoder(options));
var getU8Encoder = (options = {}) => numberEncoderFactory({
var getU64Codec = (config = {}) => combineCodec(getU64Encoder(config), getU64Decoder(config));
var getU8Encoder = () => numberEncoderFactory({
name: "u8",
options,
range: [0, Number("0xff")],

@@ -309,9 +294,8 @@ set: (view, value) => view.setUint8(0, value),

});
var getU8Decoder = (options = {}) => numberDecoderFactory({
var getU8Decoder = () => numberDecoderFactory({
get: (view) => view.getUint8(0),
name: "u8",
options,
size: 1
});
var getU8Codec = (options = {}) => combineCodec(getU8Encoder(options), getU8Decoder(options));
var getU8Codec = () => combineCodec(getU8Encoder(), getU8Decoder());

@@ -318,0 +302,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.options) || input.options.endian === 0 /* LITTLE */;
defaultDescription += littleEndian ? "(le)" : "(be)";
}
return {
description: input.options.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];
}
});
}

@@ -71,31 +55,31 @@ function toArrayBuffer(bytes, offset, length) {

// src/f32.ts
var getF32Encoder = (options = {}) => numberEncoderFactory({
var getF32Encoder = (config = {}) => numberEncoderFactory({
config,
name: "f32",
options,
set: (view, value, le) => view.setFloat32(0, value, le),
size: 4
});
var getF32Decoder = (options = {}) => numberDecoderFactory({
var getF32Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getFloat32(0, le),
name: "f32",
options,
size: 4
});
var getF32Codec = (options = {}) => combineCodec(getF32Encoder(options), getF32Decoder(options));
var getF64Encoder = (options = {}) => numberEncoderFactory({
var getF32Codec = (config = {}) => combineCodec(getF32Encoder(config), getF32Decoder(config));
var getF64Encoder = (config = {}) => numberEncoderFactory({
config,
name: "f64",
options,
set: (view, value, le) => view.setFloat64(0, value, le),
size: 8
});
var getF64Decoder = (options = {}) => numberDecoderFactory({
var getF64Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getFloat64(0, le),
name: "f64",
options,
size: 8
});
var getF64Codec = (options = {}) => combineCodec(getF64Encoder(options), getF64Decoder(options));
var getI128Encoder = (options = {}) => numberEncoderFactory({
var getF64Codec = (config = {}) => combineCodec(getF64Encoder(config), getF64Decoder(config));
var getI128Encoder = (config = {}) => numberEncoderFactory({
config,
name: "i128",
options,
range: [-BigInt("0x7fffffffffffffffffffffffffffffff") - 1n, BigInt("0x7fffffffffffffffffffffffffffffff")],

@@ -111,3 +95,4 @@ set: (view, value, le) => {

});
var getI128Decoder = (options = {}) => numberDecoderFactory({
var getI128Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => {

@@ -121,9 +106,8 @@ const leftOffset = le ? 8 : 0;

name: "i128",
options,
size: 16
});
var getI128Codec = (options = {}) => combineCodec(getI128Encoder(options), getI128Decoder(options));
var getI16Encoder = (options = {}) => numberEncoderFactory({
var getI128Codec = (config = {}) => combineCodec(getI128Encoder(config), getI128Decoder(config));
var getI16Encoder = (config = {}) => numberEncoderFactory({
config,
name: "i16",
options,
range: [-Number("0x7fff") - 1, Number("0x7fff")],

@@ -133,12 +117,12 @@ set: (view, value, le) => view.setInt16(0, value, le),

});
var getI16Decoder = (options = {}) => numberDecoderFactory({
var getI16Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getInt16(0, le),
name: "i16",
options,
size: 2
});
var getI16Codec = (options = {}) => combineCodec(getI16Encoder(options), getI16Decoder(options));
var getI32Encoder = (options = {}) => numberEncoderFactory({
var getI16Codec = (config = {}) => combineCodec(getI16Encoder(config), getI16Decoder(config));
var getI32Encoder = (config = {}) => numberEncoderFactory({
config,
name: "i32",
options,
range: [-Number("0x7fffffff") - 1, Number("0x7fffffff")],

@@ -148,12 +132,12 @@ set: (view, value, le) => view.setInt32(0, value, le),

});
var getI32Decoder = (options = {}) => numberDecoderFactory({
var getI32Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getInt32(0, le),
name: "i32",
options,
size: 4
});
var getI32Codec = (options = {}) => combineCodec(getI32Encoder(options), getI32Decoder(options));
var getI64Encoder = (options = {}) => numberEncoderFactory({
var getI32Codec = (config = {}) => combineCodec(getI32Encoder(config), getI32Decoder(config));
var getI64Encoder = (config = {}) => numberEncoderFactory({
config,
name: "i64",
options,
range: [-BigInt("0x7fffffffffffffff") - 1n, BigInt("0x7fffffffffffffff")],

@@ -163,12 +147,11 @@ set: (view, value, le) => view.setBigInt64(0, BigInt(value), le),

});
var getI64Decoder = (options = {}) => numberDecoderFactory({
var getI64Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getBigInt64(0, le),
name: "i64",
options,
size: 8
});
var getI64Codec = (options = {}) => combineCodec(getI64Encoder(options), getI64Decoder(options));
var getI8Encoder = (options = {}) => numberEncoderFactory({
var getI64Codec = (config = {}) => combineCodec(getI64Encoder(config), getI64Decoder(config));
var getI8Encoder = () => numberEncoderFactory({
name: "i8",
options,
range: [-Number("0x7f") - 1, Number("0x7f")],

@@ -178,14 +161,20 @@ set: (view, value) => view.setInt8(0, value),

});
var getI8Decoder = (options = {}) => numberDecoderFactory({
var getI8Decoder = () => numberDecoderFactory({
get: (view) => view.getInt8(0),
name: "i8",
options,
size: 1
});
var getI8Codec = (options = {}) => combineCodec(getI8Encoder(options), getI8Decoder(options));
var getShortU16Encoder = (options = {}) => ({
description: options.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) {

@@ -197,14 +186,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 = (options = {}) => ({
decode: (bytes, offset = 0) => {
var getShortU16Decoder = () => createDecoder({
maxSize: 3,
read: (bytes, offset) => {
let value = 0;

@@ -222,11 +211,8 @@ let byteCount = 0;

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

@@ -242,3 +228,4 @@ set: (view, value, le) => {

});
var getU128Decoder = (options = {}) => numberDecoderFactory({
var getU128Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => {

@@ -252,9 +239,8 @@ const leftOffset = le ? 8 : 0;

name: "u128",
options,
size: 16
});
var getU128Codec = (options = {}) => combineCodec(getU128Encoder(options), getU128Decoder(options));
var getU16Encoder = (options = {}) => numberEncoderFactory({
var getU128Codec = (config = {}) => combineCodec(getU128Encoder(config), getU128Decoder(config));
var getU16Encoder = (config = {}) => numberEncoderFactory({
config,
name: "u16",
options,
range: [0, Number("0xffff")],

@@ -264,12 +250,12 @@ set: (view, value, le) => view.setUint16(0, value, le),

});
var getU16Decoder = (options = {}) => numberDecoderFactory({
var getU16Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getUint16(0, le),
name: "u16",
options,
size: 2
});
var getU16Codec = (options = {}) => combineCodec(getU16Encoder(options), getU16Decoder(options));
var getU32Encoder = (options = {}) => numberEncoderFactory({
var getU16Codec = (config = {}) => combineCodec(getU16Encoder(config), getU16Decoder(config));
var getU32Encoder = (config = {}) => numberEncoderFactory({
config,
name: "u32",
options,
range: [0, Number("0xffffffff")],

@@ -279,12 +265,12 @@ set: (view, value, le) => view.setUint32(0, value, le),

});
var getU32Decoder = (options = {}) => numberDecoderFactory({
var getU32Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getUint32(0, le),
name: "u32",
options,
size: 4
});
var getU32Codec = (options = {}) => combineCodec(getU32Encoder(options), getU32Decoder(options));
var getU64Encoder = (options = {}) => numberEncoderFactory({
var getU32Codec = (config = {}) => combineCodec(getU32Encoder(config), getU32Decoder(config));
var getU64Encoder = (config = {}) => numberEncoderFactory({
config,
name: "u64",
options,
range: [0, BigInt("0xffffffffffffffff")],

@@ -294,12 +280,11 @@ set: (view, value, le) => view.setBigUint64(0, BigInt(value), le),

});
var getU64Decoder = (options = {}) => numberDecoderFactory({
var getU64Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getBigUint64(0, le),
name: "u64",
options,
size: 8
});
var getU64Codec = (options = {}) => combineCodec(getU64Encoder(options), getU64Decoder(options));
var getU8Encoder = (options = {}) => numberEncoderFactory({
var getU64Codec = (config = {}) => combineCodec(getU64Encoder(config), getU64Decoder(config));
var getU8Encoder = () => numberEncoderFactory({
name: "u8",
options,
range: [0, Number("0xff")],

@@ -309,9 +294,8 @@ set: (view, value) => view.setUint8(0, value),

});
var getU8Decoder = (options = {}) => numberDecoderFactory({
var getU8Decoder = () => numberDecoderFactory({
get: (view) => view.getUint8(0),
name: "u8",
options,
size: 1
});
var getU8Codec = (options = {}) => combineCodec(getU8Encoder(options), getU8Decoder(options));
var getU8Codec = () => combineCodec(getU8Encoder(), getU8Decoder());

@@ -318,0 +302,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.options) || input.options.endian === 0 /* LITTLE */;
defaultDescription += littleEndian ? "(le)" : "(be)";
}
return {
description: input.options.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];
}
});
}

@@ -71,31 +55,31 @@ function toArrayBuffer(bytes, offset, length) {

// src/f32.ts
var getF32Encoder = (options = {}) => numberEncoderFactory({
var getF32Encoder = (config = {}) => numberEncoderFactory({
config,
name: "f32",
options,
set: (view, value, le) => view.setFloat32(0, value, le),
size: 4
});
var getF32Decoder = (options = {}) => numberDecoderFactory({
var getF32Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getFloat32(0, le),
name: "f32",
options,
size: 4
});
var getF32Codec = (options = {}) => combineCodec(getF32Encoder(options), getF32Decoder(options));
var getF64Encoder = (options = {}) => numberEncoderFactory({
var getF32Codec = (config = {}) => combineCodec(getF32Encoder(config), getF32Decoder(config));
var getF64Encoder = (config = {}) => numberEncoderFactory({
config,
name: "f64",
options,
set: (view, value, le) => view.setFloat64(0, value, le),
size: 8
});
var getF64Decoder = (options = {}) => numberDecoderFactory({
var getF64Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getFloat64(0, le),
name: "f64",
options,
size: 8
});
var getF64Codec = (options = {}) => combineCodec(getF64Encoder(options), getF64Decoder(options));
var getI128Encoder = (options = {}) => numberEncoderFactory({
var getF64Codec = (config = {}) => combineCodec(getF64Encoder(config), getF64Decoder(config));
var getI128Encoder = (config = {}) => numberEncoderFactory({
config,
name: "i128",
options,
range: [-BigInt("0x7fffffffffffffffffffffffffffffff") - 1n, BigInt("0x7fffffffffffffffffffffffffffffff")],

@@ -111,3 +95,4 @@ set: (view, value, le) => {

});
var getI128Decoder = (options = {}) => numberDecoderFactory({
var getI128Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => {

@@ -121,9 +106,8 @@ const leftOffset = le ? 8 : 0;

name: "i128",
options,
size: 16
});
var getI128Codec = (options = {}) => combineCodec(getI128Encoder(options), getI128Decoder(options));
var getI16Encoder = (options = {}) => numberEncoderFactory({
var getI128Codec = (config = {}) => combineCodec(getI128Encoder(config), getI128Decoder(config));
var getI16Encoder = (config = {}) => numberEncoderFactory({
config,
name: "i16",
options,
range: [-Number("0x7fff") - 1, Number("0x7fff")],

@@ -133,12 +117,12 @@ set: (view, value, le) => view.setInt16(0, value, le),

});
var getI16Decoder = (options = {}) => numberDecoderFactory({
var getI16Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getInt16(0, le),
name: "i16",
options,
size: 2
});
var getI16Codec = (options = {}) => combineCodec(getI16Encoder(options), getI16Decoder(options));
var getI32Encoder = (options = {}) => numberEncoderFactory({
var getI16Codec = (config = {}) => combineCodec(getI16Encoder(config), getI16Decoder(config));
var getI32Encoder = (config = {}) => numberEncoderFactory({
config,
name: "i32",
options,
range: [-Number("0x7fffffff") - 1, Number("0x7fffffff")],

@@ -148,12 +132,12 @@ set: (view, value, le) => view.setInt32(0, value, le),

});
var getI32Decoder = (options = {}) => numberDecoderFactory({
var getI32Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getInt32(0, le),
name: "i32",
options,
size: 4
});
var getI32Codec = (options = {}) => combineCodec(getI32Encoder(options), getI32Decoder(options));
var getI64Encoder = (options = {}) => numberEncoderFactory({
var getI32Codec = (config = {}) => combineCodec(getI32Encoder(config), getI32Decoder(config));
var getI64Encoder = (config = {}) => numberEncoderFactory({
config,
name: "i64",
options,
range: [-BigInt("0x7fffffffffffffff") - 1n, BigInt("0x7fffffffffffffff")],

@@ -163,12 +147,11 @@ set: (view, value, le) => view.setBigInt64(0, BigInt(value), le),

});
var getI64Decoder = (options = {}) => numberDecoderFactory({
var getI64Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getBigInt64(0, le),
name: "i64",
options,
size: 8
});
var getI64Codec = (options = {}) => combineCodec(getI64Encoder(options), getI64Decoder(options));
var getI8Encoder = (options = {}) => numberEncoderFactory({
var getI64Codec = (config = {}) => combineCodec(getI64Encoder(config), getI64Decoder(config));
var getI8Encoder = () => numberEncoderFactory({
name: "i8",
options,
range: [-Number("0x7f") - 1, Number("0x7f")],

@@ -178,14 +161,20 @@ set: (view, value) => view.setInt8(0, value),

});
var getI8Decoder = (options = {}) => numberDecoderFactory({
var getI8Decoder = () => numberDecoderFactory({
get: (view) => view.getInt8(0),
name: "i8",
options,
size: 1
});
var getI8Codec = (options = {}) => combineCodec(getI8Encoder(options), getI8Decoder(options));
var getShortU16Encoder = (options = {}) => ({
description: options.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) {

@@ -197,14 +186,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 = (options = {}) => ({
decode: (bytes, offset = 0) => {
var getShortU16Decoder = () => createDecoder({
maxSize: 3,
read: (bytes, offset) => {
let value = 0;

@@ -222,11 +211,8 @@ let byteCount = 0;

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

@@ -242,3 +228,4 @@ set: (view, value, le) => {

});
var getU128Decoder = (options = {}) => numberDecoderFactory({
var getU128Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => {

@@ -252,9 +239,8 @@ const leftOffset = le ? 8 : 0;

name: "u128",
options,
size: 16
});
var getU128Codec = (options = {}) => combineCodec(getU128Encoder(options), getU128Decoder(options));
var getU16Encoder = (options = {}) => numberEncoderFactory({
var getU128Codec = (config = {}) => combineCodec(getU128Encoder(config), getU128Decoder(config));
var getU16Encoder = (config = {}) => numberEncoderFactory({
config,
name: "u16",
options,
range: [0, Number("0xffff")],

@@ -264,12 +250,12 @@ set: (view, value, le) => view.setUint16(0, value, le),

});
var getU16Decoder = (options = {}) => numberDecoderFactory({
var getU16Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getUint16(0, le),
name: "u16",
options,
size: 2
});
var getU16Codec = (options = {}) => combineCodec(getU16Encoder(options), getU16Decoder(options));
var getU32Encoder = (options = {}) => numberEncoderFactory({
var getU16Codec = (config = {}) => combineCodec(getU16Encoder(config), getU16Decoder(config));
var getU32Encoder = (config = {}) => numberEncoderFactory({
config,
name: "u32",
options,
range: [0, Number("0xffffffff")],

@@ -279,12 +265,12 @@ set: (view, value, le) => view.setUint32(0, value, le),

});
var getU32Decoder = (options = {}) => numberDecoderFactory({
var getU32Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getUint32(0, le),
name: "u32",
options,
size: 4
});
var getU32Codec = (options = {}) => combineCodec(getU32Encoder(options), getU32Decoder(options));
var getU64Encoder = (options = {}) => numberEncoderFactory({
var getU32Codec = (config = {}) => combineCodec(getU32Encoder(config), getU32Decoder(config));
var getU64Encoder = (config = {}) => numberEncoderFactory({
config,
name: "u64",
options,
range: [0, BigInt("0xffffffffffffffff")],

@@ -294,12 +280,11 @@ set: (view, value, le) => view.setBigUint64(0, BigInt(value), le),

});
var getU64Decoder = (options = {}) => numberDecoderFactory({
var getU64Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getBigUint64(0, le),
name: "u64",
options,
size: 8
});
var getU64Codec = (options = {}) => combineCodec(getU64Encoder(options), getU64Decoder(options));
var getU8Encoder = (options = {}) => numberEncoderFactory({
var getU64Codec = (config = {}) => combineCodec(getU64Encoder(config), getU64Decoder(config));
var getU8Encoder = () => numberEncoderFactory({
name: "u8",
options,
range: [0, Number("0xff")],

@@ -309,9 +294,8 @@ set: (view, value) => view.setUint8(0, value),

});
var getU8Decoder = (options = {}) => numberDecoderFactory({
var getU8Decoder = () => numberDecoderFactory({
get: (view) => view.getUint8(0),
name: "u8",
options,
size: 1
});
var getU8Codec = (options = {}) => combineCodec(getU8Encoder(options), getU8Decoder(options));
var getU8Codec = () => combineCodec(getU8Encoder(), getU8Decoder());

@@ -318,0 +302,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,12 +0,16 @@

import { BaseCodecOptions, 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 options for u8 and i8 codecs. */
export type SingleByteNumberCodecOptions = BaseCodecOptions;
/** Defines the options for number codecs that use more than one byte. */
export type NumberCodecOptions = BaseCodecOptions & {
/** 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 = {
/**

@@ -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 { NumberCodecOptions } from './common';
export declare const getF32Encoder: (options?: NumberCodecOptions) => Encoder<number>;
export declare const getF32Decoder: (options?: NumberCodecOptions) => Decoder<number>;
export declare const getF32Codec: (options?: NumberCodecOptions) => Codec<number>;
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common.js';
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 { NumberCodecOptions } from './common';
export declare const getF64Encoder: (options?: NumberCodecOptions) => Encoder<number>;
export declare const getF64Decoder: (options?: NumberCodecOptions) => Decoder<number>;
export declare const getF64Codec: (options?: NumberCodecOptions) => Codec<number>;
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common.js';
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 { NumberCodecOptions } from './common';
export declare const getI128Encoder: (options?: NumberCodecOptions) => Encoder<number | bigint>;
export declare const getI128Decoder: (options?: NumberCodecOptions) => Decoder<bigint>;
export declare const getI128Codec: (options?: NumberCodecOptions) => Codec<number | bigint, bigint>;
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common.js';
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 { NumberCodecOptions } from './common';
export declare const getI16Encoder: (options?: NumberCodecOptions) => Encoder<number>;
export declare const getI16Decoder: (options?: NumberCodecOptions) => Decoder<number>;
export declare const getI16Codec: (options?: NumberCodecOptions) => Codec<number>;
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common.js';
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 { NumberCodecOptions } from './common';
export declare const getI32Encoder: (options?: NumberCodecOptions) => Encoder<number>;
export declare const getI32Decoder: (options?: NumberCodecOptions) => Decoder<number>;
export declare const getI32Codec: (options?: NumberCodecOptions) => Codec<number>;
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common.js';
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 { NumberCodecOptions } from './common';
export declare const getI64Encoder: (options?: NumberCodecOptions) => Encoder<number | bigint>;
export declare const getI64Decoder: (options?: NumberCodecOptions) => Decoder<bigint>;
export declare const getI64Codec: (options?: NumberCodecOptions) => Codec<number | bigint, bigint>;
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common.js';
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 { SingleByteNumberCodecOptions } from './common';
export declare const getI8Encoder: (options?: SingleByteNumberCodecOptions) => Encoder<number>;
export declare const getI8Decoder: (options?: SingleByteNumberCodecOptions) => Decoder<number>;
export declare const getI8Codec: (options?: SingleByteNumberCodecOptions) => 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,16 +0,16 @@

export * from './assertions';
export * from './common';
export * from './f32';
export * from './f64';
export * from './i128';
export * from './i16';
export * from './i32';
export * from './i64';
export * from './i8';
export * from './short-u16';
export * from './u128';
export * from './u16';
export * from './u32';
export * from './u64';
export * from './u8';
export * from './assertions.js';
export * from './common.js';
export * from './f32.js';
export * from './f64.js';
export * from './i128.js';
export * from './i16.js';
export * from './i32.js';
export * from './i64.js';
export * from './i8.js';
export * from './short-u16.js';
export * from './u128.js';
export * from './u16.js';
export * from './u32.js';
export * from './u64.js';
export * from './u8.js';
//# sourceMappingURL=index.d.ts.map

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

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

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

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

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

*/
export declare const getShortU16Codec: (options?: ShortU16CodecOptions) => 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 { NumberCodecOptions } from './common';
export declare const getU128Encoder: (options?: NumberCodecOptions) => Encoder<number | bigint>;
export declare const getU128Decoder: (options?: NumberCodecOptions) => Decoder<bigint>;
export declare const getU128Codec: (options?: NumberCodecOptions) => Codec<number | bigint, bigint>;
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common.js';
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 { NumberCodecOptions } from './common';
export declare const getU16Encoder: (options?: NumberCodecOptions) => Encoder<number>;
export declare const getU16Decoder: (options?: NumberCodecOptions) => Decoder<number>;
export declare const getU16Codec: (options?: NumberCodecOptions) => Codec<number>;
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common.js';
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 { NumberCodecOptions } from './common';
export declare const getU32Encoder: (options?: NumberCodecOptions) => Encoder<number>;
export declare const getU32Decoder: (options?: NumberCodecOptions) => Decoder<number>;
export declare const getU32Codec: (options?: NumberCodecOptions) => Codec<number>;
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common.js';
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 { NumberCodecOptions } from './common';
export declare const getU64Encoder: (options?: NumberCodecOptions) => Encoder<number | bigint>;
export declare const getU64Decoder: (options?: NumberCodecOptions) => Decoder<bigint>;
export declare const getU64Codec: (options?: NumberCodecOptions) => Codec<number | bigint, bigint>;
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common.js';
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 { SingleByteNumberCodecOptions } from './common';
export declare const getU8Encoder: (options?: SingleByteNumberCodecOptions) => Encoder<number>;
export declare const getU8Decoder: (options?: SingleByteNumberCodecOptions) => Decoder<number>;
export declare const getU8Codec: (options?: SingleByteNumberCodecOptions) => 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 { NumberCodecOptions, SingleByteNumberCodecOptions } from './common';
type NumberFactorySharedInput = {
import { FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
import { NumberCodecConfig } from './common.js';
type NumberFactorySharedInput<TSize extends number> = {
name: string;
size: number;
options: SingleByteNumberCodecOptions | NumberCodecOptions;
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.1c6b6d6",
"version": "2.0.0-experimental.1e2106f",
"description": "Codecs for numbers of different sizes and endianness",

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

"dependencies": {
"@solana/codecs-core": "2.0.0-experimental.1c6b6d6"
"@solana/codecs-core": "2.0.0-experimental.1e2106f"
},

@@ -58,4 +58,4 @@ "devDependencies": {

"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.6",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@types/jest": "^29.5.11",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.3.0",

@@ -70,4 +70,4 @@ "agadoo": "^3.0.0",

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

@@ -88,4 +88,4 @@ "version-from-git": "^1.1.1",

"scripts": {
"compile:js": "tsup --config build-scripts/tsup.config.library.ts",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
"compile:js": "tsup --config build-scripts/tsup.config.package.ts",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/build-scripts/add-js-extension-to-types.mjs",
"dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch",

@@ -92,0 +92,0 @@ "publish-packages": "pnpm publish --tag experimental --access public --no-git-checks",

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