Socket
Socket
Sign inDemoInstall

@solana/codecs-core

Package Overview
Dependencies
Maintainers
14
Versions
1095
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/codecs-core - npm Package Compare versions

Comparing version 2.0.0-experimental.e6fc977 to 2.0.0-experimental.e72afd8

2

dist/index.browser.js

@@ -167,3 +167,1 @@ // src/assertions.ts

export { assertByteArrayHasEnoughBytesForCodec, assertByteArrayIsNotEmptyForCodec, assertFixedSizeCodec, combineCodec, fixBytes, fixCodec, fixDecoder, fixEncoder, mapCodec, mapDecoder, mapEncoder, mergeBytes, padBytes, reverseCodec, reverseDecoder, reverseEncoder };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.browser.js.map

6

dist/index.development.js

@@ -19,3 +19,3 @@ this.globalThis = this.globalThis || {};

if (data.fixedSize === null) {
throw new Error(message ?? "Expected a fixed-size codec, got a variable-size one.");
throw new Error(message != null ? message : "Expected a fixed-size codec, got a variable-size one.");
}

@@ -70,3 +70,3 @@ }

decode: decoder.decode,
description: description ?? encoder.description,
description: description != null ? description : encoder.description,
encode: encoder.encode,

@@ -81,3 +81,3 @@ fixedSize: encoder.fixedSize,

return {
description: description ?? `fixed(${fixedBytes}, ${data.description})`,
description: description != null ? description : `fixed(${fixedBytes}, ${data.description})`,
fixedSize: fixedBytes,

@@ -84,0 +84,0 @@ maxSize: fixedBytes

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

function E(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 t=o.length-n;if(t<r)throw new Error(`Codec [${e}] expected ${r} bytes, got ${t}.`)}function a(e,r){if(e.fixedSize===null)throw new Error(r??"Expected a fixed-size codec, got a variable-size one.")}var u=e=>{let r=e.filter(i=>i.length);if(r.length===0)return e.length?e[0]:new Uint8Array;if(r.length===1)return r[0];let o=r.reduce((i,p)=>i+p.length,0),n=new Uint8Array(o),t=0;return r.forEach(i=>{n.set(i,t),t+=i.length;}),n},f=(e,r)=>{if(e.length>=r)return e;let o=new Uint8Array(r).fill(0);return o.set(e),o},m=(e,r)=>f(e.length<=r?e:e.slice(0,r),r);function c(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??e.description,encode:e.encode,fixedSize:e.fixedSize,maxSize:e.maxSize}}function x(e,r,o){return {description:o??`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r}}function l(e,r,o){return {...x(e,r,o),encode:n=>m(e.encode(n),r)}}function T(e,r,o){return {...x(e,r,o),decode:(n,t=0)=>{s("fixCodec",r,n,t),(t>0||n.length>r)&&(n=n.slice(t,t+r)),e.fixedSize!==null&&(n=m(n,e.fixedSize));let[i]=e.decode(n,0);return [i,t+r]}}}function $(e,r,o){return c(l(e,r,o),T(e,r,o))}function z(e,r){return {description:e.description,encode:o=>e.encode(r(o)),fixedSize:e.fixedSize,maxSize:e.maxSize}}function w(e,r){return {decode:(o,n=0)=>{let[t,i]=e.decode(o,n);return [r(t,o,n),i]},description:e.description,fixedSize:e.fixedSize,maxSize:e.maxSize}}function _(e,r,o){return {decode:o?w(e,o).decode:e.decode,description:e.description,encode:z(e,r).encode,fixedSize:e.fixedSize,maxSize:e.maxSize}}function C(e){return a(e,"Cannot reverse a codec of variable size."),{...e,encode:r=>e.encode(r).reverse()}}function F(e){return a(e,"Cannot reverse a codec of variable size."),{...e,decode:(r,o=0)=>{let n=o+e.fixedSize;if(o===0&&r.length===n)return e.decode(r.reverse(),o);let t=u([...o===0?[]:[r.slice(0,o)],r.slice(o,n).reverse(),...r.length===n?[]:[r.slice(n)]]);return e.decode(t,o)}}}function I(e){return c(C(e),F(e))}
function E(e,r,o=0){if(r.length-o<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function u(e,r,o,n=0){let t=o.length-n;if(t<r)throw new Error(`Codec [${e}] expected ${r} bytes, got ${t}.`)}function a(e,r){if(e.fixedSize===null)throw new Error(r!=null?r:"Expected a fixed-size codec, got a variable-size one.")}var x=e=>{let r=e.filter(i=>i.length);if(r.length===0)return e.length?e[0]:new Uint8Array;if(r.length===1)return r[0];let o=r.reduce((i,p)=>i+p.length,0),n=new Uint8Array(o),t=0;return r.forEach(i=>{n.set(i,t),t+=i.length;}),n},f=(e,r)=>{if(e.length>=r)return e;let o=new Uint8Array(r).fill(0);return o.set(e),o},m=(e,r)=>f(e.length<=r?e:e.slice(0,r),r);function c(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 s(e,r,o){return {description:o!=null?o:`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r}}function l(e,r,o){return {...s(e,r,o),encode:n=>m(e.encode(n),r)}}function T(e,r,o){return {...s(e,r,o),decode:(n,t=0)=>{u("fixCodec",r,n,t),(t>0||n.length>r)&&(n=n.slice(t,t+r)),e.fixedSize!==null&&(n=m(n,e.fixedSize));let[i]=e.decode(n,0);return [i,t+r]}}}function $(e,r,o){return c(l(e,r,o),T(e,r,o))}function z(e,r){return {description:e.description,encode:o=>e.encode(r(o)),fixedSize:e.fixedSize,maxSize:e.maxSize}}function w(e,r){return {decode:(o,n=0)=>{let[t,i]=e.decode(o,n);return [r(t,o,n),i]},description:e.description,fixedSize:e.fixedSize,maxSize:e.maxSize}}function _(e,r,o){return {decode:o?w(e,o).decode:e.decode,description:e.description,encode:z(e,r).encode,fixedSize:e.fixedSize,maxSize:e.maxSize}}function C(e){return a(e,"Cannot reverse a codec of variable size."),{...e,encode:r=>e.encode(r).reverse()}}function F(e){return a(e,"Cannot reverse a codec of variable size."),{...e,decode:(r,o=0)=>{let n=o+e.fixedSize;if(o===0&&r.length===n)return e.decode(r.reverse(),o);let t=x([...o===0?[]:[r.slice(0,o)],r.slice(o,n).reverse(),...r.length===n?[]:[r.slice(n)]]);return e.decode(t,o)}}}function I(e){return c(C(e),F(e))}
exports.assertByteArrayHasEnoughBytesForCodec = s;
exports.assertByteArrayHasEnoughBytesForCodec = u;
exports.assertByteArrayIsNotEmptyForCodec = E;

@@ -19,3 +19,3 @@ exports.assertFixedSizeCodec = a;

exports.mapEncoder = z;
exports.mergeBytes = u;
exports.mergeBytes = x;
exports.padBytes = f;

@@ -22,0 +22,0 @@ exports.reverseCodec = I;

@@ -44,5 +44,5 @@ /**

/**
* Defines common options for codec factories.
* Defines common configurations for codec factories.
*/
export type BaseCodecOptions = {
export type BaseCodecConfig = {
/** A custom description for the Codec. */

@@ -49,0 +49,0 @@ description?: string;

{
"name": "@solana/codecs-core",
"version": "2.0.0-experimental.e6fc977",
"version": "2.0.0-experimental.e72afd8",
"description": "Core types and helpers for encoding and decoding byte arrays on Solana",

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

"prettier": "^2.8",
"tsup": "7.2.0",
"tsup": "^8.0.1",
"typescript": "^5.2.2",

@@ -69,0 +69,0 @@ "version-from-git": "^1.1.1",

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