@daiso-tech/core
Version:
The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.
29 lines (28 loc) • 960 B
TypeScript
/**
* @module Codec
*/
/**
* Encoder contract defining the interface for converting decoded data to encoded format.
*
* Common use cases:
* - JSON encoding: object → JSON string
* - Base64 encoding: binary data → base64 string
* - Compression: large data → compressed bytes
* - Encryption: plaintext → ciphertext
*
* @template TDecodedValue - The type of data before encoding (original/source format)
* @template TEncodedValue - The type of data after encoding (target/transport format)
*
* IMPORT_PATH: `"@daiso-tech/core/codec/contracts"`
* @group Contracts
*/
export type IEncoder<TDecodedValue, TEncodedValue> = {
/**
* Encodes the given decoded value into encoded format.
* Transforms data from original format to target encoding.
*
* @param decodedValue - The value in original format to encode
* @returns The value in encoded format
*/
encode(decodedValue: TDecodedValue): TEncodedValue;
};