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

@solana/codecs-strings

Package Overview
Dependencies
Maintainers
14
Versions
1164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/codecs-strings - npm Package Compare versions

Comparing version 2.0.0-experimental.2938d71 to 2.0.0-experimental.2962a3f

dist/types/assertions.d.ts.map

257

dist/index.browser.js

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

import { combineCodec, fixEncoder, mergeBytes, fixDecoder, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';
import { createEncoder, createDecoder, combineCodec, fixEncoder, getEncodedSize, fixDecoder, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';
import { getU32Encoder, getU32Decoder } from '@solana/codecs-numbers';

@@ -11,23 +11,20 @@

var getBaseXEncoder = (alphabet4) => {
const base = alphabet4.length;
const baseBigInt = BigInt(base);
return {
description: `base${base}`,
encode(value) {
return createEncoder({
getSizeFromValue: (value) => {
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
if (tailChars === "")
return value.length;
const base10Number = getBigIntFromBaseX(tailChars, alphabet4);
return leadingZeroes.length + Math.ceil(base10Number.toString(16).length / 2);
},
write(value, bytes, offset) {
assertValidBaseString(alphabet4, value);
if (value === "")
return new Uint8Array();
const chars = [...value];
let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
const leadingZeroes = Array(trailIndex).fill(0);
if (trailIndex === chars.length)
return Uint8Array.from(leadingZeroes);
const tailChars = chars.slice(trailIndex);
let base10Number = 0n;
let baseXPower = 1n;
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
baseXPower *= baseBigInt;
return offset;
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
if (tailChars === "") {
bytes.set(new Uint8Array(leadingZeroes.length).fill(0), offset);
return offset + leadingZeroes.length;
}
let base10Number = getBigIntFromBaseX(tailChars, alphabet4);
const tailBytes = [];

@@ -38,13 +35,11 @@ while (base10Number > 0n) {

}
return Uint8Array.from(leadingZeroes.concat(tailBytes));
},
fixedSize: null,
maxSize: null
};
const bytesToAdd = [...Array(leadingZeroes.length).fill(0), ...tailBytes];
bytes.set(bytesToAdd, offset);
return offset + bytesToAdd.length;
}
});
};
var getBaseXDecoder = (alphabet4) => {
const base = alphabet4.length;
const baseBigInt = BigInt(base);
return {
decode(rawBytes, offset = 0) {
return createDecoder({
read(rawBytes, offset) {
const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);

@@ -58,16 +53,26 @@ if (bytes.length === 0)

return [leadingZeroes, rawBytes.length];
let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
const tailChars = [];
while (base10Number > 0n) {
tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
base10Number /= baseBigInt;
}
return [leadingZeroes + tailChars.join(""), rawBytes.length];
},
description: `base${base}`,
fixedSize: null,
maxSize: null
};
const base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
const tailChars = getBaseXFromBigInt(base10Number, alphabet4);
return [leadingZeroes + tailChars, rawBytes.length];
}
});
};
var getBaseXCodec = (alphabet4) => combineCodec(getBaseXEncoder(alphabet4), getBaseXDecoder(alphabet4));
function partitionLeadingZeroes(value, zeroCharacter) {
const leadingZeroIndex = [...value].findIndex((c) => c !== zeroCharacter);
return leadingZeroIndex === -1 ? [value, ""] : [value.slice(0, leadingZeroIndex), value.slice(leadingZeroIndex)];
}
function getBigIntFromBaseX(value, alphabet4) {
const base = BigInt(alphabet4.length);
return [...value].reduce((sum, char) => sum * base + BigInt(alphabet4.indexOf(char)), 0n);
}
function getBaseXFromBigInt(value, alphabet4) {
const base = BigInt(alphabet4.length);
const tailChars = [];
while (value > 0n) {
tailChars.unshift(alphabet4[Number(value % base)]);
value /= base;
}
return tailChars.join("");
}

@@ -79,21 +84,18 @@ // src/base10.ts

var getBase10Codec = () => getBaseXCodec(alphabet);
var getBase16Encoder = () => ({
description: "base16",
encode(value) {
var getBase16Encoder = () => createEncoder({
getSizeFromValue: (value) => Math.ceil(value.length / 2),
write(value, bytes, offset) {
const lowercaseValue = value.toLowerCase();
assertValidBaseString("0123456789abcdef", lowercaseValue, value);
const matches = lowercaseValue.match(/.{1,2}/g);
return Uint8Array.from(matches ? matches.map((byte) => parseInt(byte, 16)) : []);
},
fixedSize: null,
maxSize: null
const hexBytes = matches ? matches.map((byte) => parseInt(byte, 16)) : [];
bytes.set(hexBytes, offset);
return hexBytes.length + offset;
}
});
var getBase16Decoder = () => ({
decode(bytes, offset = 0) {
var getBase16Decoder = () => createDecoder({
read(bytes, offset) {
const value = bytes.slice(offset).reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
return [value, bytes.length];
},
description: "base16",
fixedSize: null,
maxSize: null
}
});

@@ -107,16 +109,16 @@ var getBase16Codec = () => combineCodec(getBase16Encoder(), getBase16Decoder());

var getBase58Codec = () => getBaseXCodec(alphabet2);
var getBaseXResliceEncoder = (alphabet4, bits) => ({
description: `base${alphabet4.length}`,
encode(value) {
var getBaseXResliceEncoder = (alphabet4, bits) => createEncoder({
getSizeFromValue: (value) => Math.floor(value.length * bits / 8),
write(value, bytes, offset) {
assertValidBaseString(alphabet4, value);
if (value === "")
return new Uint8Array();
return offset;
const charIndices = [...value].map((c) => alphabet4.indexOf(c));
return new Uint8Array(reslice(charIndices, bits, 8, false));
},
fixedSize: null,
maxSize: null
const reslicedBytes = reslice(charIndices, bits, 8, false);
bytes.set(reslicedBytes, offset);
return reslicedBytes.length + offset;
}
});
var getBaseXResliceDecoder = (alphabet4, bits) => ({
decode(rawBytes, offset = 0) {
var getBaseXResliceDecoder = (alphabet4, bits) => createDecoder({
read(rawBytes, offset = 0) {
const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);

@@ -127,6 +129,3 @@ if (bytes.length === 0)

return [charIndices.map((i) => alphabet4[i]).join(""), rawBytes.length];
},
description: `base${alphabet4.length}`,
fixedSize: null,
maxSize: null
}
});

@@ -154,8 +153,6 @@ var getBaseXResliceCodec = (alphabet4, bits) => combineCodec(getBaseXResliceEncoder(alphabet4, bits), getBaseXResliceDecoder(alphabet4, bits));

{
return {
description: `base64`,
encode(value) {
return createEncoder({
getSizeFromValue: (value) => {
try {
const bytes = atob(value).split("").map((c) => c.charCodeAt(0));
return new Uint8Array(bytes);
return atob(value).length;
} catch (e2) {

@@ -165,5 +162,12 @@ throw new Error(`Expected a string of base 64, got [${value}].`);

},
fixedSize: null,
maxSize: null
};
write(value, bytes, offset) {
try {
const bytesToAdd = atob(value).split("").map((c) => c.charCodeAt(0));
bytes.set(bytesToAdd, offset);
return bytesToAdd.length + offset;
} catch (e2) {
throw new Error(`Expected a string of base 64, got [${value}].`);
}
}
});
}

@@ -173,12 +177,9 @@ };

{
return {
decode(bytes, offset = 0) {
return createDecoder({
read(bytes, offset = 0) {
const slice = bytes.slice(offset);
const value = btoa(String.fromCharCode(...slice));
return [value, bytes.length];
},
description: `base64`,
fixedSize: null,
maxSize: null
};
}
});
}

@@ -202,20 +203,19 @@ };

let textEncoder;
return {
description: "utf8",
encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
fixedSize: null,
maxSize: null
};
return createEncoder({
getSizeFromValue: (value) => (textEncoder ||= new o()).encode(value).length,
write: (value, bytes, offset) => {
const bytesToAdd = (textEncoder ||= new o()).encode(value);
bytes.set(bytesToAdd, offset);
return offset + bytesToAdd.length;
}
});
};
var getUtf8Decoder = () => {
let textDecoder;
return {
decode(bytes, offset = 0) {
const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
return createDecoder({
read(bytes, offset) {
const value = (textDecoder ||= new e()).decode(bytes.slice(offset));
return [removeNullCharacters(value), bytes.length];
},
description: "utf8",
fixedSize: null,
maxSize: null
};
}
});
};

@@ -225,37 +225,36 @@ var getUtf8Codec = () => combineCodec(getUtf8Encoder(), getUtf8Decoder());

// src/string.ts
var getStringEncoder = (options = {}) => {
const size = options.size ?? getU32Encoder();
const encoding = options.encoding ?? getUtf8Encoder();
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
function getStringEncoder(config = {}) {
const size = config.size ?? getU32Encoder();
const encoding = config.encoding ?? getUtf8Encoder();
if (size === "variable") {
return { ...encoding, description };
return encoding;
}
if (typeof size === "number") {
return fixEncoder(encoding, size, description);
return fixEncoder(encoding, size);
}
return {
description,
encode: (value) => {
const contentBytes = encoding.encode(value);
const lengthBytes = size.encode(contentBytes.length);
return mergeBytes([lengthBytes, contentBytes]);
return createEncoder({
getSizeFromValue: (value) => {
const contentSize = getEncodedSize(value, encoding);
return getEncodedSize(contentSize, size) + contentSize;
},
fixedSize: null,
maxSize: null
};
};
var getStringDecoder = (options = {}) => {
const size = options.size ?? getU32Decoder();
const encoding = options.encoding ?? getUtf8Decoder();
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
write: (value, bytes, offset) => {
const contentSize = getEncodedSize(value, encoding);
offset = size.write(contentSize, bytes, offset);
return encoding.write(value, bytes, offset);
}
});
}
function getStringDecoder(config = {}) {
const size = config.size ?? getU32Decoder();
const encoding = config.encoding ?? getUtf8Decoder();
if (size === "variable") {
return { ...encoding, description };
return encoding;
}
if (typeof size === "number") {
return fixDecoder(encoding, size, description);
return fixDecoder(encoding, size);
}
return {
decode: (bytes, offset = 0) => {
return createDecoder({
read: (bytes, offset = 0) => {
assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
const [lengthBigInt, lengthOffset] = size.read(bytes, offset);
const length = Number(lengthBigInt);

@@ -265,15 +264,11 @@ offset = lengthOffset;

assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
const [value, contentOffset] = encoding.decode(contentBytes);
const [value, contentOffset] = encoding.read(contentBytes, 0);
offset += contentOffset;
return [value, offset];
},
description,
fixedSize: null,
maxSize: null
};
};
var getStringCodec = (options = {}) => combineCodec(getStringEncoder(options), getStringDecoder(options));
function getSizeDescription(size) {
return typeof size === "object" ? size.description : `${size}`;
}
});
}
function getStringCodec(config = {}) {
return combineCodec(getStringEncoder(config), getStringDecoder(config));
}

@@ -280,0 +275,0 @@ export { assertValidBaseString, getBase10Codec, getBase10Decoder, getBase10Encoder, getBase16Codec, getBase16Decoder, getBase16Encoder, getBase58Codec, getBase58Decoder, getBase58Encoder, getBase64Codec, getBase64Decoder, getBase64Encoder, getBaseXCodec, getBaseXDecoder, getBaseXEncoder, getBaseXResliceCodec, getBaseXResliceDecoder, getBaseXResliceEncoder, getStringCodec, getStringDecoder, getStringEncoder, getUtf8Codec, getUtf8Decoder, getUtf8Encoder, padNullCharacters, removeNullCharacters };

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

import { combineCodec, mapEncoder, mapDecoder, fixEncoder, mergeBytes, fixDecoder, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';
import { createEncoder, createDecoder, combineCodec, mapEncoder, mapDecoder, fixEncoder, getEncodedSize, fixDecoder, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';
import { getU32Encoder, getU32Decoder } from '@solana/codecs-numbers';

@@ -11,23 +11,20 @@

var getBaseXEncoder = (alphabet4) => {
const base = alphabet4.length;
const baseBigInt = BigInt(base);
return {
description: `base${base}`,
encode(value) {
return createEncoder({
getSizeFromValue: (value) => {
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
if (tailChars === "")
return value.length;
const base10Number = getBigIntFromBaseX(tailChars, alphabet4);
return leadingZeroes.length + Math.ceil(base10Number.toString(16).length / 2);
},
write(value, bytes, offset) {
assertValidBaseString(alphabet4, value);
if (value === "")
return new Uint8Array();
const chars = [...value];
let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
const leadingZeroes = Array(trailIndex).fill(0);
if (trailIndex === chars.length)
return Uint8Array.from(leadingZeroes);
const tailChars = chars.slice(trailIndex);
let base10Number = 0n;
let baseXPower = 1n;
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
baseXPower *= baseBigInt;
return offset;
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
if (tailChars === "") {
bytes.set(new Uint8Array(leadingZeroes.length).fill(0), offset);
return offset + leadingZeroes.length;
}
let base10Number = getBigIntFromBaseX(tailChars, alphabet4);
const tailBytes = [];

@@ -38,13 +35,11 @@ while (base10Number > 0n) {

}
return Uint8Array.from(leadingZeroes.concat(tailBytes));
},
fixedSize: null,
maxSize: null
};
const bytesToAdd = [...Array(leadingZeroes.length).fill(0), ...tailBytes];
bytes.set(bytesToAdd, offset);
return offset + bytesToAdd.length;
}
});
};
var getBaseXDecoder = (alphabet4) => {
const base = alphabet4.length;
const baseBigInt = BigInt(base);
return {
decode(rawBytes, offset = 0) {
return createDecoder({
read(rawBytes, offset) {
const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);

@@ -58,16 +53,26 @@ if (bytes.length === 0)

return [leadingZeroes, rawBytes.length];
let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
const tailChars = [];
while (base10Number > 0n) {
tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
base10Number /= baseBigInt;
}
return [leadingZeroes + tailChars.join(""), rawBytes.length];
},
description: `base${base}`,
fixedSize: null,
maxSize: null
};
const base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
const tailChars = getBaseXFromBigInt(base10Number, alphabet4);
return [leadingZeroes + tailChars, rawBytes.length];
}
});
};
var getBaseXCodec = (alphabet4) => combineCodec(getBaseXEncoder(alphabet4), getBaseXDecoder(alphabet4));
function partitionLeadingZeroes(value, zeroCharacter) {
const leadingZeroIndex = [...value].findIndex((c) => c !== zeroCharacter);
return leadingZeroIndex === -1 ? [value, ""] : [value.slice(0, leadingZeroIndex), value.slice(leadingZeroIndex)];
}
function getBigIntFromBaseX(value, alphabet4) {
const base = BigInt(alphabet4.length);
return [...value].reduce((sum, char) => sum * base + BigInt(alphabet4.indexOf(char)), 0n);
}
function getBaseXFromBigInt(value, alphabet4) {
const base = BigInt(alphabet4.length);
const tailChars = [];
while (value > 0n) {
tailChars.unshift(alphabet4[Number(value % base)]);
value /= base;
}
return tailChars.join("");
}

@@ -79,21 +84,18 @@ // src/base10.ts

var getBase10Codec = () => getBaseXCodec(alphabet);
var getBase16Encoder = () => ({
description: "base16",
encode(value) {
var getBase16Encoder = () => createEncoder({
getSizeFromValue: (value) => Math.ceil(value.length / 2),
write(value, bytes, offset) {
const lowercaseValue = value.toLowerCase();
assertValidBaseString("0123456789abcdef", lowercaseValue, value);
const matches = lowercaseValue.match(/.{1,2}/g);
return Uint8Array.from(matches ? matches.map((byte) => parseInt(byte, 16)) : []);
},
fixedSize: null,
maxSize: null
const hexBytes = matches ? matches.map((byte) => parseInt(byte, 16)) : [];
bytes.set(hexBytes, offset);
return hexBytes.length + offset;
}
});
var getBase16Decoder = () => ({
decode(bytes, offset = 0) {
var getBase16Decoder = () => createDecoder({
read(bytes, offset) {
const value = bytes.slice(offset).reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
return [value, bytes.length];
},
description: "base16",
fixedSize: null,
maxSize: null
}
});

@@ -107,16 +109,16 @@ var getBase16Codec = () => combineCodec(getBase16Encoder(), getBase16Decoder());

var getBase58Codec = () => getBaseXCodec(alphabet2);
var getBaseXResliceEncoder = (alphabet4, bits) => ({
description: `base${alphabet4.length}`,
encode(value) {
var getBaseXResliceEncoder = (alphabet4, bits) => createEncoder({
getSizeFromValue: (value) => Math.floor(value.length * bits / 8),
write(value, bytes, offset) {
assertValidBaseString(alphabet4, value);
if (value === "")
return new Uint8Array();
return offset;
const charIndices = [...value].map((c) => alphabet4.indexOf(c));
return new Uint8Array(reslice(charIndices, bits, 8, false));
},
fixedSize: null,
maxSize: null
const reslicedBytes = reslice(charIndices, bits, 8, false);
bytes.set(reslicedBytes, offset);
return reslicedBytes.length + offset;
}
});
var getBaseXResliceDecoder = (alphabet4, bits) => ({
decode(rawBytes, offset = 0) {
var getBaseXResliceDecoder = (alphabet4, bits) => createDecoder({
read(rawBytes, offset = 0) {
const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);

@@ -127,6 +129,3 @@ if (bytes.length === 0)

return [charIndices.map((i) => alphabet4[i]).join(""), rawBytes.length];
},
description: `base${alphabet4.length}`,
fixedSize: null,
maxSize: null
}
});

@@ -180,20 +179,19 @@ var getBaseXResliceCodec = (alphabet4, bits) => combineCodec(getBaseXResliceEncoder(alphabet4, bits), getBaseXResliceDecoder(alphabet4, bits));

let textEncoder;
return {
description: "utf8",
encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
fixedSize: null,
maxSize: null
};
return createEncoder({
getSizeFromValue: (value) => (textEncoder ||= new o()).encode(value).length,
write: (value, bytes, offset) => {
const bytesToAdd = (textEncoder ||= new o()).encode(value);
bytes.set(bytesToAdd, offset);
return offset + bytesToAdd.length;
}
});
};
var getUtf8Decoder = () => {
let textDecoder;
return {
decode(bytes, offset = 0) {
const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
return createDecoder({
read(bytes, offset) {
const value = (textDecoder ||= new e()).decode(bytes.slice(offset));
return [removeNullCharacters(value), bytes.length];
},
description: "utf8",
fixedSize: null,
maxSize: null
};
}
});
};

@@ -203,37 +201,36 @@ var getUtf8Codec = () => combineCodec(getUtf8Encoder(), getUtf8Decoder());

// src/string.ts
var getStringEncoder = (options = {}) => {
const size = options.size ?? getU32Encoder();
const encoding = options.encoding ?? getUtf8Encoder();
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
function getStringEncoder(config = {}) {
const size = config.size ?? getU32Encoder();
const encoding = config.encoding ?? getUtf8Encoder();
if (size === "variable") {
return { ...encoding, description };
return encoding;
}
if (typeof size === "number") {
return fixEncoder(encoding, size, description);
return fixEncoder(encoding, size);
}
return {
description,
encode: (value) => {
const contentBytes = encoding.encode(value);
const lengthBytes = size.encode(contentBytes.length);
return mergeBytes([lengthBytes, contentBytes]);
return createEncoder({
getSizeFromValue: (value) => {
const contentSize = getEncodedSize(value, encoding);
return getEncodedSize(contentSize, size) + contentSize;
},
fixedSize: null,
maxSize: null
};
};
var getStringDecoder = (options = {}) => {
const size = options.size ?? getU32Decoder();
const encoding = options.encoding ?? getUtf8Decoder();
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
write: (value, bytes, offset) => {
const contentSize = getEncodedSize(value, encoding);
offset = size.write(contentSize, bytes, offset);
return encoding.write(value, bytes, offset);
}
});
}
function getStringDecoder(config = {}) {
const size = config.size ?? getU32Decoder();
const encoding = config.encoding ?? getUtf8Decoder();
if (size === "variable") {
return { ...encoding, description };
return encoding;
}
if (typeof size === "number") {
return fixDecoder(encoding, size, description);
return fixDecoder(encoding, size);
}
return {
decode: (bytes, offset = 0) => {
return createDecoder({
read: (bytes, offset = 0) => {
assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
const [lengthBigInt, lengthOffset] = size.read(bytes, offset);
const length = Number(lengthBigInt);

@@ -243,15 +240,11 @@ offset = lengthOffset;

assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
const [value, contentOffset] = encoding.decode(contentBytes);
const [value, contentOffset] = encoding.read(contentBytes, 0);
offset += contentOffset;
return [value, offset];
},
description,
fixedSize: null,
maxSize: null
};
};
var getStringCodec = (options = {}) => combineCodec(getStringEncoder(options), getStringDecoder(options));
function getSizeDescription(size) {
return typeof size === "object" ? size.description : `${size}`;
}
});
}
function getStringCodec(config = {}) {
return combineCodec(getStringEncoder(config), getStringDecoder(config));
}

@@ -258,0 +251,0 @@ export { assertValidBaseString, getBase10Codec, getBase10Decoder, getBase10Encoder, getBase16Codec, getBase16Decoder, getBase16Encoder, getBase58Codec, getBase58Decoder, getBase58Encoder, getBase64Codec, getBase64Decoder, getBase64Encoder, getBaseXCodec, getBaseXDecoder, getBaseXEncoder, getBaseXResliceCodec, getBaseXResliceDecoder, getBaseXResliceEncoder, getStringCodec, getStringDecoder, getStringEncoder, getUtf8Codec, getUtf8Decoder, getUtf8Encoder, padNullCharacters, removeNullCharacters };

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

import { combineCodec, fixEncoder, mergeBytes, fixDecoder, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';
import { createEncoder, createDecoder, combineCodec, fixEncoder, getEncodedSize, fixDecoder, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';
import { getU32Encoder, getU32Decoder } from '@solana/codecs-numbers';

@@ -11,23 +11,20 @@

var getBaseXEncoder = (alphabet4) => {
const base = alphabet4.length;
const baseBigInt = BigInt(base);
return {
description: `base${base}`,
encode(value) {
return createEncoder({
getSizeFromValue: (value) => {
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
if (tailChars === "")
return value.length;
const base10Number = getBigIntFromBaseX(tailChars, alphabet4);
return leadingZeroes.length + Math.ceil(base10Number.toString(16).length / 2);
},
write(value, bytes, offset) {
assertValidBaseString(alphabet4, value);
if (value === "")
return new Uint8Array();
const chars = [...value];
let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
const leadingZeroes = Array(trailIndex).fill(0);
if (trailIndex === chars.length)
return Uint8Array.from(leadingZeroes);
const tailChars = chars.slice(trailIndex);
let base10Number = 0n;
let baseXPower = 1n;
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
baseXPower *= baseBigInt;
return offset;
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
if (tailChars === "") {
bytes.set(new Uint8Array(leadingZeroes.length).fill(0), offset);
return offset + leadingZeroes.length;
}
let base10Number = getBigIntFromBaseX(tailChars, alphabet4);
const tailBytes = [];

@@ -38,13 +35,11 @@ while (base10Number > 0n) {

}
return Uint8Array.from(leadingZeroes.concat(tailBytes));
},
fixedSize: null,
maxSize: null
};
const bytesToAdd = [...Array(leadingZeroes.length).fill(0), ...tailBytes];
bytes.set(bytesToAdd, offset);
return offset + bytesToAdd.length;
}
});
};
var getBaseXDecoder = (alphabet4) => {
const base = alphabet4.length;
const baseBigInt = BigInt(base);
return {
decode(rawBytes, offset = 0) {
return createDecoder({
read(rawBytes, offset) {
const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);

@@ -58,16 +53,26 @@ if (bytes.length === 0)

return [leadingZeroes, rawBytes.length];
let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
const tailChars = [];
while (base10Number > 0n) {
tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
base10Number /= baseBigInt;
}
return [leadingZeroes + tailChars.join(""), rawBytes.length];
},
description: `base${base}`,
fixedSize: null,
maxSize: null
};
const base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
const tailChars = getBaseXFromBigInt(base10Number, alphabet4);
return [leadingZeroes + tailChars, rawBytes.length];
}
});
};
var getBaseXCodec = (alphabet4) => combineCodec(getBaseXEncoder(alphabet4), getBaseXDecoder(alphabet4));
function partitionLeadingZeroes(value, zeroCharacter) {
const leadingZeroIndex = [...value].findIndex((c) => c !== zeroCharacter);
return leadingZeroIndex === -1 ? [value, ""] : [value.slice(0, leadingZeroIndex), value.slice(leadingZeroIndex)];
}
function getBigIntFromBaseX(value, alphabet4) {
const base = BigInt(alphabet4.length);
return [...value].reduce((sum, char) => sum * base + BigInt(alphabet4.indexOf(char)), 0n);
}
function getBaseXFromBigInt(value, alphabet4) {
const base = BigInt(alphabet4.length);
const tailChars = [];
while (value > 0n) {
tailChars.unshift(alphabet4[Number(value % base)]);
value /= base;
}
return tailChars.join("");
}

@@ -79,21 +84,18 @@ // src/base10.ts

var getBase10Codec = () => getBaseXCodec(alphabet);
var getBase16Encoder = () => ({
description: "base16",
encode(value) {
var getBase16Encoder = () => createEncoder({
getSizeFromValue: (value) => Math.ceil(value.length / 2),
write(value, bytes, offset) {
const lowercaseValue = value.toLowerCase();
assertValidBaseString("0123456789abcdef", lowercaseValue, value);
const matches = lowercaseValue.match(/.{1,2}/g);
return Uint8Array.from(matches ? matches.map((byte) => parseInt(byte, 16)) : []);
},
fixedSize: null,
maxSize: null
const hexBytes = matches ? matches.map((byte) => parseInt(byte, 16)) : [];
bytes.set(hexBytes, offset);
return hexBytes.length + offset;
}
});
var getBase16Decoder = () => ({
decode(bytes, offset = 0) {
var getBase16Decoder = () => createDecoder({
read(bytes, offset) {
const value = bytes.slice(offset).reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
return [value, bytes.length];
},
description: "base16",
fixedSize: null,
maxSize: null
}
});

@@ -107,16 +109,16 @@ var getBase16Codec = () => combineCodec(getBase16Encoder(), getBase16Decoder());

var getBase58Codec = () => getBaseXCodec(alphabet2);
var getBaseXResliceEncoder = (alphabet4, bits) => ({
description: `base${alphabet4.length}`,
encode(value) {
var getBaseXResliceEncoder = (alphabet4, bits) => createEncoder({
getSizeFromValue: (value) => Math.floor(value.length * bits / 8),
write(value, bytes, offset) {
assertValidBaseString(alphabet4, value);
if (value === "")
return new Uint8Array();
return offset;
const charIndices = [...value].map((c) => alphabet4.indexOf(c));
return new Uint8Array(reslice(charIndices, bits, 8, false));
},
fixedSize: null,
maxSize: null
const reslicedBytes = reslice(charIndices, bits, 8, false);
bytes.set(reslicedBytes, offset);
return reslicedBytes.length + offset;
}
});
var getBaseXResliceDecoder = (alphabet4, bits) => ({
decode(rawBytes, offset = 0) {
var getBaseXResliceDecoder = (alphabet4, bits) => createDecoder({
read(rawBytes, offset = 0) {
const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);

@@ -127,6 +129,3 @@ if (bytes.length === 0)

return [charIndices.map((i) => alphabet4[i]).join(""), rawBytes.length];
},
description: `base${alphabet4.length}`,
fixedSize: null,
maxSize: null
}
});

@@ -157,11 +156,11 @@ var getBaseXResliceCodec = (alphabet4, bits) => combineCodec(getBaseXResliceEncoder(alphabet4, bits), getBaseXResliceDecoder(alphabet4, bits));

{
return {
description: `base64`,
encode(value) {
return createEncoder({
getSizeFromValue: (value) => Buffer.from(value, "base64").length,
write(value, bytes, offset) {
assertValidBaseString(alphabet3, value.replace(/=/g, ""));
return new Uint8Array(Buffer.from(value, "base64"));
},
fixedSize: null,
maxSize: null
};
const buffer = Buffer.from(value, "base64");
bytes.set(buffer, offset);
return buffer.length + offset;
}
});
}

@@ -171,8 +170,5 @@ };

{
return {
decode: (bytes, offset = 0) => [Buffer.from(bytes, offset).toString("base64"), bytes.length],
description: `base64`,
fixedSize: null,
maxSize: null
};
return createDecoder({
read: (bytes, offset = 0) => [Buffer.from(bytes, offset).toString("base64"), bytes.length]
});
}

@@ -196,20 +192,19 @@ };

let textEncoder;
return {
description: "utf8",
encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
fixedSize: null,
maxSize: null
};
return createEncoder({
getSizeFromValue: (value) => (textEncoder ||= new o()).encode(value).length,
write: (value, bytes, offset) => {
const bytesToAdd = (textEncoder ||= new o()).encode(value);
bytes.set(bytesToAdd, offset);
return offset + bytesToAdd.length;
}
});
};
var getUtf8Decoder = () => {
let textDecoder;
return {
decode(bytes, offset = 0) {
const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
return createDecoder({
read(bytes, offset) {
const value = (textDecoder ||= new e()).decode(bytes.slice(offset));
return [removeNullCharacters(value), bytes.length];
},
description: "utf8",
fixedSize: null,
maxSize: null
};
}
});
};

@@ -219,37 +214,36 @@ var getUtf8Codec = () => combineCodec(getUtf8Encoder(), getUtf8Decoder());

// src/string.ts
var getStringEncoder = (options = {}) => {
const size = options.size ?? getU32Encoder();
const encoding = options.encoding ?? getUtf8Encoder();
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
function getStringEncoder(config = {}) {
const size = config.size ?? getU32Encoder();
const encoding = config.encoding ?? getUtf8Encoder();
if (size === "variable") {
return { ...encoding, description };
return encoding;
}
if (typeof size === "number") {
return fixEncoder(encoding, size, description);
return fixEncoder(encoding, size);
}
return {
description,
encode: (value) => {
const contentBytes = encoding.encode(value);
const lengthBytes = size.encode(contentBytes.length);
return mergeBytes([lengthBytes, contentBytes]);
return createEncoder({
getSizeFromValue: (value) => {
const contentSize = getEncodedSize(value, encoding);
return getEncodedSize(contentSize, size) + contentSize;
},
fixedSize: null,
maxSize: null
};
};
var getStringDecoder = (options = {}) => {
const size = options.size ?? getU32Decoder();
const encoding = options.encoding ?? getUtf8Decoder();
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
write: (value, bytes, offset) => {
const contentSize = getEncodedSize(value, encoding);
offset = size.write(contentSize, bytes, offset);
return encoding.write(value, bytes, offset);
}
});
}
function getStringDecoder(config = {}) {
const size = config.size ?? getU32Decoder();
const encoding = config.encoding ?? getUtf8Decoder();
if (size === "variable") {
return { ...encoding, description };
return encoding;
}
if (typeof size === "number") {
return fixDecoder(encoding, size, description);
return fixDecoder(encoding, size);
}
return {
decode: (bytes, offset = 0) => {
return createDecoder({
read: (bytes, offset = 0) => {
assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
const [lengthBigInt, lengthOffset] = size.read(bytes, offset);
const length = Number(lengthBigInt);

@@ -259,16 +253,14 @@ offset = lengthOffset;

assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
const [value, contentOffset] = encoding.decode(contentBytes);
const [value, contentOffset] = encoding.read(contentBytes, 0);
offset += contentOffset;
return [value, offset];
},
description,
fixedSize: null,
maxSize: null
};
};
var getStringCodec = (options = {}) => combineCodec(getStringEncoder(options), getStringDecoder(options));
function getSizeDescription(size) {
return typeof size === "object" ? size.description : `${size}`;
}
});
}
function getStringCodec(config = {}) {
return combineCodec(getStringEncoder(config), getStringDecoder(config));
}
export { assertValidBaseString, getBase10Codec, getBase10Decoder, getBase10Encoder, getBase16Codec, getBase16Decoder, getBase16Encoder, getBase58Codec, getBase58Decoder, getBase58Encoder, getBase64Codec, getBase64Decoder, getBase64Encoder, getBaseXCodec, getBaseXDecoder, getBaseXEncoder, getBaseXResliceCodec, getBaseXResliceDecoder, getBaseXResliceEncoder, getStringCodec, getStringDecoder, getStringEncoder, getUtf8Codec, getUtf8Decoder, getUtf8Encoder, padNullCharacters, removeNullCharacters };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.node.js.map
/** Encodes strings in base10. */
export declare const getBase10Encoder: () => import("@solana/codecs-core").Encoder<string>;
export declare const getBase10Encoder: () => import("@solana/codecs-core").VariableSizeEncoder<string>;
/** Decodes strings in base10. */
export declare const getBase10Decoder: () => import("@solana/codecs-core").Decoder<string>;
export declare const getBase10Decoder: () => import("@solana/codecs-core").VariableSizeDecoder<string>;
/** Encodes and decodes strings in base10. */
export declare const getBase10Codec: () => import("@solana/codecs-core").Codec<string>;
export declare const getBase10Codec: () => import("@solana/codecs-core").VariableSizeCodec<string>;
//# sourceMappingURL=base10.d.ts.map

@@ -1,8 +0,8 @@

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
/** Encodes strings in base16. */
export declare const getBase16Encoder: () => Encoder<string>;
export declare const getBase16Encoder: () => VariableSizeEncoder<string>;
/** Decodes strings in base16. */
export declare const getBase16Decoder: () => Decoder<string>;
export declare const getBase16Decoder: () => VariableSizeDecoder<string>;
/** Encodes and decodes strings in base16. */
export declare const getBase16Codec: () => Codec<string>;
export declare const getBase16Codec: () => VariableSizeCodec<string>;
//# sourceMappingURL=base16.d.ts.map
/** Encodes strings in base58. */
export declare const getBase58Encoder: () => import("@solana/codecs-core").Encoder<string>;
export declare const getBase58Encoder: () => import("@solana/codecs-core").VariableSizeEncoder<string>;
/** Decodes strings in base58. */
export declare const getBase58Decoder: () => import("@solana/codecs-core").Decoder<string>;
export declare const getBase58Decoder: () => import("@solana/codecs-core").VariableSizeDecoder<string>;
/** Encodes and decodes strings in base58. */
export declare const getBase58Codec: () => import("@solana/codecs-core").Codec<string>;
export declare const getBase58Codec: () => import("@solana/codecs-core").VariableSizeCodec<string>;
//# sourceMappingURL=base58.d.ts.map

@@ -1,8 +0,8 @@

import { Decoder, Encoder } from '@solana/codecs-core';
import { VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
/** Encodes strings in base64. */
export declare const getBase64Encoder: () => Encoder<string>;
export declare const getBase64Encoder: () => VariableSizeEncoder<string>;
/** Decodes strings in base64. */
export declare const getBase64Decoder: () => Decoder<string>;
export declare const getBase64Decoder: () => VariableSizeDecoder<string>;
/** Encodes and decodes strings in base64. */
export declare const getBase64Codec: () => import("@solana/codecs-core").Codec<string, string>;
export declare const getBase64Codec: () => VariableSizeCodec<string>;
//# sourceMappingURL=base64.d.ts.map

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

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
/**

@@ -6,3 +6,3 @@ * Encodes a string using a custom alphabet by reslicing the bits of the byte array.

*/
export declare const getBaseXResliceEncoder: (alphabet: string, bits: number) => Encoder<string>;
export declare const getBaseXResliceEncoder: (alphabet: string, bits: number) => VariableSizeEncoder<string>;
/**

@@ -12,3 +12,3 @@ * Decodes a string using a custom alphabet by reslicing the bits of the byte array.

*/
export declare const getBaseXResliceDecoder: (alphabet: string, bits: number) => Decoder<string>;
export declare const getBaseXResliceDecoder: (alphabet: string, bits: number) => VariableSizeDecoder<string>;
/**

@@ -21,3 +21,3 @@ * A string serializer that reslices bytes into custom chunks

*/
export declare const getBaseXResliceCodec: (alphabet: string, bits: number) => Codec<string>;
export declare const getBaseXResliceCodec: (alphabet: string, bits: number) => VariableSizeCodec<string>;
//# sourceMappingURL=baseX-reslice.d.ts.map

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

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
/**

@@ -7,3 +7,3 @@ * Encodes a string using a custom alphabet by dividing

*/
export declare const getBaseXEncoder: (alphabet: string) => Encoder<string>;
export declare const getBaseXEncoder: (alphabet: string) => VariableSizeEncoder<string>;
/**

@@ -14,3 +14,3 @@ * Decodes a string using a custom alphabet by dividing

*/
export declare const getBaseXDecoder: (alphabet: string) => Decoder<string>;
export declare const getBaseXDecoder: (alphabet: string) => VariableSizeDecoder<string>;
/**

@@ -25,3 +25,3 @@ * A string codec that requires a custom alphabet and uses

*/
export declare const getBaseXCodec: (alphabet: string) => Codec<string>;
export declare const getBaseXCodec: (alphabet: string) => VariableSizeCodec<string>;
//# sourceMappingURL=baseX.d.ts.map

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

export * from './assertions';
export * from './base10';
export * from './base16';
export * from './base58';
export * from './base64';
export * from './baseX';
export * from './baseX-reslice';
export * from './null-characters';
export * from './string';
export * from './utf8';
export * from './assertions.js';
export * from './base10.js';
export * from './base16.js';
export * from './base58.js';
export * from './base64.js';
export * from './baseX.js';
export * from './baseX-reslice.js';
export * from './null-characters.js';
export * from './string.js';
export * from './utf8.js';
//# sourceMappingURL=index.d.ts.map

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

import { BaseCodecOptions, Codec, Decoder, Encoder } from '@solana/codecs-core';
import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
import { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';
/** Defines the options for string codecs. */
export type StringCodecOptions<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder, TEncoding extends Codec<string> | Encoder<string> | Decoder<string>> = BaseCodecOptions & {
/** Defines the config for string codecs. */
export type StringCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder, TEncoding extends Codec<string> | Encoder<string> | Decoder<string>> = {
/**

@@ -20,7 +20,28 @@ * The size of the string. It can be one of the following:

/** Encodes strings from a given encoding and size strategy. */
export declare const getStringEncoder: (options?: StringCodecOptions<NumberEncoder, Encoder<string>>) => Encoder<string>;
export declare function getStringEncoder<TSize extends number>(config: StringCodecConfig<NumberEncoder, Encoder<string>> & {
size: TSize;
}): FixedSizeEncoder<string, TSize>;
export declare function getStringEncoder<TSize extends number>(config: StringCodecConfig<NumberEncoder, Encoder<string>> & {
size: 'variable';
encoding: FixedSizeEncoder<string, TSize>;
}): FixedSizeEncoder<string, TSize>;
export declare function getStringEncoder(config?: StringCodecConfig<NumberEncoder, Encoder<string>>): VariableSizeEncoder<string>;
/** Decodes strings from a given encoding and size strategy. */
export declare const getStringDecoder: (options?: StringCodecOptions<NumberDecoder, Decoder<string>>) => Decoder<string>;
export declare function getStringDecoder<TSize extends number>(config: StringCodecConfig<NumberDecoder, Decoder<string>> & {
size: TSize;
}): FixedSizeDecoder<string, TSize>;
export declare function getStringDecoder<TSize extends number>(config: StringCodecConfig<NumberDecoder, Decoder<string>> & {
size: 'variable';
encoding: FixedSizeDecoder<string, TSize>;
}): FixedSizeDecoder<string, TSize>;
export declare function getStringDecoder(config?: StringCodecConfig<NumberDecoder, Decoder<string>>): VariableSizeDecoder<string>;
/** Encodes and decodes strings from a given encoding and size strategy. */
export declare const getStringCodec: (options?: StringCodecOptions<NumberCodec, Codec<string>>) => Codec<string>;
export declare function getStringCodec<TSize extends number>(config: StringCodecConfig<NumberCodec, Codec<string>> & {
size: TSize;
}): FixedSizeCodec<string, string, TSize>;
export declare function getStringCodec<TSize extends number>(config: StringCodecConfig<NumberCodec, Codec<string>> & {
size: 'variable';
encoding: FixedSizeCodec<string, string, TSize>;
}): FixedSizeCodec<string, string, TSize>;
export declare function getStringCodec(config?: StringCodecConfig<NumberCodec, Codec<string>>): VariableSizeCodec<string>;
//# sourceMappingURL=string.d.ts.map

@@ -1,8 +0,8 @@

import { Codec, Decoder, Encoder } from '@solana/codecs-core';
import { Codec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
/** Encodes UTF-8 strings using the native `TextEncoder` API. */
export declare const getUtf8Encoder: () => Encoder<string>;
export declare const getUtf8Encoder: () => VariableSizeEncoder<string>;
/** Decodes UTF-8 strings using the native `TextDecoder` API. */
export declare const getUtf8Decoder: () => Decoder<string>;
export declare const getUtf8Decoder: () => VariableSizeDecoder<string>;
/** Encodes and decodes UTF-8 strings using the native `TextEncoder` and `TextDecoder` API. */
export declare const getUtf8Codec: () => Codec<string>;
//# sourceMappingURL=utf8.d.ts.map
{
"name": "@solana/codecs-strings",
"version": "2.0.0-experimental.2938d71",
"version": "2.0.0-experimental.2962a3f",
"description": "Codecs for strings of different sizes and encodings",

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

"dependencies": {
"@solana/codecs-core": "2.0.0-experimental.2938d71",
"@solana/codecs-numbers": "2.0.0-experimental.2938d71"
"@solana/codecs-core": "2.0.0-experimental.2962a3f",
"@solana/codecs-numbers": "2.0.0-experimental.2962a3f"
},

@@ -59,4 +59,5 @@ "devDependencies": {

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

@@ -71,4 +72,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",

@@ -93,4 +94,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",

@@ -97,0 +98,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

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