@solana/options
Advanced tools
Comparing version 2.0.0-experimental.c237089 to 2.0.0-experimental.c42ccfd
@@ -1,2 +0,2 @@ | ||
import { fixBytes, mergeBytes, combineCodec, assertFixedSizeCodec } from '@solana/codecs-core'; | ||
import { isFixedSize, assertIsFixedSize, createEncoder, getEncodedSize, createDecoder, combineCodec } from '@solana/codecs-core'; | ||
import { getU8Encoder, getU8Decoder } from '@solana/codecs-numbers'; | ||
@@ -20,58 +20,72 @@ | ||
// src/option-codec.ts | ||
function sumCodecSizes(sizes) { | ||
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0); | ||
} | ||
function optionCodecHelper(item, prefix, fixed, description) { | ||
let descriptionSuffix = `; ${prefix.description}`; | ||
let fixedSize = item.fixedSize === 0 ? prefix.fixedSize : null; | ||
if (fixed) { | ||
assertFixedSizeCodec(item, "Fixed options can only be used with fixed-size codecs."); | ||
assertFixedSizeCodec(prefix, "Fixed options can only be used with fixed-size prefix."); | ||
descriptionSuffix += "; fixed"; | ||
fixedSize = prefix.fixedSize + item.fixedSize; | ||
function getOptionEncoder(item, config = {}) { | ||
const prefix = config.prefix ?? getU8Encoder(); | ||
const fixed = config.fixed ?? false; | ||
const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0; | ||
if (fixed || isZeroSizeItem) { | ||
assertIsFixedSize(item, "Fixed options can only be used with fixed-size codecs."); | ||
assertIsFixedSize(prefix, "Fixed options can only be used with fixed-size prefix."); | ||
const fixedSize = prefix.fixedSize + item.fixedSize; | ||
return createEncoder({ | ||
fixedSize, | ||
write: (optionOrNullable, bytes, offset) => { | ||
const option = isOption(optionOrNullable) ? optionOrNullable : wrapNullable(optionOrNullable); | ||
const prefixOffset = prefix.write(Number(isSome(option)), bytes, offset); | ||
if (isSome(option)) { | ||
item.write(option.value, bytes, prefixOffset); | ||
} | ||
return offset + fixedSize; | ||
} | ||
}); | ||
} | ||
return { | ||
description: description ?? `option(${item.description + descriptionSuffix})`, | ||
fixedSize, | ||
maxSize: sumCodecSizes([prefix.maxSize, item.maxSize]) | ||
}; | ||
} | ||
function getOptionEncoder(item, options = {}) { | ||
const prefix = options.prefix ?? getU8Encoder(); | ||
const fixed = options.fixed ?? false; | ||
return { | ||
...optionCodecHelper(item, prefix, fixed, options.description), | ||
encode: (optionOrNullable) => { | ||
return createEncoder({ | ||
getSizeFromValue: (optionOrNullable) => { | ||
const option = isOption(optionOrNullable) ? optionOrNullable : wrapNullable(optionOrNullable); | ||
const prefixByte = prefix.encode(Number(isSome(option))); | ||
let itemBytes = isSome(option) ? item.encode(option.value) : new Uint8Array(); | ||
itemBytes = fixed ? fixBytes(itemBytes, item.fixedSize) : itemBytes; | ||
return mergeBytes([prefixByte, itemBytes]); | ||
return getEncodedSize(Number(isSome(option)), prefix) + (isSome(option) ? getEncodedSize(option.value, item) : 0); | ||
}, | ||
maxSize: sumCodecSizes([prefix, item].map(getMaxSize)) ?? void 0, | ||
write: (optionOrNullable, bytes, offset) => { | ||
const option = isOption(optionOrNullable) ? optionOrNullable : wrapNullable(optionOrNullable); | ||
offset = prefix.write(Number(isSome(option)), bytes, offset); | ||
if (isSome(option)) { | ||
offset = item.write(option.value, bytes, offset); | ||
} | ||
return offset; | ||
} | ||
}; | ||
}); | ||
} | ||
function getOptionDecoder(item, options = {}) { | ||
const prefix = options.prefix ?? getU8Decoder(); | ||
const fixed = options.fixed ?? false; | ||
return { | ||
...optionCodecHelper(item, prefix, fixed, options.description), | ||
decode: (bytes, offset = 0) => { | ||
function getOptionDecoder(item, config = {}) { | ||
const prefix = config.prefix ?? getU8Decoder(); | ||
const fixed = config.fixed ?? false; | ||
let fixedSize = null; | ||
const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0; | ||
if (fixed || isZeroSizeItem) { | ||
assertIsFixedSize(item, "Fixed options can only be used with fixed-size codecs."); | ||
assertIsFixedSize(prefix, "Fixed options can only be used with fixed-size prefix."); | ||
fixedSize = prefix.fixedSize + item.fixedSize; | ||
} | ||
return createDecoder({ | ||
...fixedSize === null ? { maxSize: sumCodecSizes([prefix, item].map(getMaxSize)) ?? void 0 } : { fixedSize }, | ||
read: (bytes, offset) => { | ||
if (bytes.length - offset <= 0) { | ||
return [none(), offset]; | ||
} | ||
const fixedOffset = offset + (prefix.fixedSize ?? 0) + (item.fixedSize ?? 0); | ||
const [isSome2, prefixOffset] = prefix.decode(bytes, offset); | ||
offset = prefixOffset; | ||
const [isSome2, prefixOffset] = prefix.read(bytes, offset); | ||
if (isSome2 === 0) { | ||
return [none(), fixed ? fixedOffset : offset]; | ||
return [none(), fixedSize !== null ? offset + fixedSize : prefixOffset]; | ||
} | ||
const [value, newOffset] = item.decode(bytes, offset); | ||
offset = newOffset; | ||
return [some(value), fixed ? fixedOffset : offset]; | ||
const [value, newOffset] = item.read(bytes, prefixOffset); | ||
return [some(value), fixedSize !== null ? offset + fixedSize : newOffset]; | ||
} | ||
}; | ||
}); | ||
} | ||
function getOptionCodec(item, options = {}) { | ||
return combineCodec(getOptionEncoder(item, options), getOptionDecoder(item, options)); | ||
function getOptionCodec(item, config = {}) { | ||
return combineCodec(getOptionEncoder(item, config), getOptionDecoder(item, config)); | ||
} | ||
function sumCodecSizes(sizes) { | ||
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0); | ||
} | ||
function getMaxSize(codec) { | ||
return isFixedSize(codec) ? codec.fixedSize : codec.maxSize ?? null; | ||
} | ||
@@ -78,0 +92,0 @@ // src/unwrap-option-recursively.ts |
@@ -1,2 +0,2 @@ | ||
import { fixBytes, mergeBytes, combineCodec, assertFixedSizeCodec } from '@solana/codecs-core'; | ||
import { isFixedSize, assertIsFixedSize, createEncoder, getEncodedSize, createDecoder, combineCodec } from '@solana/codecs-core'; | ||
import { getU8Encoder, getU8Decoder } from '@solana/codecs-numbers'; | ||
@@ -20,58 +20,72 @@ | ||
// src/option-codec.ts | ||
function sumCodecSizes(sizes) { | ||
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0); | ||
} | ||
function optionCodecHelper(item, prefix, fixed, description) { | ||
let descriptionSuffix = `; ${prefix.description}`; | ||
let fixedSize = item.fixedSize === 0 ? prefix.fixedSize : null; | ||
if (fixed) { | ||
assertFixedSizeCodec(item, "Fixed options can only be used with fixed-size codecs."); | ||
assertFixedSizeCodec(prefix, "Fixed options can only be used with fixed-size prefix."); | ||
descriptionSuffix += "; fixed"; | ||
fixedSize = prefix.fixedSize + item.fixedSize; | ||
function getOptionEncoder(item, config = {}) { | ||
const prefix = config.prefix ?? getU8Encoder(); | ||
const fixed = config.fixed ?? false; | ||
const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0; | ||
if (fixed || isZeroSizeItem) { | ||
assertIsFixedSize(item, "Fixed options can only be used with fixed-size codecs."); | ||
assertIsFixedSize(prefix, "Fixed options can only be used with fixed-size prefix."); | ||
const fixedSize = prefix.fixedSize + item.fixedSize; | ||
return createEncoder({ | ||
fixedSize, | ||
write: (optionOrNullable, bytes, offset) => { | ||
const option = isOption(optionOrNullable) ? optionOrNullable : wrapNullable(optionOrNullable); | ||
const prefixOffset = prefix.write(Number(isSome(option)), bytes, offset); | ||
if (isSome(option)) { | ||
item.write(option.value, bytes, prefixOffset); | ||
} | ||
return offset + fixedSize; | ||
} | ||
}); | ||
} | ||
return { | ||
description: description ?? `option(${item.description + descriptionSuffix})`, | ||
fixedSize, | ||
maxSize: sumCodecSizes([prefix.maxSize, item.maxSize]) | ||
}; | ||
} | ||
function getOptionEncoder(item, options = {}) { | ||
const prefix = options.prefix ?? getU8Encoder(); | ||
const fixed = options.fixed ?? false; | ||
return { | ||
...optionCodecHelper(item, prefix, fixed, options.description), | ||
encode: (optionOrNullable) => { | ||
return createEncoder({ | ||
getSizeFromValue: (optionOrNullable) => { | ||
const option = isOption(optionOrNullable) ? optionOrNullable : wrapNullable(optionOrNullable); | ||
const prefixByte = prefix.encode(Number(isSome(option))); | ||
let itemBytes = isSome(option) ? item.encode(option.value) : new Uint8Array(); | ||
itemBytes = fixed ? fixBytes(itemBytes, item.fixedSize) : itemBytes; | ||
return mergeBytes([prefixByte, itemBytes]); | ||
return getEncodedSize(Number(isSome(option)), prefix) + (isSome(option) ? getEncodedSize(option.value, item) : 0); | ||
}, | ||
maxSize: sumCodecSizes([prefix, item].map(getMaxSize)) ?? void 0, | ||
write: (optionOrNullable, bytes, offset) => { | ||
const option = isOption(optionOrNullable) ? optionOrNullable : wrapNullable(optionOrNullable); | ||
offset = prefix.write(Number(isSome(option)), bytes, offset); | ||
if (isSome(option)) { | ||
offset = item.write(option.value, bytes, offset); | ||
} | ||
return offset; | ||
} | ||
}; | ||
}); | ||
} | ||
function getOptionDecoder(item, options = {}) { | ||
const prefix = options.prefix ?? getU8Decoder(); | ||
const fixed = options.fixed ?? false; | ||
return { | ||
...optionCodecHelper(item, prefix, fixed, options.description), | ||
decode: (bytes, offset = 0) => { | ||
function getOptionDecoder(item, config = {}) { | ||
const prefix = config.prefix ?? getU8Decoder(); | ||
const fixed = config.fixed ?? false; | ||
let fixedSize = null; | ||
const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0; | ||
if (fixed || isZeroSizeItem) { | ||
assertIsFixedSize(item, "Fixed options can only be used with fixed-size codecs."); | ||
assertIsFixedSize(prefix, "Fixed options can only be used with fixed-size prefix."); | ||
fixedSize = prefix.fixedSize + item.fixedSize; | ||
} | ||
return createDecoder({ | ||
...fixedSize === null ? { maxSize: sumCodecSizes([prefix, item].map(getMaxSize)) ?? void 0 } : { fixedSize }, | ||
read: (bytes, offset) => { | ||
if (bytes.length - offset <= 0) { | ||
return [none(), offset]; | ||
} | ||
const fixedOffset = offset + (prefix.fixedSize ?? 0) + (item.fixedSize ?? 0); | ||
const [isSome2, prefixOffset] = prefix.decode(bytes, offset); | ||
offset = prefixOffset; | ||
const [isSome2, prefixOffset] = prefix.read(bytes, offset); | ||
if (isSome2 === 0) { | ||
return [none(), fixed ? fixedOffset : offset]; | ||
return [none(), fixedSize !== null ? offset + fixedSize : prefixOffset]; | ||
} | ||
const [value, newOffset] = item.decode(bytes, offset); | ||
offset = newOffset; | ||
return [some(value), fixed ? fixedOffset : offset]; | ||
const [value, newOffset] = item.read(bytes, prefixOffset); | ||
return [some(value), fixedSize !== null ? offset + fixedSize : newOffset]; | ||
} | ||
}; | ||
}); | ||
} | ||
function getOptionCodec(item, options = {}) { | ||
return combineCodec(getOptionEncoder(item, options), getOptionDecoder(item, options)); | ||
function getOptionCodec(item, config = {}) { | ||
return combineCodec(getOptionEncoder(item, config), getOptionDecoder(item, config)); | ||
} | ||
function sumCodecSizes(sizes) { | ||
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0); | ||
} | ||
function getMaxSize(codec) { | ||
return isFixedSize(codec) ? codec.fixedSize : codec.maxSize ?? null; | ||
} | ||
@@ -78,0 +92,0 @@ // src/unwrap-option-recursively.ts |
@@ -1,2 +0,2 @@ | ||
import { fixBytes, mergeBytes, combineCodec, assertFixedSizeCodec } from '@solana/codecs-core'; | ||
import { isFixedSize, assertIsFixedSize, createEncoder, getEncodedSize, createDecoder, combineCodec } from '@solana/codecs-core'; | ||
import { getU8Encoder, getU8Decoder } from '@solana/codecs-numbers'; | ||
@@ -20,58 +20,72 @@ | ||
// src/option-codec.ts | ||
function sumCodecSizes(sizes) { | ||
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0); | ||
} | ||
function optionCodecHelper(item, prefix, fixed, description) { | ||
let descriptionSuffix = `; ${prefix.description}`; | ||
let fixedSize = item.fixedSize === 0 ? prefix.fixedSize : null; | ||
if (fixed) { | ||
assertFixedSizeCodec(item, "Fixed options can only be used with fixed-size codecs."); | ||
assertFixedSizeCodec(prefix, "Fixed options can only be used with fixed-size prefix."); | ||
descriptionSuffix += "; fixed"; | ||
fixedSize = prefix.fixedSize + item.fixedSize; | ||
function getOptionEncoder(item, config = {}) { | ||
const prefix = config.prefix ?? getU8Encoder(); | ||
const fixed = config.fixed ?? false; | ||
const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0; | ||
if (fixed || isZeroSizeItem) { | ||
assertIsFixedSize(item, "Fixed options can only be used with fixed-size codecs."); | ||
assertIsFixedSize(prefix, "Fixed options can only be used with fixed-size prefix."); | ||
const fixedSize = prefix.fixedSize + item.fixedSize; | ||
return createEncoder({ | ||
fixedSize, | ||
write: (optionOrNullable, bytes, offset) => { | ||
const option = isOption(optionOrNullable) ? optionOrNullable : wrapNullable(optionOrNullable); | ||
const prefixOffset = prefix.write(Number(isSome(option)), bytes, offset); | ||
if (isSome(option)) { | ||
item.write(option.value, bytes, prefixOffset); | ||
} | ||
return offset + fixedSize; | ||
} | ||
}); | ||
} | ||
return { | ||
description: description ?? `option(${item.description + descriptionSuffix})`, | ||
fixedSize, | ||
maxSize: sumCodecSizes([prefix.maxSize, item.maxSize]) | ||
}; | ||
} | ||
function getOptionEncoder(item, options = {}) { | ||
const prefix = options.prefix ?? getU8Encoder(); | ||
const fixed = options.fixed ?? false; | ||
return { | ||
...optionCodecHelper(item, prefix, fixed, options.description), | ||
encode: (optionOrNullable) => { | ||
return createEncoder({ | ||
getSizeFromValue: (optionOrNullable) => { | ||
const option = isOption(optionOrNullable) ? optionOrNullable : wrapNullable(optionOrNullable); | ||
const prefixByte = prefix.encode(Number(isSome(option))); | ||
let itemBytes = isSome(option) ? item.encode(option.value) : new Uint8Array(); | ||
itemBytes = fixed ? fixBytes(itemBytes, item.fixedSize) : itemBytes; | ||
return mergeBytes([prefixByte, itemBytes]); | ||
return getEncodedSize(Number(isSome(option)), prefix) + (isSome(option) ? getEncodedSize(option.value, item) : 0); | ||
}, | ||
maxSize: sumCodecSizes([prefix, item].map(getMaxSize)) ?? void 0, | ||
write: (optionOrNullable, bytes, offset) => { | ||
const option = isOption(optionOrNullable) ? optionOrNullable : wrapNullable(optionOrNullable); | ||
offset = prefix.write(Number(isSome(option)), bytes, offset); | ||
if (isSome(option)) { | ||
offset = item.write(option.value, bytes, offset); | ||
} | ||
return offset; | ||
} | ||
}; | ||
}); | ||
} | ||
function getOptionDecoder(item, options = {}) { | ||
const prefix = options.prefix ?? getU8Decoder(); | ||
const fixed = options.fixed ?? false; | ||
return { | ||
...optionCodecHelper(item, prefix, fixed, options.description), | ||
decode: (bytes, offset = 0) => { | ||
function getOptionDecoder(item, config = {}) { | ||
const prefix = config.prefix ?? getU8Decoder(); | ||
const fixed = config.fixed ?? false; | ||
let fixedSize = null; | ||
const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0; | ||
if (fixed || isZeroSizeItem) { | ||
assertIsFixedSize(item, "Fixed options can only be used with fixed-size codecs."); | ||
assertIsFixedSize(prefix, "Fixed options can only be used with fixed-size prefix."); | ||
fixedSize = prefix.fixedSize + item.fixedSize; | ||
} | ||
return createDecoder({ | ||
...fixedSize === null ? { maxSize: sumCodecSizes([prefix, item].map(getMaxSize)) ?? void 0 } : { fixedSize }, | ||
read: (bytes, offset) => { | ||
if (bytes.length - offset <= 0) { | ||
return [none(), offset]; | ||
} | ||
const fixedOffset = offset + (prefix.fixedSize ?? 0) + (item.fixedSize ?? 0); | ||
const [isSome2, prefixOffset] = prefix.decode(bytes, offset); | ||
offset = prefixOffset; | ||
const [isSome2, prefixOffset] = prefix.read(bytes, offset); | ||
if (isSome2 === 0) { | ||
return [none(), fixed ? fixedOffset : offset]; | ||
return [none(), fixedSize !== null ? offset + fixedSize : prefixOffset]; | ||
} | ||
const [value, newOffset] = item.decode(bytes, offset); | ||
offset = newOffset; | ||
return [some(value), fixed ? fixedOffset : offset]; | ||
const [value, newOffset] = item.read(bytes, prefixOffset); | ||
return [some(value), fixedSize !== null ? offset + fixedSize : newOffset]; | ||
} | ||
}; | ||
}); | ||
} | ||
function getOptionCodec(item, options = {}) { | ||
return combineCodec(getOptionEncoder(item, options), getOptionDecoder(item, options)); | ||
function getOptionCodec(item, config = {}) { | ||
return combineCodec(getOptionEncoder(item, config), getOptionDecoder(item, config)); | ||
} | ||
function sumCodecSizes(sizes) { | ||
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0); | ||
} | ||
function getMaxSize(codec) { | ||
return isFixedSize(codec) ? codec.fixedSize : codec.maxSize ?? null; | ||
} | ||
@@ -78,0 +92,0 @@ // src/unwrap-option-recursively.ts |
@@ -1,5 +0,5 @@ | ||
export * from './option'; | ||
export * from './option-codec'; | ||
export * from './unwrap-option'; | ||
export * from './unwrap-option-recursively'; | ||
export * from './option.js'; | ||
export * from './option-codec.js'; | ||
export * from './unwrap-option.js'; | ||
export * from './unwrap-option-recursively.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,6 +0,6 @@ | ||
import { BaseCodecOptions, Codec, Decoder, Encoder } from '@solana/codecs-core'; | ||
import { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers'; | ||
import { Option, OptionOrNullable } from './option'; | ||
/** Defines the options for option codecs. */ | ||
export type OptionCodecOptions<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecOptions & { | ||
import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core'; | ||
import { FixedSizeNumberCodec, FixedSizeNumberDecoder, FixedSizeNumberEncoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers'; | ||
import { Option, OptionOrNullable } from './option.js'; | ||
/** Defines the config for option codecs. */ | ||
export type OptionCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = { | ||
/** | ||
@@ -25,5 +25,11 @@ * The codec to use for the boolean prefix. | ||
* @param item - The encoder to use for the value that may be present. | ||
* @param options - A set of options for the encoder. | ||
* @param config - A set of config for the encoder. | ||
*/ | ||
export declare function getOptionEncoder<T>(item: Encoder<T>, options?: OptionCodecOptions<NumberEncoder>): Encoder<OptionOrNullable<T>>; | ||
export declare function getOptionEncoder<TFrom>(item: FixedSizeEncoder<TFrom>, config: OptionCodecConfig<FixedSizeNumberEncoder> & { | ||
fixed: true; | ||
}): FixedSizeEncoder<OptionOrNullable<TFrom>>; | ||
export declare function getOptionEncoder<TFrom>(item: FixedSizeEncoder<TFrom, 0>, config?: OptionCodecConfig<FixedSizeNumberEncoder>): FixedSizeEncoder<OptionOrNullable<TFrom>>; | ||
export declare function getOptionEncoder<TFrom>(item: Encoder<TFrom>, config?: OptionCodecConfig<NumberEncoder> & { | ||
fixed?: false; | ||
}): VariableSizeEncoder<OptionOrNullable<TFrom>>; | ||
/** | ||
@@ -33,5 +39,11 @@ * Creates a decoder for an optional value using `null` as the `None` value. | ||
* @param item - The decoder to use for the value that may be present. | ||
* @param options - A set of options for the decoder. | ||
* @param config - A set of config for the decoder. | ||
*/ | ||
export declare function getOptionDecoder<T>(item: Decoder<T>, options?: OptionCodecOptions<NumberDecoder>): Decoder<Option<T>>; | ||
export declare function getOptionDecoder<TTo>(item: FixedSizeDecoder<TTo>, config: OptionCodecConfig<FixedSizeNumberDecoder> & { | ||
fixed: true; | ||
}): FixedSizeDecoder<Option<TTo>>; | ||
export declare function getOptionDecoder<TTo>(item: FixedSizeDecoder<TTo, 0>, config?: OptionCodecConfig<FixedSizeNumberDecoder>): FixedSizeDecoder<Option<TTo>>; | ||
export declare function getOptionDecoder<TTo>(item: Decoder<TTo>, config?: OptionCodecConfig<NumberDecoder> & { | ||
fixed?: false; | ||
}): VariableSizeDecoder<Option<TTo>>; | ||
/** | ||
@@ -41,5 +53,11 @@ * Creates a codec for an optional value using `null` as the `None` value. | ||
* @param item - The codec to use for the value that may be present. | ||
* @param options - A set of options for the codec. | ||
* @param config - A set of config for the codec. | ||
*/ | ||
export declare function getOptionCodec<T, U extends T = T>(item: Codec<T, U>, options?: OptionCodecOptions<NumberCodec>): Codec<OptionOrNullable<T>, Option<U>>; | ||
export declare function getOptionCodec<TFrom, TTo extends TFrom = TFrom>(item: FixedSizeCodec<TFrom, TTo>, config: OptionCodecConfig<FixedSizeNumberCodec> & { | ||
fixed: true; | ||
}): FixedSizeCodec<OptionOrNullable<TFrom>, Option<TTo>>; | ||
export declare function getOptionCodec<TFrom, TTo extends TFrom = TFrom>(item: FixedSizeCodec<TFrom, TTo, 0>, config?: OptionCodecConfig<FixedSizeNumberCodec>): FixedSizeCodec<OptionOrNullable<TFrom>, Option<TTo>>; | ||
export declare function getOptionCodec<TFrom, TTo extends TFrom = TFrom>(item: Codec<TFrom, TTo>, config?: OptionCodecConfig<NumberCodec> & { | ||
fixed?: false; | ||
}): VariableSizeCodec<OptionOrNullable<TFrom>, Option<TTo>>; | ||
//# sourceMappingURL=option-codec.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { None, Some } from './option'; | ||
import { None, Some } from './option.js'; | ||
/** | ||
@@ -3,0 +3,0 @@ * Lists all types that should not be recursively unwrapped. |
@@ -1,2 +0,2 @@ | ||
import { Option } from './option'; | ||
import { Option } from './option.js'; | ||
/** | ||
@@ -3,0 +3,0 @@ * Unwraps the value of an {@link Option} of type `T` |
{ | ||
"name": "@solana/options", | ||
"version": "2.0.0-experimental.c237089", | ||
"version": "2.0.0-experimental.c42ccfd", | ||
"description": "Managing and serializing Rust-like Option types in JavaScript", | ||
@@ -52,21 +52,21 @@ "exports": { | ||
"dependencies": { | ||
"@solana/codecs-core": "2.0.0-experimental.c237089", | ||
"@solana/codecs-numbers": "2.0.0-experimental.c237089" | ||
"@solana/codecs-core": "2.0.0-experimental.c42ccfd", | ||
"@solana/codecs-numbers": "2.0.0-experimental.c42ccfd" | ||
}, | ||
"devDependencies": { | ||
"@solana/eslint-config-solana": "^1.0.2", | ||
"@swc/jest": "^0.2.28", | ||
"@types/jest": "^29.5.5", | ||
"@typescript-eslint/eslint-plugin": "^6.7.0", | ||
"@swc/jest": "^0.2.29", | ||
"@types/jest": "^29.5.11", | ||
"@typescript-eslint/eslint-plugin": "^6.13.2", | ||
"@typescript-eslint/parser": "^6.3.0", | ||
"agadoo": "^3.0.0", | ||
"eslint": "^8.45.0", | ||
"eslint-plugin-jest": "^27.2.3", | ||
"eslint-plugin-jest": "^27.4.2", | ||
"eslint-plugin-sort-keys-fix": "^1.1.2", | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.6.4", | ||
"jest-runner-eslint": "^2.1.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"jest-runner-eslint": "^2.1.2", | ||
"jest-runner-prettier": "^1.0.0", | ||
"prettier": "^2.8", | ||
"tsup": "7.2.0", | ||
"prettier": "^3.1", | ||
"tsup": "^8.0.1", | ||
"typescript": "^5.2.2", | ||
@@ -87,7 +87,7 @@ "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", | ||
"publish-packages": "pnpm publish --tag experimental --access public --no-git-checks", | ||
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/*", | ||
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/* package.json", | ||
"test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent", | ||
@@ -94,0 +94,0 @@ "test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129270
24
837
+ Added@solana/codecs-core@2.0.0-experimental.c42ccfd(transitive)
+ Added@solana/codecs-numbers@2.0.0-experimental.c42ccfd(transitive)
- Removed@solana/codecs-core@2.0.0-experimental.c237089(transitive)
- Removed@solana/codecs-numbers@2.0.0-experimental.c237089(transitive)