@structium/ini
Version:
Serialize and deserialize INI
28 lines (24 loc) • 1.26 kB
TypeScript
import IniLib from 'ini';
type CommonObj = Record<string, unknown> | Record<string, unknown>[] | unknown[];
type DeserializeOptions = IniLib.DecodeOptions;
/**
* Deserialize an INI string into a JavaScript object.
*
* @template Res - The expected return type of the deserialized object
* @param {string} input - The INI content string
* @param {object} [options] - Options
* @returns {Promise<Res>} - The deserialized JavaScript object
* @throws {Error} - If the content is detected as HTML
*/
declare const deserialize: <Res extends CommonObj = CommonObj>(input: string, options?: DeserializeOptions) => Promise<Res>;
type SerializeOptions = IniLib.EncodeOptions;
/**
* Serialize a JavaScript object into an INI string.
*
* @template I - The type of the object to be converted.
* @param {I} input - The object to be converted.
* @param {SerializeOptions} [options] - Options to pass to `ini.stringify`
* @returns {Promise<string>} - A promise that resolves to the INI string.
*/
declare const serialize: <I extends CommonObj>(input: I, options?: SerializeOptions) => Promise<string>;
export { type DeserializeOptions, type SerializeOptions, deserialize, serialize };