161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci /** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit ArkTS 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci import { Callback } from './@ohos.base'; 2161847f8eSopenharmony_ci import emitter from './@ohos.events.emitter'; 2261847f8eSopenharmony_ci 2361847f8eSopenharmony_ci /** 2461847f8eSopenharmony_ci * The stream module provides a comprehensive set of stream processing capabilities, including four types of streams: 2561847f8eSopenharmony_ci * - Writable: streams designed for writing data to. 2661847f8eSopenharmony_ci * - Readable: streams designed for reading data from. 2761847f8eSopenharmony_ci * - Duplex: streams that are both readable and writable. 2861847f8eSopenharmony_ci * - Transform: a specialized type of duplex stream that can modify or transform data as it's being written and read. 2961847f8eSopenharmony_ci * 3061847f8eSopenharmony_ci * @namespace stream 3161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 3261847f8eSopenharmony_ci * @crossplatform 3361847f8eSopenharmony_ci * @atomicservice 3461847f8eSopenharmony_ci * @since 12 3561847f8eSopenharmony_ci */ 3661847f8eSopenharmony_cideclare namespace stream { 3761847f8eSopenharmony_ci /** 3861847f8eSopenharmony_ci * Streams to which data can be written. 3961847f8eSopenharmony_ci * 4061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 4161847f8eSopenharmony_ci * @crossplatform 4261847f8eSopenharmony_ci * @atomicservice 4361847f8eSopenharmony_ci * @since 12 4461847f8eSopenharmony_ci */ 4561847f8eSopenharmony_ci class Writable { 4661847f8eSopenharmony_ci /** 4761847f8eSopenharmony_ci * The Writable constructor. 4861847f8eSopenharmony_ci * 4961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 5061847f8eSopenharmony_ci * @crossplatform 5161847f8eSopenharmony_ci * @atomicservice 5261847f8eSopenharmony_ci * @since 12 5361847f8eSopenharmony_ci */ 5461847f8eSopenharmony_ci constructor(); 5561847f8eSopenharmony_ci /** 5661847f8eSopenharmony_ci * writes a chunk to Writable and invokes callback when the chunk is flushed. The return value indicates 5761847f8eSopenharmony_ci * whether the internal buffer of the Writable reaches the hightWaterMark. If true is returned, the buffer 5861847f8eSopenharmony_ci * does not reach the hightWaterMark. If false is returned, the buffer has been reached. The write function 5961847f8eSopenharmony_ci * should be called after the drain event is triggered. If the write function is called continuously, 6061847f8eSopenharmony_ci * the chunk is still added to the buffer until the memory overflows 6161847f8eSopenharmony_ci * 6261847f8eSopenharmony_ci * @param { string | Uint8Array } [chunk] - Data to be written. 6361847f8eSopenharmony_ci * @param { string } [encoding] - Encoding type. 6461847f8eSopenharmony_ci * @param { Function } [callback] - Callback after writing. 6561847f8eSopenharmony_ci * @returns { boolean } Write success returns true, write failure returns false. 6661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 6761847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 6861847f8eSopenharmony_ci * 2.Incorrect parameter types; 6961847f8eSopenharmony_ci * 3.Parameter verification failed. 7061847f8eSopenharmony_ci * @throws { BusinessError } 10200035 - The doWrite method has not been implemented. 7161847f8eSopenharmony_ci * @throws { BusinessError } 10200036 - The stream has been ended. 7261847f8eSopenharmony_ci * @throws { BusinessError } 10200037 - The callback is invoked multiple times consecutively. 7361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 7461847f8eSopenharmony_ci * @crossplatform 7561847f8eSopenharmony_ci * @atomicservice 7661847f8eSopenharmony_ci * @since 12 7761847f8eSopenharmony_ci */ 7861847f8eSopenharmony_ci write(chunk?: string | Uint8Array, encoding?: string, callback?: Function): boolean; 7961847f8eSopenharmony_ci /** 8061847f8eSopenharmony_ci * Write the last chunk to Writable. 8161847f8eSopenharmony_ci * 8261847f8eSopenharmony_ci * @param { string | Uint8Array } [chunk] - Data to be written. 8361847f8eSopenharmony_ci * @param { string } [encoding] - Encoding type. 8461847f8eSopenharmony_ci * @param { Function } [callback] - Callback after writing. 8561847f8eSopenharmony_ci * @returns { Writable } Returns the Writable object. 8661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 8761847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 8861847f8eSopenharmony_ci * 2.Incorrect parameter types; 8961847f8eSopenharmony_ci * 3.Parameter verification failed. 9061847f8eSopenharmony_ci * @throws { BusinessError } 10200035 - The doWrite method has not been implemented. 9161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 9261847f8eSopenharmony_ci * @crossplatform 9361847f8eSopenharmony_ci * @atomicservice 9461847f8eSopenharmony_ci * @since 12 9561847f8eSopenharmony_ci */ 9661847f8eSopenharmony_ci end(chunk?: string | Uint8Array, encoding?: string, callback?: Function): Writable; 9761847f8eSopenharmony_ci /** 9861847f8eSopenharmony_ci * Set the default encoding mode. 9961847f8eSopenharmony_ci * 10061847f8eSopenharmony_ci * @param { string } [encoding] - Encoding type.Default: utf8. 10161847f8eSopenharmony_ci * @returns { boolean } Setting successful returns true, setting failed returns false. 10261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 10361847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 10461847f8eSopenharmony_ci * 2.Incorrect parameter types; 10561847f8eSopenharmony_ci * 3.Parameter verification failed. 10661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 10761847f8eSopenharmony_ci * @crossplatform 10861847f8eSopenharmony_ci * @atomicservice 10961847f8eSopenharmony_ci * @since 12 11061847f8eSopenharmony_ci */ 11161847f8eSopenharmony_ci setDefaultEncoding(encoding?: string): boolean; 11261847f8eSopenharmony_ci /** 11361847f8eSopenharmony_ci * After the call, all Write operations will be forced to write to the buffer instead of being flushed. 11461847f8eSopenharmony_ci * 11561847f8eSopenharmony_ci * @returns { boolean } Setting successful returns true, setting failed returns false. 11661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 11761847f8eSopenharmony_ci * @crossplatform 11861847f8eSopenharmony_ci * @atomicservice 11961847f8eSopenharmony_ci * @since 12 12061847f8eSopenharmony_ci */ 12161847f8eSopenharmony_ci cork(): boolean; 12261847f8eSopenharmony_ci /** 12361847f8eSopenharmony_ci * After calling, flush all buffers. 12461847f8eSopenharmony_ci * 12561847f8eSopenharmony_ci * @returns { boolean } Setting successful returns true, setting failed returns false. 12661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 12761847f8eSopenharmony_ci * @crossplatform 12861847f8eSopenharmony_ci * @atomicservice 12961847f8eSopenharmony_ci * @since 12 13061847f8eSopenharmony_ci */ 13161847f8eSopenharmony_ci uncork(): boolean; 13261847f8eSopenharmony_ci /** 13361847f8eSopenharmony_ci * Registering Event Messages. 13461847f8eSopenharmony_ci * 13561847f8eSopenharmony_ci * @param { string } event - Register Event. 13661847f8eSopenharmony_ci * @param { Callback<emitter.EventData> } callback - event callbacks. 13761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 13861847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 13961847f8eSopenharmony_ci * 2.Incorrect parameter types; 14061847f8eSopenharmony_ci * 3.Parameter verification failed. 14161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 14261847f8eSopenharmony_ci * @crossplatform 14361847f8eSopenharmony_ci * @atomicservice 14461847f8eSopenharmony_ci * @since 12 14561847f8eSopenharmony_ci */ 14661847f8eSopenharmony_ci on(event: string, callback: Callback<emitter.EventData>): void; 14761847f8eSopenharmony_ci /** 14861847f8eSopenharmony_ci * Cancel event message. 14961847f8eSopenharmony_ci * 15061847f8eSopenharmony_ci * @param { string } event - Register Event. 15161847f8eSopenharmony_ci * @param { Callback<emitter.EventData> } callback - event callbacks. 15261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 15361847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 15461847f8eSopenharmony_ci * 2.Incorrect parameter types. 15561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 15661847f8eSopenharmony_ci * @crossplatform 15761847f8eSopenharmony_ci * @atomicservice 15861847f8eSopenharmony_ci * @since 12 15961847f8eSopenharmony_ci */ 16061847f8eSopenharmony_ci off(event: string, callback?: Callback<emitter.EventData>): void; 16161847f8eSopenharmony_ci /** 16261847f8eSopenharmony_ci * This method is invoked by the Writable method during initialization and must not be invoked directly. 16361847f8eSopenharmony_ci * After the resource is initialized in the doInitialize method, the callback () method is invoked. 16461847f8eSopenharmony_ci * 16561847f8eSopenharmony_ci * @param { Function } callback - Callback when the stream has completed the initial. 16661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 16761847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 16861847f8eSopenharmony_ci * 2.Incorrect parameter types. 16961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 17061847f8eSopenharmony_ci * @crossplatform 17161847f8eSopenharmony_ci * @atomicservice 17261847f8eSopenharmony_ci * @since 12 17361847f8eSopenharmony_ci */ 17461847f8eSopenharmony_ci doInitialize(callback: Function): void; 17561847f8eSopenharmony_ci /** 17661847f8eSopenharmony_ci * Implemented by subclass inheritance. The implementation logic of flushing chunks in the buffer must not be 17761847f8eSopenharmony_ci * directly called. The call is controlled by Writable.write. 17861847f8eSopenharmony_ci * 17961847f8eSopenharmony_ci * @param { string | Uint8Array } [chunk] - Data to be written. 18061847f8eSopenharmony_ci * @param { string } [encoding] - Encoding type. 18161847f8eSopenharmony_ci * @param { Function } [callback] - Callback after writing. 18261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 18361847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 18461847f8eSopenharmony_ci * 2.Incorrect parameter types; 18561847f8eSopenharmony_ci * 3.Parameter verification failed. 18661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 18761847f8eSopenharmony_ci * @crossplatform 18861847f8eSopenharmony_ci * @atomicservice 18961847f8eSopenharmony_ci * @since 12 19061847f8eSopenharmony_ci */ 19161847f8eSopenharmony_ci doWrite(chunk: string | Uint8Array, encoding: string, callback: Function): void; 19261847f8eSopenharmony_ci /** 19361847f8eSopenharmony_ci * The implementation logic of flushing chunks in the buffer in batches should not be actively called. 19461847f8eSopenharmony_ci * The call is controlled by Writable.write. 19561847f8eSopenharmony_ci * 19661847f8eSopenharmony_ci * @param { string[] | Uint8Array[] } [chunks] - Data to be written. 19761847f8eSopenharmony_ci * @param { Function } [callback] - Callback after writing. 19861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 19961847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 20061847f8eSopenharmony_ci * 2.Incorrect parameter types; 20161847f8eSopenharmony_ci * 3.Parameter verification failed. 20261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 20361847f8eSopenharmony_ci * @crossplatform 20461847f8eSopenharmony_ci * @atomicservice 20561847f8eSopenharmony_ci * @since 12 20661847f8eSopenharmony_ci */ 20761847f8eSopenharmony_ci doWritev(chunks: string[] | Uint8Array[], callback: Function): void; 20861847f8eSopenharmony_ci /** 20961847f8eSopenharmony_ci * Returns boolean indicating whether it is in ObjectMode. 21061847f8eSopenharmony_ci * 21161847f8eSopenharmony_ci * @type { boolean } 21261847f8eSopenharmony_ci * @readonly 21361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 21461847f8eSopenharmony_ci * @crossplatform 21561847f8eSopenharmony_ci * @atomicservice 21661847f8eSopenharmony_ci * @since 12 21761847f8eSopenharmony_ci */ 21861847f8eSopenharmony_ci readonly writableObjectMode: boolean; 21961847f8eSopenharmony_ci /** 22061847f8eSopenharmony_ci * Value of highWatermark. 22161847f8eSopenharmony_ci * 22261847f8eSopenharmony_ci * @type { number } 22361847f8eSopenharmony_ci * @readonly 22461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 22561847f8eSopenharmony_ci * @crossplatform 22661847f8eSopenharmony_ci * @atomicservice 22761847f8eSopenharmony_ci * @since 12 22861847f8eSopenharmony_ci */ 22961847f8eSopenharmony_ci readonly writableHighWatermark: number; 23061847f8eSopenharmony_ci /** 23161847f8eSopenharmony_ci * Is true if it is safe to call writable.write(), which means the stream has not been destroyed, error or end. 23261847f8eSopenharmony_ci * 23361847f8eSopenharmony_ci * @type { boolean } 23461847f8eSopenharmony_ci * @readonly 23561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 23661847f8eSopenharmony_ci * @crossplatform 23761847f8eSopenharmony_ci * @atomicservice 23861847f8eSopenharmony_ci * @since 12 23961847f8eSopenharmony_ci */ 24061847f8eSopenharmony_ci readonly writable: boolean; 24161847f8eSopenharmony_ci /** 24261847f8eSopenharmony_ci * Size of data that can be flushed, in bytes or objects. 24361847f8eSopenharmony_ci * 24461847f8eSopenharmony_ci * @type { number } 24561847f8eSopenharmony_ci * @readonly 24661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 24761847f8eSopenharmony_ci * @crossplatform 24861847f8eSopenharmony_ci * @atomicservice 24961847f8eSopenharmony_ci * @since 12 25061847f8eSopenharmony_ci */ 25161847f8eSopenharmony_ci readonly writableLength: number; 25261847f8eSopenharmony_ci /** 25361847f8eSopenharmony_ci * Number of times writable.uncork() needs to be called in order to fully uncork the stream. 25461847f8eSopenharmony_ci * 25561847f8eSopenharmony_ci * @type { number } 25661847f8eSopenharmony_ci * @readonly 25761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 25861847f8eSopenharmony_ci * @crossplatform 25961847f8eSopenharmony_ci * @atomicservice 26061847f8eSopenharmony_ci * @since 12 26161847f8eSopenharmony_ci */ 26261847f8eSopenharmony_ci readonly writableCorked: number; 26361847f8eSopenharmony_ci /** 26461847f8eSopenharmony_ci * Whether Writable.end has been called. 26561847f8eSopenharmony_ci * 26661847f8eSopenharmony_ci * @type { boolean } 26761847f8eSopenharmony_ci * @readonly 26861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 26961847f8eSopenharmony_ci * @crossplatform 27061847f8eSopenharmony_ci * @atomicservice 27161847f8eSopenharmony_ci * @since 12 27261847f8eSopenharmony_ci */ 27361847f8eSopenharmony_ci readonly writableEnded: boolean; 27461847f8eSopenharmony_ci /** 27561847f8eSopenharmony_ci * Whether Writable.end has been called and all buffers have been flushed. 27661847f8eSopenharmony_ci * 27761847f8eSopenharmony_ci * @type { boolean } 27861847f8eSopenharmony_ci * @readonly 27961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 28061847f8eSopenharmony_ci * @crossplatform 28161847f8eSopenharmony_ci * @atomicservice 28261847f8eSopenharmony_ci * @since 12 28361847f8eSopenharmony_ci */ 28461847f8eSopenharmony_ci readonly writableFinished: boolean; 28561847f8eSopenharmony_ci } 28661847f8eSopenharmony_ci /** 28761847f8eSopenharmony_ci * Transform stream is a Duplex stream where the output is computed in some way from the input. 28861847f8eSopenharmony_ci * Transform implementations must implement the doTransform() method and may also implement the doFlush() method. 28961847f8eSopenharmony_ci * 29061847f8eSopenharmony_ci * @extends Duplex 29161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 29261847f8eSopenharmony_ci * @crossplatform 29361847f8eSopenharmony_ci * @atomicservice 29461847f8eSopenharmony_ci * @since 12 29561847f8eSopenharmony_ci */ 29661847f8eSopenharmony_ci class Transform extends Duplex { 29761847f8eSopenharmony_ci /** 29861847f8eSopenharmony_ci * The Transform constructor. 29961847f8eSopenharmony_ci * 30061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 30161847f8eSopenharmony_ci * @crossplatform 30261847f8eSopenharmony_ci * @atomicservice 30361847f8eSopenharmony_ci * @since 12 30461847f8eSopenharmony_ci */ 30561847f8eSopenharmony_ci constructor(); 30661847f8eSopenharmony_ci /** 30761847f8eSopenharmony_ci * Convert the input data. After the conversion, Transform.push can be called to send the input to the read stream. 30861847f8eSopenharmony_ci * Transform.push should not be called Transform.write to call. 30961847f8eSopenharmony_ci * 31061847f8eSopenharmony_ci * @param { string } chunk - Input data to be converted. 31161847f8eSopenharmony_ci * @param { string } encoding - If the chunk is a string, then this is the encoding type. If chunk is a buffer, 31261847f8eSopenharmony_ci * then this is the special value 'buffer'. Ignore it in that case. 31361847f8eSopenharmony_ci * @param { Function } callback - Callback after conversion. 31461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 31561847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 31661847f8eSopenharmony_ci * 2.Incorrect parameter types; 31761847f8eSopenharmony_ci * 3.Parameter verification failed. 31861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 31961847f8eSopenharmony_ci * @crossplatform 32061847f8eSopenharmony_ci * @atomicservice 32161847f8eSopenharmony_ci * @since 12 32261847f8eSopenharmony_ci */ 32361847f8eSopenharmony_ci doTransform(chunk: string, encoding: string, callback: Function): void; 32461847f8eSopenharmony_ci /** 32561847f8eSopenharmony_ci * After all data is flushed to the write stream, you can use the Transform.doFlush writes some extra data, must 32661847f8eSopenharmony_ci * not be called directly, only called by Writable after flushing all data. 32761847f8eSopenharmony_ci * 32861847f8eSopenharmony_ci * @param { Function } callback - Callback after flush completion. 32961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 33061847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 33161847f8eSopenharmony_ci * 2.Incorrect parameter types; 33261847f8eSopenharmony_ci * 3.Parameter verification failed. 33361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 33461847f8eSopenharmony_ci * @crossplatform 33561847f8eSopenharmony_ci * @atomicservice 33661847f8eSopenharmony_ci * @since 12 33761847f8eSopenharmony_ci */ 33861847f8eSopenharmony_ci doFlush(callback: Function): void; 33961847f8eSopenharmony_ci } 34061847f8eSopenharmony_ci 34161847f8eSopenharmony_ci /** 34261847f8eSopenharmony_ci * Return readable options. 34361847f8eSopenharmony_ci * 34461847f8eSopenharmony_ci * @interface ReadableOptions 34561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 34661847f8eSopenharmony_ci * @crossplatform 34761847f8eSopenharmony_ci * @atomicservice 34861847f8eSopenharmony_ci * @since 12 34961847f8eSopenharmony_ci */ 35061847f8eSopenharmony_ci interface ReadableOptions { 35161847f8eSopenharmony_ci /** 35261847f8eSopenharmony_ci * Specifies the encoding format of the data. If this parameter is provided, 35361847f8eSopenharmony_ci * the readable stream decodes the data into a string in the specified encoding format. Default: utf8. 35461847f8eSopenharmony_ci * If an invalid string is entered, a 401 exception is thrown in the Readable constructor. 35561847f8eSopenharmony_ci * Supported encoding formats: utf-8, ibm866, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, 35661847f8eSopenharmony_ci * iso-8859-7, iso-8859-8, iso-8859-8-i, iso-8859-10, iso-8859-13, iso-8859-14, iso-8859-15, koi8-r, koi8-u, 35761847f8eSopenharmony_ci * macintosh, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, 35861847f8eSopenharmony_ci * windows-1256, windows-1257, windows-1258, x-mac-cyrillic, gbk, gb18030, big5, euc-jp, iso-2022-jp, shift_jis, 35961847f8eSopenharmony_ci * euc-kr, utf-16be, utf-16le. 36061847f8eSopenharmony_ci * 36161847f8eSopenharmony_ci * @type { ?string } 36261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 36361847f8eSopenharmony_ci * @crossplatform 36461847f8eSopenharmony_ci * @atomicservice 36561847f8eSopenharmony_ci * @since 12 36661847f8eSopenharmony_ci */ 36761847f8eSopenharmony_ci encoding?: string; 36861847f8eSopenharmony_ci } 36961847f8eSopenharmony_ci 37061847f8eSopenharmony_ci /** 37161847f8eSopenharmony_ci * The stream from which data can be read. 37261847f8eSopenharmony_ci * 37361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 37461847f8eSopenharmony_ci * @crossplatform 37561847f8eSopenharmony_ci * @atomicservice 37661847f8eSopenharmony_ci * @since 12 37761847f8eSopenharmony_ci */ 37861847f8eSopenharmony_ci class Readable { 37961847f8eSopenharmony_ci /** 38061847f8eSopenharmony_ci * The Readable constructor. 38161847f8eSopenharmony_ci * 38261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 38361847f8eSopenharmony_ci * @crossplatform 38461847f8eSopenharmony_ci * @atomicservice 38561847f8eSopenharmony_ci * @since 12 38661847f8eSopenharmony_ci */ 38761847f8eSopenharmony_ci constructor(); 38861847f8eSopenharmony_ci /** 38961847f8eSopenharmony_ci * The Readable constructor. 39061847f8eSopenharmony_ci * 39161847f8eSopenharmony_ci * @param { ReadableOptions } options - Provide options. 39261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 39361847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 39461847f8eSopenharmony_ci * 2.Incorrect parameter types; 39561847f8eSopenharmony_ci * 3.Parameter verification failed. 39661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 39761847f8eSopenharmony_ci * @crossplatform 39861847f8eSopenharmony_ci * @atomicservice 39961847f8eSopenharmony_ci * @since 12 40061847f8eSopenharmony_ci */ 40161847f8eSopenharmony_ci constructor(options: ReadableOptions); 40261847f8eSopenharmony_ci /** 40361847f8eSopenharmony_ci * Reads a buffer of a specified size from the buffer. If the available buffer is sufficient, the result 40461847f8eSopenharmony_ci * of the specified size is returned. Otherwise, if Readable has ended, all remaining buffers are returned. 40561847f8eSopenharmony_ci * 40661847f8eSopenharmony_ci * @param { number } size - Expected length of the data to be read. 40761847f8eSopenharmony_ci * @returns { string | null } If no data is available to read, null is returned. 40861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 40961847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 41061847f8eSopenharmony_ci * 2.Incorrect parameter types; 41161847f8eSopenharmony_ci * 3.Parameter verification failed. 41261847f8eSopenharmony_ci * @throws { BusinessError } 10200038 - The doRead method has not been implemented. 41361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 41461847f8eSopenharmony_ci * @crossplatform 41561847f8eSopenharmony_ci * @atomicservice 41661847f8eSopenharmony_ci * @since 12 41761847f8eSopenharmony_ci */ 41861847f8eSopenharmony_ci read(size?: number): string | null; 41961847f8eSopenharmony_ci /** 42061847f8eSopenharmony_ci * Switch Readable to Streaming Mode. 42161847f8eSopenharmony_ci * 42261847f8eSopenharmony_ci * @returns { Readable } Return this object. 42361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 42461847f8eSopenharmony_ci * @crossplatform 42561847f8eSopenharmony_ci * @atomicservice 42661847f8eSopenharmony_ci * @since 12 42761847f8eSopenharmony_ci */ 42861847f8eSopenharmony_ci resume(): Readable; 42961847f8eSopenharmony_ci /** 43061847f8eSopenharmony_ci * Toggle Readable to Suspend Mode. 43161847f8eSopenharmony_ci * 43261847f8eSopenharmony_ci * @returns { Readable } Return this object. 43361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 43461847f8eSopenharmony_ci * @crossplatform 43561847f8eSopenharmony_ci * @atomicservice 43661847f8eSopenharmony_ci * @since 12 43761847f8eSopenharmony_ci */ 43861847f8eSopenharmony_ci pause(): Readable; 43961847f8eSopenharmony_ci /** 44061847f8eSopenharmony_ci * Sets the encoding format of the input binary data.Default: utf8. 44161847f8eSopenharmony_ci * 44261847f8eSopenharmony_ci * @param { string } [encoding] - Original Data Encoding Type. 44361847f8eSopenharmony_ci * @returns { boolean } Setting successful returns true, setting failed returns false. 44461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 44561847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 44661847f8eSopenharmony_ci * 2.Incorrect parameter types. 44761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 44861847f8eSopenharmony_ci * @crossplatform 44961847f8eSopenharmony_ci * @atomicservice 45061847f8eSopenharmony_ci * @since 12 45161847f8eSopenharmony_ci */ 45261847f8eSopenharmony_ci setEncoding(encoding?: string): boolean; 45361847f8eSopenharmony_ci /** 45461847f8eSopenharmony_ci * Query whether it is in pause state. 45561847f8eSopenharmony_ci * 45661847f8eSopenharmony_ci * @returns { boolean } Pause state returns true, otherwise returns false. 45761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 45861847f8eSopenharmony_ci * @crossplatform 45961847f8eSopenharmony_ci * @atomicservice 46061847f8eSopenharmony_ci * @since 12 46161847f8eSopenharmony_ci */ 46261847f8eSopenharmony_ci isPaused(): boolean; 46361847f8eSopenharmony_ci /** 46461847f8eSopenharmony_ci * Concatenated a Writable to a Readable and switches the Readable to stream mode. 46561847f8eSopenharmony_ci * 46661847f8eSopenharmony_ci * @param { Writable } destination - Output writable stream. 46761847f8eSopenharmony_ci * @param { Object } [options] - Pipeline Options. 46861847f8eSopenharmony_ci * @returns { Writable } Returns the Writable object. 46961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 47061847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 47161847f8eSopenharmony_ci * 2.Incorrect parameter types; 47261847f8eSopenharmony_ci * 3.Parameter verification failed. 47361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 47461847f8eSopenharmony_ci * @crossplatform 47561847f8eSopenharmony_ci * @atomicservice 47661847f8eSopenharmony_ci * @since 12 47761847f8eSopenharmony_ci */ 47861847f8eSopenharmony_ci pipe(destination: Writable, options?: Object): Writable; 47961847f8eSopenharmony_ci /** 48061847f8eSopenharmony_ci * Disconnect Writable from Readable. 48161847f8eSopenharmony_ci * 48261847f8eSopenharmony_ci * @param { Writable } [destination] - Writable Streams Needing to Be Disconnected. 48361847f8eSopenharmony_ci * @returns { Readable } Returns the Readable object. 48461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 48561847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 48661847f8eSopenharmony_ci * 2.Incorrect parameter types; 48761847f8eSopenharmony_ci * 3.Parameter verification failed. 48861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 48961847f8eSopenharmony_ci * @crossplatform 49061847f8eSopenharmony_ci * @atomicservice 49161847f8eSopenharmony_ci * @since 12 49261847f8eSopenharmony_ci */ 49361847f8eSopenharmony_ci unpipe(destination?: Writable): Readable; 49461847f8eSopenharmony_ci /** 49561847f8eSopenharmony_ci * Registering Event Messages. 49661847f8eSopenharmony_ci * 49761847f8eSopenharmony_ci * @param { string } event - Registering Events. 49861847f8eSopenharmony_ci * @param { Callback<emitter.EventData> } callback - Event callback. 49961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 50061847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 50161847f8eSopenharmony_ci * 2.Incorrect parameter types. 50261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 50361847f8eSopenharmony_ci * @crossplatform 50461847f8eSopenharmony_ci * @atomicservice 50561847f8eSopenharmony_ci * @since 12 50661847f8eSopenharmony_ci */ 50761847f8eSopenharmony_ci on(event: string, callback: Callback<emitter.EventData>): void; 50861847f8eSopenharmony_ci /** 50961847f8eSopenharmony_ci * Cancel event message. 51061847f8eSopenharmony_ci * 51161847f8eSopenharmony_ci * @param { string } event - Registering Events. 51261847f8eSopenharmony_ci * @param { Callback<emitter.EventData> } callback - Event callback. 51361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 51461847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 51561847f8eSopenharmony_ci * 2.Incorrect parameter types. 51661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 51761847f8eSopenharmony_ci * @crossplatform 51861847f8eSopenharmony_ci * @atomicservice 51961847f8eSopenharmony_ci * @since 12 52061847f8eSopenharmony_ci */ 52161847f8eSopenharmony_ci off(event: string, callback?: Callback<emitter.EventData>): void; 52261847f8eSopenharmony_ci /** 52361847f8eSopenharmony_ci * It may be implemented by child classes, and if so, will be called by the Readable class methods only. 52461847f8eSopenharmony_ci * It must not be called directly. 52561847f8eSopenharmony_ci * 52661847f8eSopenharmony_ci * @param { Function } callback - Callback when the stream has completed the initial. 52761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 52861847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 52961847f8eSopenharmony_ci * 2.Incorrect parameter types; 53061847f8eSopenharmony_ci * 3.Parameter verification failed. 53161847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 53261847f8eSopenharmony_ci * @crossplatform 53361847f8eSopenharmony_ci * @atomicservice 53461847f8eSopenharmony_ci * @since 12 53561847f8eSopenharmony_ci */ 53661847f8eSopenharmony_ci doInitialize(callback: Function): void; 53761847f8eSopenharmony_ci /** 53861847f8eSopenharmony_ci * The specific implementation of data production. It must not be actively called. 53961847f8eSopenharmony_ci * After data production, Readable.push should be called to push the produced data into the buffer. 54061847f8eSopenharmony_ci * If push is not called, doRead will not be called again. 54161847f8eSopenharmony_ci * 54261847f8eSopenharmony_ci * @param { number } size - Expected length of the data to be read. 54361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 54461847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 54561847f8eSopenharmony_ci * 2.Incorrect parameter types; 54661847f8eSopenharmony_ci * 3.Parameter verification failed. 54761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 54861847f8eSopenharmony_ci * @crossplatform 54961847f8eSopenharmony_ci * @atomicservice 55061847f8eSopenharmony_ci * @since 12 55161847f8eSopenharmony_ci */ 55261847f8eSopenharmony_ci doRead(size: number): void; 55361847f8eSopenharmony_ci /** 55461847f8eSopenharmony_ci * Adds the generated data to the buffer. The return value indicates whether the data in the buffer has not 55561847f8eSopenharmony_ci * reached the highWaterMark (similar to Writable.write). If the chunk is null, all data has been generated. 55661847f8eSopenharmony_ci * 55761847f8eSopenharmony_ci * @param { Uint8Array | string | null } chunk - Binary data to be stored in the buffer. 55861847f8eSopenharmony_ci * @param { string } [encoding] - Binary data encoding type. 55961847f8eSopenharmony_ci * @returns { boolean } If true is returned, the data in the buffer reaches the highWaterMark. Otherwise, the 56061847f8eSopenharmony_ci * data in the buffer does not reach the highWaterMark. 56161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 56261847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 56361847f8eSopenharmony_ci * 2.Incorrect parameter types. 56461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 56561847f8eSopenharmony_ci * @crossplatform 56661847f8eSopenharmony_ci * @atomicservice 56761847f8eSopenharmony_ci * @since 12 56861847f8eSopenharmony_ci */ 56961847f8eSopenharmony_ci push(chunk: Uint8Array | string | null, encoding?: string): boolean; 57061847f8eSopenharmony_ci /** 57161847f8eSopenharmony_ci * Returns boolean indicating whether it is in ObjectMode. 57261847f8eSopenharmony_ci * 57361847f8eSopenharmony_ci * @type { boolean } 57461847f8eSopenharmony_ci * @readonly 57561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 57661847f8eSopenharmony_ci * @crossplatform 57761847f8eSopenharmony_ci * @atomicservice 57861847f8eSopenharmony_ci * @since 12 57961847f8eSopenharmony_ci */ 58061847f8eSopenharmony_ci readonly readableObjectMode: boolean; 58161847f8eSopenharmony_ci /** 58261847f8eSopenharmony_ci * Is true if it is safe to call readable.read(), which means 58361847f8eSopenharmony_ci * the stream has not been destroyed or emitted 'error' or 'end'. 58461847f8eSopenharmony_ci * 58561847f8eSopenharmony_ci * @type { boolean } 58661847f8eSopenharmony_ci * @readonly 58761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 58861847f8eSopenharmony_ci * @crossplatform 58961847f8eSopenharmony_ci * @atomicservice 59061847f8eSopenharmony_ci * @since 12 59161847f8eSopenharmony_ci */ 59261847f8eSopenharmony_ci readonly readable: boolean; 59361847f8eSopenharmony_ci /** 59461847f8eSopenharmony_ci * Returns the value of highWatermark passed when creating this Readable. 59561847f8eSopenharmony_ci * 59661847f8eSopenharmony_ci * @type { number } 59761847f8eSopenharmony_ci * @readonly 59861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 59961847f8eSopenharmony_ci * @crossplatform 60061847f8eSopenharmony_ci * @atomicservice 60161847f8eSopenharmony_ci * @since 12 60261847f8eSopenharmony_ci */ 60361847f8eSopenharmony_ci readonly readableHighWatermark: number; 60461847f8eSopenharmony_ci /** 60561847f8eSopenharmony_ci * This property reflects the current state of the readable stream null/true/false. 60661847f8eSopenharmony_ci * 60761847f8eSopenharmony_ci * @type { boolean | null } 60861847f8eSopenharmony_ci * @readonly 60961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 61061847f8eSopenharmony_ci * @crossplatform 61161847f8eSopenharmony_ci * @atomicservice 61261847f8eSopenharmony_ci * @since 12 61361847f8eSopenharmony_ci */ 61461847f8eSopenharmony_ci readonly readableFlowing: boolean | null; 61561847f8eSopenharmony_ci /** 61661847f8eSopenharmony_ci * Size of the data that can be read, in bytes or objects. 61761847f8eSopenharmony_ci * 61861847f8eSopenharmony_ci * @type { number } 61961847f8eSopenharmony_ci * @readonly 62061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 62161847f8eSopenharmony_ci * @crossplatform 62261847f8eSopenharmony_ci * @atomicservice 62361847f8eSopenharmony_ci * @since 12 62461847f8eSopenharmony_ci */ 62561847f8eSopenharmony_ci readonly readableLength: number; 62661847f8eSopenharmony_ci /** 62761847f8eSopenharmony_ci * Getter for the property encoding of a given Readable stream. The encoding property can be set using the 62861847f8eSopenharmony_ci * readable.setEncoding() method. 62961847f8eSopenharmony_ci * 63061847f8eSopenharmony_ci * @type { string | null } 63161847f8eSopenharmony_ci * @readonly 63261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 63361847f8eSopenharmony_ci * @crossplatform 63461847f8eSopenharmony_ci * @atomicservice 63561847f8eSopenharmony_ci * @since 12 63661847f8eSopenharmony_ci */ 63761847f8eSopenharmony_ci readonly readableEncoding: string | null; 63861847f8eSopenharmony_ci /** 63961847f8eSopenharmony_ci * Whether all data has been generated. 64061847f8eSopenharmony_ci * 64161847f8eSopenharmony_ci * @type { boolean } 64261847f8eSopenharmony_ci * @readonly 64361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 64461847f8eSopenharmony_ci * @crossplatform 64561847f8eSopenharmony_ci * @atomicservice 64661847f8eSopenharmony_ci * @since 12 64761847f8eSopenharmony_ci */ 64861847f8eSopenharmony_ci readonly readableEnded: boolean; 64961847f8eSopenharmony_ci } 65061847f8eSopenharmony_ci /** 65161847f8eSopenharmony_ci * Duplex streams are streams that implement both the Readable streams and Writable streams interfaces. 65261847f8eSopenharmony_ci * 65361847f8eSopenharmony_ci * @extends Readable 65461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 65561847f8eSopenharmony_ci * @crossplatform 65661847f8eSopenharmony_ci * @atomicservice 65761847f8eSopenharmony_ci * @since 12 65861847f8eSopenharmony_ci */ 65961847f8eSopenharmony_ci class Duplex extends Readable { 66061847f8eSopenharmony_ci /** 66161847f8eSopenharmony_ci * The Duplex constructor. 66261847f8eSopenharmony_ci * 66361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 66461847f8eSopenharmony_ci * @crossplatform 66561847f8eSopenharmony_ci * @atomicservice 66661847f8eSopenharmony_ci * @since 12 66761847f8eSopenharmony_ci */ 66861847f8eSopenharmony_ci constructor(); 66961847f8eSopenharmony_ci /** 67061847f8eSopenharmony_ci * writes a chunk to Writable and invokes callback when the chunk is flushed. The return value indicates 67161847f8eSopenharmony_ci * whether the internal buffer of the Writable reaches the hightWaterMark. If true is returned, the buffer 67261847f8eSopenharmony_ci * does not reach the hightWaterMark. If false is returned, the buffer has been reached. The write function 67361847f8eSopenharmony_ci * should be called after the drain event is triggered. If the write function is called continuously, 67461847f8eSopenharmony_ci * the chunk is still added to the buffer until the memory overflows 67561847f8eSopenharmony_ci * 67661847f8eSopenharmony_ci * @param { string | Uint8Array } [chunk] - Data to be written. 67761847f8eSopenharmony_ci * @param { string } [encoding] - Encoding type. 67861847f8eSopenharmony_ci * @param { Function } [callback] - Callback after writing. 67961847f8eSopenharmony_ci * @returns { boolean } Write success returns true, write failure returns false. 68061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 68161847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 68261847f8eSopenharmony_ci * 2.Incorrect parameter types; 68361847f8eSopenharmony_ci * 3.Parameter verification failed. 68461847f8eSopenharmony_ci * @throws { BusinessError } 10200036 - The stream has been ended. 68561847f8eSopenharmony_ci * @throws { BusinessError } 10200037 - The callback is invoked multiple times consecutively. 68661847f8eSopenharmony_ci * @throws { BusinessError } 10200039 - The doTransform method has not been implemented for a class that inherits from Transform. 68761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 68861847f8eSopenharmony_ci * @crossplatform 68961847f8eSopenharmony_ci * @atomicservice 69061847f8eSopenharmony_ci * @since 12 69161847f8eSopenharmony_ci */ 69261847f8eSopenharmony_ci write(chunk?: string | Uint8Array, encoding?: string, callback?: Function): boolean; 69361847f8eSopenharmony_ci /** 69461847f8eSopenharmony_ci * Write the last chunk to Writable. 69561847f8eSopenharmony_ci * 69661847f8eSopenharmony_ci * @param { string | Uint8Array } [chunk] - Data to be written. 69761847f8eSopenharmony_ci * @param { string } [encoding] - Encoding type. 69861847f8eSopenharmony_ci * @param { Function } [callback] - Callback after writing. 69961847f8eSopenharmony_ci * @returns { Writable } Returns the Writable object. 70061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 70161847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 70261847f8eSopenharmony_ci * 2.Incorrect parameter types; 70361847f8eSopenharmony_ci * 3.Parameter verification failed. 70461847f8eSopenharmony_ci * @throws { BusinessError } 10200039 - The doTransform method has not been implemented for a class that inherits from Transform. 70561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 70661847f8eSopenharmony_ci * @crossplatform 70761847f8eSopenharmony_ci * @atomicservice 70861847f8eSopenharmony_ci * @since 12 70961847f8eSopenharmony_ci */ 71061847f8eSopenharmony_ci end(chunk?: string | Uint8Array, encoding?: string, callback?: Function): Writable; 71161847f8eSopenharmony_ci /** 71261847f8eSopenharmony_ci * Set the default encoding mode. 71361847f8eSopenharmony_ci * 71461847f8eSopenharmony_ci * @param { string } [encoding] - Encoding type.Default: utf8. 71561847f8eSopenharmony_ci * @returns { boolean } Setting successful returns true, setting failed returns false. 71661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 71761847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 71861847f8eSopenharmony_ci * 2.Incorrect parameter types; 71961847f8eSopenharmony_ci * 3.Parameter verification failed. 72061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 72161847f8eSopenharmony_ci * @crossplatform 72261847f8eSopenharmony_ci * @atomicservice 72361847f8eSopenharmony_ci * @since 12 72461847f8eSopenharmony_ci */ 72561847f8eSopenharmony_ci setDefaultEncoding(encoding?: string): boolean; 72661847f8eSopenharmony_ci /** 72761847f8eSopenharmony_ci * After the call, all Write operations will be forced to write to the buffer instead of being flushed. 72861847f8eSopenharmony_ci * 72961847f8eSopenharmony_ci * @returns { boolean } Setting successful returns true, setting failed returns false. 73061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 73161847f8eSopenharmony_ci * @crossplatform 73261847f8eSopenharmony_ci * @atomicservice 73361847f8eSopenharmony_ci * @since 12 73461847f8eSopenharmony_ci */ 73561847f8eSopenharmony_ci cork(): boolean; 73661847f8eSopenharmony_ci /** 73761847f8eSopenharmony_ci * After calling, flush all buffers. 73861847f8eSopenharmony_ci * 73961847f8eSopenharmony_ci * @returns { boolean } Setting successful returns true, setting failed returns false. 74061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 74161847f8eSopenharmony_ci * @crossplatform 74261847f8eSopenharmony_ci * @atomicservice 74361847f8eSopenharmony_ci * @since 12 74461847f8eSopenharmony_ci */ 74561847f8eSopenharmony_ci uncork(): boolean; 74661847f8eSopenharmony_ci /** 74761847f8eSopenharmony_ci * Implemented by subclass inheritance. The implementation logic of flushing chunks in the buffer must not be 74861847f8eSopenharmony_ci * directly called. The call is controlled by Writable.write. 74961847f8eSopenharmony_ci * 75061847f8eSopenharmony_ci * @param { string | Uint8Array } [chunk] - Data to be written. 75161847f8eSopenharmony_ci * @param { string } [encoding] - Encoding type. 75261847f8eSopenharmony_ci * @param { Function } [callback] - Callback after writing. 75361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 75461847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 75561847f8eSopenharmony_ci * 2.Incorrect parameter types; 75661847f8eSopenharmony_ci * 3.Parameter verification failed. 75761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 75861847f8eSopenharmony_ci * @crossplatform 75961847f8eSopenharmony_ci * @atomicservice 76061847f8eSopenharmony_ci * @since 12 76161847f8eSopenharmony_ci */ 76261847f8eSopenharmony_ci doWrite(chunk: string | Uint8Array, encoding: string, callback: Function): void; 76361847f8eSopenharmony_ci /** 76461847f8eSopenharmony_ci * The implementation logic of flushing chunks in the buffer in batches should not be actively called. 76561847f8eSopenharmony_ci * The call is controlled by Writable.write. 76661847f8eSopenharmony_ci * 76761847f8eSopenharmony_ci * @param { string[] | Uint8Array[] } [chunks] - Data to be written. 76861847f8eSopenharmony_ci * @param { Function } [callback] - Callback after writing. 76961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 77061847f8eSopenharmony_ci * 1.Mandatory parameters are left unspecified; 77161847f8eSopenharmony_ci * 2.Incorrect parameter types; 77261847f8eSopenharmony_ci * 3.Parameter verification failed. 77361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 77461847f8eSopenharmony_ci * @crossplatform 77561847f8eSopenharmony_ci * @atomicservice 77661847f8eSopenharmony_ci * @since 12 77761847f8eSopenharmony_ci */ 77861847f8eSopenharmony_ci doWritev(chunks: string[] | Uint8Array[], callback: Function): void; 77961847f8eSopenharmony_ci /** 78061847f8eSopenharmony_ci * Returns boolean indicating whether it is in ObjectMode. 78161847f8eSopenharmony_ci * 78261847f8eSopenharmony_ci * @type { boolean } 78361847f8eSopenharmony_ci * @readonly 78461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 78561847f8eSopenharmony_ci * @crossplatform 78661847f8eSopenharmony_ci * @atomicservice 78761847f8eSopenharmony_ci * @since 12 78861847f8eSopenharmony_ci */ 78961847f8eSopenharmony_ci readonly writableObjectMode: boolean; 79061847f8eSopenharmony_ci /** 79161847f8eSopenharmony_ci * Value of highWatermark. 79261847f8eSopenharmony_ci * 79361847f8eSopenharmony_ci * @type { number } 79461847f8eSopenharmony_ci * @readonly 79561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 79661847f8eSopenharmony_ci * @crossplatform 79761847f8eSopenharmony_ci * @atomicservice 79861847f8eSopenharmony_ci * @since 12 79961847f8eSopenharmony_ci */ 80061847f8eSopenharmony_ci readonly writableHighWatermark: number; 80161847f8eSopenharmony_ci /** 80261847f8eSopenharmony_ci * Is true if it is safe to call writable.write(), which means the stream has not been destroyed, error or end. 80361847f8eSopenharmony_ci * 80461847f8eSopenharmony_ci * @type { boolean } 80561847f8eSopenharmony_ci * @readonly 80661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 80761847f8eSopenharmony_ci * @crossplatform 80861847f8eSopenharmony_ci * @atomicservice 80961847f8eSopenharmony_ci * @since 12 81061847f8eSopenharmony_ci */ 81161847f8eSopenharmony_ci readonly writable: boolean; 81261847f8eSopenharmony_ci /** 81361847f8eSopenharmony_ci * Size of data that can be flushed, in bytes or objects. 81461847f8eSopenharmony_ci * 81561847f8eSopenharmony_ci * @type { number } 81661847f8eSopenharmony_ci * @readonly 81761847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 81861847f8eSopenharmony_ci * @crossplatform 81961847f8eSopenharmony_ci * @atomicservice 82061847f8eSopenharmony_ci * @since 12 82161847f8eSopenharmony_ci */ 82261847f8eSopenharmony_ci readonly writableLength: number; 82361847f8eSopenharmony_ci /** 82461847f8eSopenharmony_ci * Number of times writable.uncork() needs to be called in order to fully uncork the stream. 82561847f8eSopenharmony_ci * 82661847f8eSopenharmony_ci * @type { number } 82761847f8eSopenharmony_ci * @readonly 82861847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 82961847f8eSopenharmony_ci * @crossplatform 83061847f8eSopenharmony_ci * @atomicservice 83161847f8eSopenharmony_ci * @since 12 83261847f8eSopenharmony_ci */ 83361847f8eSopenharmony_ci readonly writableCorked: number; 83461847f8eSopenharmony_ci /** 83561847f8eSopenharmony_ci * Whether Writable.end has been called. 83661847f8eSopenharmony_ci * 83761847f8eSopenharmony_ci * @type { boolean } 83861847f8eSopenharmony_ci * @readonly 83961847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 84061847f8eSopenharmony_ci * @crossplatform 84161847f8eSopenharmony_ci * @atomicservice 84261847f8eSopenharmony_ci * @since 12 84361847f8eSopenharmony_ci */ 84461847f8eSopenharmony_ci readonly writableEnded: boolean; 84561847f8eSopenharmony_ci /** 84661847f8eSopenharmony_ci * Whether Writable.end has been called and all buffers have been flushed. 84761847f8eSopenharmony_ci * 84861847f8eSopenharmony_ci * @type { boolean } 84961847f8eSopenharmony_ci * @readonly 85061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang 85161847f8eSopenharmony_ci * @crossplatform 85261847f8eSopenharmony_ci * @atomicservice 85361847f8eSopenharmony_ci * @since 12 85461847f8eSopenharmony_ci */ 85561847f8eSopenharmony_ci readonly writableFinished: boolean; 85661847f8eSopenharmony_ci } 85761847f8eSopenharmony_ci} 85861847f8eSopenharmony_ciexport default stream;