UNPKG

pao-aop-server

Version:

基于pao-aop的服务端框架

256 lines 5.45 kB
/// <reference types="node" /> /** * 偏移位置 */ export declare enum OffsetPosition { start = 0, current = 1, end = 2 } /** * 将数据缓存转换为字符串 * @param data 数据缓存 */ export declare function bufferToBase64(data: Buffer): string; /** * 数据缓存 * @param json json 字符串 */ export declare function bufferFromBase64(json: string): Buffer; /** * 缓冲区定位器 */ export declare class BufferLocator { /** * 当前位置 */ protected position: number; /** * 数据缓冲 */ protected buffer: Buffer; /** * Buffer的实际长度 */ protected bufferLength: number; /** * 获取缓冲区大小 */ readonly bufferSize: number; /** * 当前位置 */ readonly currentPosition: number; /** * 是否已经读取完毕 */ readonly isEnd: boolean; /** * 获取缓冲区 */ getBuffer(): Buffer; /** * 位置偏移 * @param startPos 启动位置 * @param offset 偏移 * @returns 偏移后的位置 */ offset(startPos: OffsetPosition, offset: number): number; } /** * 缓冲区读取器 */ export declare class BufferReader extends BufferLocator { constructor(buffer?: Buffer); /** * 读取字符串 * @param encoding 编码格式 * @returns 字符串 */ readString(encoding: string): string; /** * 读取数据缓冲 * @returns 数据缓冲 */ readBuffer(): Buffer; /** * 读取UInt8 * @returns UInt8 */ readUInt8(): number; /** * 读取UInt16LE * @returns UInt16LE */ readUInt16LE(): number; /** * 读取UInt16BE * @returns UInt16BE */ readUInt16BE(): number; /** * 读取UInt32LE * @returns UInt32LE */ readUInt32LE(): number; /** * 读取UInt32BE * @returns UInt32BE */ readUInt32BE(): number; /** * 读取Int8 * @returns Int8 */ readInt8(): number; /** * 读取Int16LE * @returns Int16LE */ readInt16LE(): number; /** * 读取Int16BE * @returns Int16BE */ readInt16BE(): number; /** * 读取Int32LE * @returns Int32LE */ readInt32LE(): number; /** * 读取Int32BE * @returns Int32BE */ readInt32BE(): number; /** * 读取FloatLE * @returns FloatLE */ readFloatLE(): number; /** * 读取FloatBE * @returns FloatBE */ readFloatBE(): number; /** * 读取DoubleLE * @returns DoubleLE */ readDoubleLE(): number; /** * 读取DoubleBE * @returns DoubleBE */ readDoubleBE(): number; } /** * 写缓冲区的工具 */ export declare class BufferWriter extends BufferLocator { constructor(); /** * 写入字符串 * @param data 数据 * @param encoding 编码格式 * @returns 写入的字符串缓冲区大小 */ writeString(data: string, encoding?: string): number; /** * 写入数据缓存 * @param data 数据 * @returns 写入后的位置 */ writeBuffer(data: Buffer): number; /** * 写入UInt8 * @param value UInt8 * @returns 写入后的位置 */ writeUInt8(value: number): number; /** * 写入UInt16LE * @param value UInt16LE * @returns 写入后的位置 */ writeUInt16LE(value: number): number; /** * 写入UInt16BE * @param value UInt16BE * @returns 写入后的位置 */ writeUInt16BE(value: number): number; /** * 写入UInt32LE * @param value UInt32LE * @returns 写入后的位置 */ writeUInt32LE(value: number): number; /** * 写入UInt32BE * @param value UInt32BE * @returns 写入后的位置 */ writeUInt32BE(value: number): number; /** * 写入Int8 * @param value Int8 * @returns 写入后的位置 */ writeInt8(value: number): number; /** * 写入Int16LE * @param value Int16LE * @returns 写入后的位置 */ writeInt16LE(value: number): number; /** * 写入Int16BE * @param value Int16BE * @returns 写入后的位置 */ writeInt16BE(value: number): number; /** * 写入Int32LE * @param value Int32LE * @returns 写入后的位置 */ writeInt32LE(value: number): number; /** * 写入Int32BE * @param value Int32BE * @returns 写入后的位置 */ writeInt32BE(value: number): number; /** * 写入FloatLE * @param value FloatLE * @returns 写入后的位置 */ writeFloatLE(value: number): number; /** * 写入FloatBE * @param value FloatBE * @returns 写入后的位置 */ writeFloatBE(value: number): number; /** * 写入DoubleLE * @param value DoubleLE * @returns 写入后的位置 */ writeDoubleLE(value: number): number; /** * 写入DoubleBE * @param value DoubleBE * @returns 写入后的位置 */ writeDoubleBE(value: number): number; /** * 分配内存 * @param needSize 需要的大小 * @returns 如果新分配了内存,则返回True,否则,返回False */ protected allocate(needSize: number): boolean; } //# sourceMappingURL=index.d.ts.map