@nhtio/encoder 0.1.0-master-ab456424

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import type { Encodable } from './private/types';
2
+ /**
3
+ * The current version of the package.
4
+ *
5
+ * @tip This is a constant that is replaced during the build process with the actual version of the package.
6
+ */
7
+ export declare const version: string;
8
+ /**
9
+ * Encodes a value into a compressed base64 string
10
+ * @param what The value to be encoded
11
+ * @returns A compressed base64 string representing the encoded value
12
+ * @throws {@link @nhtio/encoder/exceptions!E_ENCODING_FAILED | E_ENCODING_FAILED} When the value cannot be encoded
13
+ * @throws {@link @nhtio/encoder/exceptions!E_CIRCULAR_REFERENCE | E_CIRCULAR_REFERENCE} When the value contains dangerous circular references
14
+ * @throws {@link @nhtio/encoder/exceptions!E_UNENCODABLE_VALUE | E_UNENCODABLE_VALUE} When the value contains unencodable data types
15
+ */
16
+ export declare const encode: <T extends Encodable = Encodable>(what: T) => string;
17
+ /**
18
+ * Decodes a compressed base64 string back into a value
19
+ * @param base64 The compressed base64 string representing an encoded value
20
+ * @returns The decoded value
21
+ * @throws {@link @nhtio/encoder/exceptions!E_NOT_AN_ENCODED_VALUE | E_NOT_AN_ENCODED_VALUE} When the provided string is not a valid encoded value
22
+ * @throws {@link @nhtio/encoder/exceptions!E_INVALID_VERSION | E_INVALID_VERSION} When the encoded value has an invalid version
23
+ * @throws {@link @nhtio/encoder/exceptions!E_INCOMPATIBLE_VERSION | E_INCOMPATIBLE_VERSION} When the encoded value is from a version that is newer than the decoder version
24
+ * @throws {@link @nhtio/encoder/exceptions!E_UNDECODABLE_VALUE | E_UNDECODABLE_VALUE} When the encoded value cannot be decoded
25
+ */
26
+ export declare const decode: <T extends Encodable = Encodable>(base64: string) => T;
27
+ export type { Encodable, EncodablePrimitive, EncodableTypedArray } from './private/types';