/** * IO related functions. * * @example * var ioLib = require('/lib/xp/io'); * * @module io */ declare global { interface XpLibraries { '/lib/xp/io': typeof import('./io'); } } import type { ByteSource, Resource, ResourceKey } from '@enonic-types/core'; export type { ByteSource, Resource, ResourceKey, } from '@enonic-types/core'; /** * Read text from a stream. * * @example-ref examples/io/readText.js * * @param stream Stream to read text from. * @returns {string} Returns the text read from the stream. */ export declare function readText(stream: ByteSource): string; /** * Read lines from a stream. * * @example-ref examples/io/readLines.js * * @param stream Stream to read lines from. * @returns {string[]} Returns lines as an array. */ export declare function readLines(stream: ByteSource): string[]; /** * Process lines from a stream. * * @example-ref examples/io/processLines.js * * @param stream Stream to read lines from. * @param {function} func Callback function to be called for each line. */ export declare function processLines(stream: ByteSource, func: (value: string) => void): void; /** * Returns the size of a stream. * * @example-ref examples/io/getSize.js * * @param stream Stream to get size of. * @returns {number} Returns the size of a stream. */ export declare function getSize(stream: ByteSource): number; /** * Returns the mime-type from a name or extension. * * @example-ref examples/io/getMimeType.js * * @param {string} name Name of file or extension. * @returns {string} Mime-type of name or extension. */ export declare function getMimeType(name: string): string; /** * Returns a new stream from a string. * * @example-ref examples/io/newStream.js * * @param {string} text String to create a stream of. * @returns {*} A new stream. */ export declare function newStream(text: string): ByteSource; /** * Looks up a resource. * * @example-ref examples/io/getResource.js * * @param {string|ResourceKey} key Resource key to look up. * @returns {Resource} Resource reference. */ export declare function getResource(key: string | ResourceKey): Resource;