diff --git a/en/application-dev/ability/fa-formability.md b/en/application-dev/ability/fa-formability.md index 49f2cf96d7d515fe60c9b8d85e793e7c9fbb9111..a39894a015af16fc254356927d4480b66d3b71e4 100644 --- a/en/application-dev/ability/fa-formability.md +++ b/en/application-dev/ability/fa-formability.md @@ -231,7 +231,7 @@ You should override **onDestroy** to delete widget data. } ``` -For details about the persistence method, see [Lightweight Data Store Development](../database/database-preference-guidelines.md). +For details about the persistence method, see [Lightweight Data Store Development](../database/database-storage-guidelines.md). Note that the **Want** passed by the widget host to the widget provider contains a temporary flag, indicating whether the requested widget is a temporary one. diff --git a/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md b/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md index 21cff7a9c850cc316aac00520824a8446cb8980e..39fa47376a819eeaa07fcb5e15caef9743cfc0e4 100644 --- a/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md +++ b/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md @@ -1,11 +1,11 @@ # MissionSnapshot -> ![icon-note.gif](public_sys-resources/icon-note.gif)**NOTE** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -Provides snapshot of a mission. +Provides the snapshot of a mission. ## Modules to Import diff --git a/en/application-dev/reference/apis/js-apis-appmanager.md b/en/application-dev/reference/apis/js-apis-appmanager.md index 04e994eb648946046319cdd55b25a908362c7b0d..70becd563ec1143c93110fc9381eed8f903a82c8 100644 --- a/en/application-dev/reference/apis/js-apis-appmanager.md +++ b/en/application-dev/reference/apis/js-apis-appmanager.md @@ -69,7 +69,7 @@ Checks whether this application is undergoing a stability test. This API uses a isRamConstrainedDevice(): Promise\; -Checks whether this application is running in a RAM constrained device. This API uses a promise to return the result. +Checks whether this application is running on a RAM constrained device. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -77,7 +77,7 @@ Checks whether this application is running in a RAM constrained device. This API | Type| Description| | -------- | -------- | - | Promise<boolean> | Promise used to return whether the application is running in a RAM constrained device. If the application is running in a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| + | Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| **Example** @@ -93,7 +93,7 @@ Checks whether this application is running in a RAM constrained device. This API isRamConstrainedDevice(callback: AsyncCallback\): void; -Checks whether this application is running in a RAM constrained device. This API uses an asynchronous callback to return the result. +Checks whether this application is running on a RAM constrained device. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -101,7 +101,7 @@ Checks whether this application is running in a RAM constrained device. This API | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running in a RAM constrained device. If the application is running in a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| + | callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| **Example** @@ -214,4 +214,4 @@ Obtains information about the running processes. This API uses an asynchronous c | pid8+ | Read only | number | No | Process ID. | | uid8+ | Read only | number | No | User ID.| | processName8+ | Read only | string | No | Process name.| -| bundleNames8+ | Read only | Array\ | No | **bundleName** array in the running process.| +| bundleNames8+ | Read only | Array\ | No | **bundleName** array in the running processes.| diff --git a/en/application-dev/reference/apis/js-apis-battery-info.md b/en/application-dev/reference/apis/js-apis-battery-info.md index a84c0cb9477cbdbbee02eba14c041fe18c7c8d29..9c0a816ef556a0d6bb80266e4a4a77730783c2a7 100644 --- a/en/application-dev/reference/apis/js-apis-battery-info.md +++ b/en/application-dev/reference/apis/js-apis-battery-info.md @@ -8,7 +8,7 @@ The Battery Info module provides APIs for querying the charger type, battery hea ## Modules to Import -``` +```js import batteryInfo from '@ohos.batteryInfo'; ``` @@ -126,7 +126,7 @@ Describes battery information. - Example - ``` + ```js import batteryInfo from '@ohos.batteryInfo'; var batterySoc = batteryInfo.batterySOC; ``` diff --git a/en/application-dev/reference/apis/js-apis-bluetooth.md b/en/application-dev/reference/apis/js-apis-bluetooth.md index 947a2723837dc43af7a7b4473538931c1b17e009..48f8b4f7c021b64e7117c6da5a69095c11d53bcf 100644 --- a/en/application-dev/reference/apis/js-apis-bluetooth.md +++ b/en/application-dev/reference/apis/js-apis-bluetooth.md @@ -8,7 +8,7 @@ ## Modules to Import -``` +```js import bluetooth from '@ohos.bluetooth'; ``` diff --git a/en/application-dev/reference/apis/js-apis-brightness.md b/en/application-dev/reference/apis/js-apis-brightness.md index c76047bde1b92f0e213a58091aafcf2a41d8793d..6bbea8b08a752972bcc9354b63841831ae837a88 100644 --- a/en/application-dev/reference/apis/js-apis-brightness.md +++ b/en/application-dev/reference/apis/js-apis-brightness.md @@ -8,7 +8,7 @@ The Brightness module provides an API for setting the screen brightness. ## Modules to Import -``` +```js import brightness from '@ohos.brightness'; ``` @@ -30,6 +30,6 @@ This is a system API and cannot be called by third-party applications. **Example** -``` +```js brightness.setValue(128); ``` diff --git a/en/application-dev/reference/apis/js-apis-convertxml.md b/en/application-dev/reference/apis/js-apis-convertxml.md index f403580810cb946d98aed4ff2f9808323656e89e..7bf2fc1da26f70ac24d95fab4cdb3333d9517ead 100644 --- a/en/application-dev/reference/apis/js-apis-convertxml.md +++ b/en/application-dev/reference/apis/js-apis-convertxml.md @@ -39,7 +39,7 @@ Converts an XML text into a JavaScript object. - Example - ``` + ```js let xml = '' + '' + diff --git a/en/application-dev/reference/apis/js-apis-device-info.md b/en/application-dev/reference/apis/js-apis-device-info.md index 3c1a3efd773b126a4ce9e7d371c2946ddada0cf6..0f5dd2a794e92690820f12d6ab8e82e9f6b3b340 100644 --- a/en/application-dev/reference/apis/js-apis-device-info.md +++ b/en/application-dev/reference/apis/js-apis-device-info.md @@ -5,7 +5,7 @@ ## Modules to Import -``` +```ts import deviceInfo from '@ohos.deviceInfo' ``` diff --git a/en/application-dev/reference/apis/js-apis-document.md b/en/application-dev/reference/apis/js-apis-document.md new file mode 100644 index 0000000000000000000000000000000000000000..0f2de0b217af39ab8b7506db1c92cee141c3bde3 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-document.md @@ -0,0 +1,130 @@ +# File Interaction + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+- The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. +- The APIs of this module will be deprecated and are not recommended for use. An exception will be thrown if any of the APIs is called. +## Modules to Import + +```js +import document from '@ohos.document'; +``` + +## document.choose + +choose(type:string[]): Promise<string> + +Chooses a file of the specified type using the file manager. This method uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------------------- | + | type | string[] | No | Type of the file to choose.| + +- Return value + + | Type | Description | + | --------------------- | -------------- | + | Promise<string> | Promise used to return the result. An error code is returned.| + +- Example + + ```js + await document.choose(type); + ``` +## document.choose + +choose(callback:AsyncCallback<string>): void + +Chooses a file using the file manager. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned.| + +- Example + + ```js + await document.choose(function(err, uri) { + // Do something with the URI. + }); + ``` +## document.choose + +choose(type:string[], callback:AsyncCallback<string>): void + +Chooses a file of the specified type using the file manager. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | type | string[] | No | Type of the file to choose.| + | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned.| + +- Example + + ```js + await document.choose(type, function(err, uri) { + // Do something with the URI. + }); + ``` + +## document.show + +show(url:string, type:string):Promise<number> + +Opens a file. This method uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + + | Name| Type | Mandatory| Description | + | ---- | ------ | ---- | ---------------------------- | + | uri | string | Yes | URI of the file to open.| + | type | string | Yes | Type of the file to open.| + +- Return value + + | Type | Description | + | --------------------- | ------------ | + | Promise<void> | Promise used to return the result. An error code is returned.| + +- Example + + ```js + await document.show(uri, type); + ``` + +## document.show + +show(url:string, type:string, callback:AsyncCallback<void>): void + +Opens a file. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | uri | string | Yes | URI of the file to open.| + | type | string | Yes | Type of the file to open.| + | callback | AsyncCallback<void> | Yes | Callback used to return the result. An error code is returned. | + +- Example + + ```js + await document.show(uri, type, function(err) { + //do something + }); + ``` diff --git a/en/application-dev/reference/apis/js-apis-image.md b/en/application-dev/reference/apis/js-apis-image.md index 3fd4d48c7bed58bd32e75c5388ea582b62d2cea1..0e90ccb51db3dca11b0a8ca111d46a623771b50c 100644 --- a/en/application-dev/reference/apis/js-apis-image.md +++ b/en/application-dev/reference/apis/js-apis-image.md @@ -104,7 +104,7 @@ pixelmap.readPixelsToBuffer(readBuffer).then(() => { readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\): void -Reads image pixel map data and writes the data to an **ArrayBuffer**. This API uses a callback to return the result. +Reads image pixel map data and writes the data to an **ArrayBuffer**. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Image @@ -126,7 +126,7 @@ pixelmap.readPixelsToBuffer(readBuffer, () => { readPixels(area: PositionArea): Promise\ -Reads pixel map data in an area. This API uses a promise to return the data read. +Reads image pixel map data in an area. This API uses a promise to return the data read. **System capability**: SystemCapability.Multimedia.Image @@ -156,7 +156,7 @@ pixelmap.readPixels(area).then((data) => { readPixels(area: PositionArea, callback: AsyncCallback\): void -Reads image pixel map data in an area. This API uses a callback to return the data read. +Reads image pixel map data in an area. This API uses an asynchronous callback to return the data read. **System capability**: SystemCapability.Multimedia.Image @@ -200,7 +200,7 @@ Writes image pixel map data to an area. This API uses a promise to return the op | Name| Type | Mandatory| Description | | ------ | ------------------------------ | ---- | -------------------- | -| area | [PositionArea](#positionarea7) | Yes | Area to which the pixel map data will be written.| +| area | [PositionArea](#positionarea7) | Yes | Area to which the image pixel map data will be written.| **Return value** @@ -250,7 +250,7 @@ image.createPixelMap(color, opts) writePixels(area: PositionArea, callback: AsyncCallback\): void -Writes image pixel map data to an area. This API uses a callback to return the operation result. +Writes image pixel map data to an area. This API uses an asynchronous callback to return the operation result. **System capability**: SystemCapability.Multimedia.Image @@ -258,7 +258,7 @@ Writes image pixel map data to an area. This API uses a callback to return the o | Name | Type | Mandatory| Description | | --------- | ------------------------------ | ---- | ------------------------------ | -| area | [PositionArea](#positionarea7) | Yes | Area to which the pixel map data will be written. | +| area | [PositionArea](#positionarea7) | Yes | Area to which the image pixel map data will be written. | | callback: | AsyncCallback\ | Yes | Callback used to return the operation result. If the operation fails, an error message is returned.| **Example** @@ -308,7 +308,7 @@ pixelMap.writeBufferToPixels(colorBuffer).then(() => { writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback\): void -Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** object. This API uses a callback to return the result. +Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Image @@ -335,7 +335,7 @@ pixelMap.writeBufferToPixels(colorBuffer, function(err) { getImageInfo(): Promise\ -Obtains pixel map information about this image. This API uses a promise to return the information. +Obtains pixel map information of this image. This API uses a promise to return the information. **System capability**: SystemCapability.Multimedia.Image @@ -359,7 +359,7 @@ pixelMap.getImageInfo().then(function(info) { getImageInfo(callback: AsyncCallback\): void -Obtains pixel map information about this image. This API uses a callback to return the information. +Obtains pixel map information of this image. This API uses an asynchronous callback to return the information. **System capability**: SystemCapability.Multimedia.Image @@ -379,7 +379,7 @@ pixelmap.getImageInfo((imageInfo) => {}) getBytesNumberPerRow(): number -Obtains the number of bytes in each line of the image pixel map. +Obtains the number of bytes per line of the image pixel map. **System capability**: SystemCapability.Multimedia.Image @@ -387,7 +387,7 @@ Obtains the number of bytes in each line of the image pixel map. | Type | Description | | ------ | -------------------- | -| number | Number of bytes in each line.| +| number | Number of bytes per line.| **Example** @@ -440,7 +440,7 @@ Releases this **PixelMap** object. This API uses a promise to return the result. release(callback: AsyncCallback\): void -Releases this **PixelMap** object. This API uses a callback to return the result. +Releases this **PixelMap** object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Image @@ -522,7 +522,7 @@ Provides APIs to obtain image information. Before calling any API in **ImageSour getImageInfo(index: number, callback: AsyncCallback\): void -Obtains information about an image with the specified index. This API uses a callback to return the information. +Obtains information about an image with the specified index. This API uses an asynchronous callback to return the information. **System capability**: SystemCapability.Multimedia.Image @@ -543,7 +543,7 @@ imageSourceApi.getImageInfo(0,(error, imageInfo) => {}) getImageInfo(callback: AsyncCallback\): void -Obtains information about this image. This API uses a callback to return the information. +Obtains information about this image. This API uses an asynchronous callback to return the information. **System capability**: SystemCapability.Multimedia.Image @@ -620,7 +620,7 @@ imageSourceApi.getImageProperty("BitsPerSample") getImageProperty(key:string, callback: AsyncCallback\): void -Obtains the value of a property with the specified index in this image. This API uses a callback to return the result. +Obtains the value of a property with the specified index in this image. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Image @@ -641,7 +641,7 @@ imageSourceApi.getImageProperty("BitsPerSample",(error,data) => {}) getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCallback\): void -Obtains the value of a property in this image. This API uses a callback to return the property value in a string. +Obtains the value of a property in this image. This API uses an asynchronous callback to return the property value in a string. **System capability**: SystemCapability.Multimedia.Image @@ -663,7 +663,7 @@ imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => {}) createPixelMap(options?: DecodingOptions): Promise\ -Creates a **PixelMap** object based on image decoding parameters. This API uses a callback to return the result. +Creates a **PixelMap** object based on image decoding parameters. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Image @@ -690,7 +690,7 @@ imageSourceApi.createPixelMap().then(pixelmap => {}) createPixelMap(callback: AsyncCallback\): void -Creates a **PixelMap** object based on the default parameters. This API uses a callback to return the result. +Creates a **PixelMap** object based on the default parameters. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Image @@ -710,7 +710,7 @@ imageSourceApi.createPixelMap(pixelmap => {}) createPixelMap(options: DecodingOptions, callback: AsyncCallback\): void -Creates a **PixelMap** object based on image decoding parameters. This API uses a callback to return the result. +Creates a **PixelMap** object based on image decoding parameters. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Image @@ -731,7 +731,7 @@ imageSourceApi.createPixelMap(decodingOptions, pixelmap => {}) release(callback: AsyncCallback\): void -Releases this **ImageSource** instance. This API uses a callback to return the result. +Releases this **ImageSource** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Image @@ -801,7 +801,7 @@ Provide APIs to pack images. Before calling any API in **ImagePacker**, you must packing(source: ImageSource, option: PackingOption, callback: AsyncCallback>): void -Packs an image. This API uses a callback to return the result. +Packs an image. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Image @@ -854,7 +854,7 @@ imagePackerApi.packing(imageSourceApi, packOpts) packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\): void -Packs an image. This API uses a callback to return the result. +Packs an image. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Image @@ -907,7 +907,7 @@ imagePackerApi.packing(pixelMapApi, packOpts) release(callback: AsyncCallback\): void -Releases this **ImagePacker** instance. This API uses a callback to return the result. +Releases this **ImagePacker** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Image @@ -1058,7 +1058,7 @@ Describes the exchangeable image file format (Exif) information of an image. | Name | Default Value | Description | | ----------------- | ----------------- | -------------------- | -| BITS_PER_SAMPLE | "BitsPerSample" | Number of bytes in each pixel. | +| BITS_PER_SAMPLE | "BitsPerSample" | Number of bits per pixel. | | ORIENTATION | "Orientation" | Image orientation. | | IMAGE_LENGTH | "ImageLength" | Image length. | | IMAGE_WIDTH | "ImageWidth" | Image width. | diff --git a/en/application-dev/reference/apis/js-apis-power.md b/en/application-dev/reference/apis/js-apis-power.md index ca7e76cf6defcf233d399b4c0b5c9e5a8d588299..ad6e437f09767e362b2787f5ee78dd58d1a65165 100644 --- a/en/application-dev/reference/apis/js-apis-power.md +++ b/en/application-dev/reference/apis/js-apis-power.md @@ -8,7 +8,7 @@ The Power Manager module provides APIs for rebooting and shutting down the syste ## Modules to Import -``` +```js import power from '@ohos.power'; ``` @@ -35,7 +35,7 @@ This is a system API and cannot be called by third-party applications. **Example** -``` +```js power.shutdownDevice("shutdown_test"); console.info('power_shutdown_device_test success') ``` @@ -57,7 +57,7 @@ Reboots the system. **Example** -``` +```js power.rebootDevice("reboot_test"); console.info('power_reboot_device_test success') ``` @@ -77,7 +77,7 @@ Checks the screen status of the current device. **Example** -``` +```js power.isScreenOn((error, screenOn) => { if (typeof error === "undefined") { console.info('screenOn status is ' + screenOn); @@ -101,7 +101,7 @@ Checks the screen status of the current device. **Example** -``` +```js power.isScreenOn() .then(screenOn => { console.info('screenOn status is ' + screenOn); diff --git a/en/application-dev/reference/apis/js-apis-process.md b/en/application-dev/reference/apis/js-apis-process.md index 2eb5e69b83605ca414d5574bd76f6ce09200d2e0..f99ddb6580e1d79981282bcd4f35e36d2b28efe5 100755 --- a/en/application-dev/reference/apis/js-apis-process.md +++ b/en/application-dev/reference/apis/js-apis-process.md @@ -60,7 +60,7 @@ Waits until the child process ends. This method uses a promise to return the exi **Example** -``` +```js var child = process.runCmd('ls'); var result = child.wait(); result.then(val=>{ @@ -85,7 +85,7 @@ Obtains the standard output of the child process. **Example** -``` +```js var child = process.runCmd('ls'); var result = child.wait(); child.getOutput.then(val=>{ @@ -110,7 +110,7 @@ Obtains the standard error output of the child process. **Example** -``` +```js var child = process.runCmd('madir test.text'); var result = child.wait(); child.getErrorOutput.then(val=>{ @@ -129,7 +129,7 @@ Closes the child process in running. **Example** -``` +```js var child = process.runCmd('sleep 5; ls'); child.close(); ``` @@ -151,7 +151,7 @@ Sends a signal to the specified child process to terminate it. **Example** -``` +```js var child = process.runCmd('sleep 5; ls'); child.kill(9); ``` @@ -173,7 +173,7 @@ Checks whether this process is isolated. **Example** -``` +```js var result = process.isIsolatedProcess(); ``` @@ -200,7 +200,7 @@ Checks whether a UID belongs to this app. **Example** -``` +```js var result = process.isAppUid(688); ``` @@ -221,7 +221,7 @@ Checks whether this process is running in a 64-bit environment. **Example** -``` +```js var ressult = process.is64Bit(); ``` @@ -248,7 +248,7 @@ Obtains the process UID based on the process name. **Example** -``` +```js var pres = process.getUidForName("tool") ``` @@ -275,7 +275,7 @@ Obtains the thread priority based on the specified TID. **Example** -``` +```js var tid = process.getTid(); var pres = process.getThreadPriority(tid); ``` @@ -297,7 +297,7 @@ Obtains the duration, in milliseconds, from the time the system starts to the ti **Example** -``` +```js var realtime = process.getStartRealtime(); ``` @@ -317,7 +317,7 @@ Obtains the CPU time (in milliseconds) from the time the process starts to the c **Example** -``` +```js var result = process.getPastCpuTime() ; ``` @@ -344,7 +344,7 @@ Obtains the system configuration. **Example** -``` +```js var _SC_ARG_MAX = 0 var pres = process.getSystemConfig(_SC_ARG_MAX) ``` @@ -372,7 +372,7 @@ Obtains the value of an environment variable. **Example** -``` +```js var pres = process.getEnvironmentVar("PATH") ``` @@ -408,7 +408,7 @@ Forks a new process to run a shell command and returns the **ChildProcess** obje **Example** -``` +```js var child = process.runCmd('ls', { maxBuffer : 2 }); var result = child.wait(); child.getOutput.then(val=>{ @@ -427,7 +427,7 @@ Aborts a process and generates a core file. This method will cause a process to **Example** -``` +```js process.abort(); ``` @@ -455,7 +455,7 @@ Stores the events triggered by the user. **Example** -``` +```js process.on("data", (e)=>{ console.log("data callback"); }) @@ -484,7 +484,7 @@ Deletes the event stored by the user. **Example** -``` +```js process.on("data", (e)=>{ console.log("data callback"); }) @@ -510,7 +510,7 @@ Exercise caution when using this API. **Example** -``` +```js process.exit(0); ``` @@ -525,7 +525,7 @@ Obtains the working directory of this process. **Example** -``` +```js var path = process.cwd(); ``` @@ -546,7 +546,7 @@ Changes the working directory of this process. **Example** -``` +```js process.chdir('/system'); ``` @@ -567,7 +567,7 @@ Obtains the running time of this process. **Example** -``` +```js var time = process.uptime(); ``` @@ -594,7 +594,7 @@ Sends a signal to the specified process to terminate it. | boolean | Returns **true** if the signal is sent successfully; returns **false** otherwise.| **Example** -``` +```js var pres = process.pid var result = that.kill(pres, 28) ``` diff --git a/en/application-dev/reference/apis/js-apis-screen-lock.md b/en/application-dev/reference/apis/js-apis-screen-lock.md index 3c2bea19bafdba3fe50485852c8945a926b20932..fa0689478926d241372095e4dcb7dcb2e0177b15 100644 --- a/en/application-dev/reference/apis/js-apis-screen-lock.md +++ b/en/application-dev/reference/apis/js-apis-screen-lock.md @@ -8,7 +8,7 @@ ## Modules to Import -``` +```js import screenlock from '@ohos.screenLock'; ``` @@ -28,7 +28,7 @@ Checks whether the screen is locked. This method uses an asynchronous callback t - Example - ``` + ```js screenlock.isScreenLocked((err, data)=>{ if (err) { console.error('isScreenLocked callback error -> ${JSON.stringify(err)}'); @@ -54,7 +54,7 @@ Checks whether the screen is locked. This method uses a promise to return the re - Example - ``` + ```js screenlock.isScreenLocked().then((data) => { console.log('isScreenLocked success: data -> ${JSON.stringify(data)}'); }).catch((err) => { @@ -81,7 +81,7 @@ Checks whether a device is in secure mode. This method uses an asynchronous call - Example - ``` + ```js screenlock.isSecureMode((err, data)=>{ if (err) { console.error('isSecureMode callback error -> ${JSON.stringify(err)}'); @@ -107,7 +107,7 @@ Checks whether a device is in secure mode. This method uses a promise to return - Example - ``` + ```js screenlock.isSecureMode().then((data) => { console.log('isSecureMode success: data->${JSON.stringify(data)}'); }).catch((err) => { @@ -134,7 +134,7 @@ Unlocks the screen. This method uses an asynchronous callback to return the resu - Example - ``` + ```js screenlock.unlockScreen((err)=>{ if (err) { console.error('unlockScreen callback error -> ${JSON.stringify(err)}'); @@ -160,7 +160,7 @@ Unlocks the screen. This method uses a promise to return the result. - Example - ``` + ```js screenlock.unlockScreen().then(() => { console.log('unlockScreen success'); }).catch((err) => { diff --git a/en/application-dev/reference/apis/js-apis-settings.md b/en/application-dev/reference/apis/js-apis-settings.md index 82ae2c2f0c346f80cf133ec75700a78ff4cb59c1..9b56d25f9f841be73f607a6ef249d57c3f3f3a8d 100644 --- a/en/application-dev/reference/apis/js-apis-settings.md +++ b/en/application-dev/reference/apis/js-apis-settings.md @@ -9,7 +9,7 @@ This module provides APIs for setting data items. ## Modules to Import -``` +```typescript import settings from '@ohos.settings'; ``` @@ -34,7 +34,7 @@ Obtains the URI of a data item. | string | URI of the data item.| - Example - ``` + ```typescript // Obtain the URI of a data item. let urivar = settings.getUriSync('settings.screen.brightness'); ``` @@ -61,7 +61,7 @@ Obtains the value of a data item. | string | Value of the data item.| - Example - ``` + ```typescript import featureAbility from '@ohos.featureAbility'; // Obtain the value of 'settings.screen.brightness' (this data item already exists in the database). @@ -96,7 +96,7 @@ If the specified data item exists in the database, the **setValueSync** method u | boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.| - Example - ``` + ```typescript import featureAbility from '@ohos.featureAbility'; // Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync diff --git a/en/application-dev/reference/apis/js-apis-system-app.md b/en/application-dev/reference/apis/js-apis-system-app.md index db1fc9a0e06586e8361820be632c234ebc9b4fec..761d2276e31642f1890ce4127929fb9272c62602 100644 --- a/en/application-dev/reference/apis/js-apis-system-app.md +++ b/en/application-dev/reference/apis/js-apis-system-app.md @@ -138,7 +138,7 @@ Sets the maximum size (in bytes) of the image data cached in the memory before d export default { onCreate() { - app.setImageRawDataCacheSize(104,857,600) // Set the upper limit of the memory for caching image data before decoding to 100 MB. + app.setImageRawDataCacheSize(100) // Set the upper limit of the memory for caching image data before decoding to 100 MB. console.info('Application onCreate') }, onDestroy() { @@ -168,7 +168,7 @@ Sets the maximum size of the image file cache (in bytes) to speed up the loading export default { onCreate() { - app.setImageFileCacheSize(209,715,200) // Set the upper limit of the image file cache to 200 MB. + app.setImageFileCacheSize(200) // Set the upper limit of the image file cache to 200 MB. console.info('Application onCreate') }, onDestroy() { diff --git a/en/application-dev/reference/apis/js-apis-system-battery.md b/en/application-dev/reference/apis/js-apis-system-battery.md index c65bc13c40412db14b9e0f624db9e37a18f1098e..596084f8483fad2e3c0971fdd6161a1062a23fcf 100644 --- a/en/application-dev/reference/apis/js-apis-system-battery.md +++ b/en/application-dev/reference/apis/js-apis-system-battery.md @@ -9,7 +9,7 @@ ## Modules to Import -``` +```js import battery from '@system.battery'; ``` @@ -39,7 +39,7 @@ The following value will be returned when the check result is obtained. **Example** -``` +```js export default { getStatus() { battery.getStatus({ diff --git a/en/application-dev/reference/apis/js-apis-system-brightness.md b/en/application-dev/reference/apis/js-apis-system-brightness.md index ce21ce2e7c13ac2b22e5ae026259d685b401c5e9..3b1731b865d28bab4708e8613e6969529ed21cb9 100644 --- a/en/application-dev/reference/apis/js-apis-system-brightness.md +++ b/en/application-dev/reference/apis/js-apis-system-brightness.md @@ -9,7 +9,7 @@ ## Modules to Import -``` +```js import brightness from '@system.brightness'; ``` @@ -38,7 +38,7 @@ The following values will be returned when the operation is successful. **Example** -``` +```js export default { getValue() { brightness.getValue({ @@ -73,7 +73,7 @@ Sets the screen brightness. **Example** -``` +```js export default { setValue() { brightness.setValue({ @@ -114,7 +114,7 @@ The following values will be returned when the operation is successful. **Example** -``` +```js export default { getMode() { brightness.getMode({ @@ -149,7 +149,7 @@ Sets the screen brightness adjustment mode. **Example** -``` +```js export default { setMode() { brightness.setMode({ @@ -185,7 +185,7 @@ Sets whether to always keep the screen on. Call this API in **onShow()**. **Example** -``` +```js export default { setKeepScreenOn() { brightness.setKeepScreenOn({ diff --git a/en/application-dev/reference/apis/js-apis-system-parameter.md b/en/application-dev/reference/apis/js-apis-system-parameter.md index 29c1e580b1e2ac03e9c0cb88922d3a640485d8bf..c111c6c2cbfa5e809816b3246a28ac8114e35f76 100644 --- a/en/application-dev/reference/apis/js-apis-system-parameter.md +++ b/en/application-dev/reference/apis/js-apis-system-parameter.md @@ -6,7 +6,7 @@ ## Modules to Import -``` +```ts import parameter from '@ohos.systemParameter' ``` @@ -34,7 +34,7 @@ Obtains the value of the attribute with the specified key. **Example** -``` +```ts try { var info = parameter.getSync("test.parameter.key"); console.log(JSON.stringify(info)); @@ -61,7 +61,7 @@ Obtains the value of the attribute with the specified key. This API uses an asyn **Example** -``` +```ts try { parameter.get("test.parameter.key", function (err, data) { if (err == undefined) { @@ -93,7 +93,7 @@ Obtains the value of the attribute with the specified key. This API uses an asyn **Example** -``` +```ts try { parameter.get("test.parameter.key", "default", function (err, data) { if (err == undefined) { @@ -131,7 +131,7 @@ Obtains the value of the attribute with the specified key. This API uses a promi **Example** -``` +```ts try { var p = parameter.get("test.parameter.key"); p.then(function (value) { @@ -162,7 +162,7 @@ Sets a value for the attribute with the specified key. **Example** -``` +```ts try { parameter.setSync("test.parameter.key", "default"); }catch(e){ @@ -189,7 +189,7 @@ Sets a value for the attribute with the specified key. This API uses an asynchro **Example** -``` +```ts try { parameter.set("test.parameter.key", "testValue", function (err, data) { if (err == undefined) { @@ -226,7 +226,7 @@ Sets a value for the attribute with the specified key. This API uses a promise t **Example** -``` +```ts try { var p = para.set("test.parameter.key", "testValue"); p.then(function (value) { diff --git a/en/application-dev/reference/apis/js-apis-thermal.md b/en/application-dev/reference/apis/js-apis-thermal.md index f1b246f11ff17c4b2b31a1ca16210d5ce11c48bc..a71897b34211faccfe2254e77f89dc10ff644244 100644 --- a/en/application-dev/reference/apis/js-apis-thermal.md +++ b/en/application-dev/reference/apis/js-apis-thermal.md @@ -8,7 +8,7 @@ This module provides thermal level-related callback and query APIs to obtain the ## Modules to Import -``` +```js import thermal from '@ohos.thermal'; ``` @@ -46,7 +46,7 @@ Subscribes to thermal level changes. **Example** -``` +```js var lev = 0; thermal.subscribeThermalLevel((lev) => { console.info("Thermal level is: " + lev); @@ -69,7 +69,7 @@ Unsubscribes from thermal level changes. **Example** -``` +```js thermal.unsubscribeThermalLevel(() => { console.info("Unsubscribe completed."); }); @@ -91,7 +91,7 @@ Obtains the current thermal level. **Example** -``` +```js var lev = thermal.getThermalLevel(); console.info("Thermal level is: " + lev); ``` diff --git a/en/application-dev/reference/apis/js-apis-uri.md b/en/application-dev/reference/apis/js-apis-uri.md index a7af3cedf7584fd6c13dd29e199aff45968cf1cf..0975f28256cffeacdfbf40ed5dcf56250ff21d5d 100644 --- a/en/application-dev/reference/apis/js-apis-uri.md +++ b/en/application-dev/reference/apis/js-apis-uri.md @@ -46,11 +46,11 @@ A constructor used to create a URI instance. **Example** -``` +```js var mm = 'http://username:password@host:8080/directory/file?foo=1&bar=2#fragment'; new uri.URI(mm); // Output 'http://username:password@host:8080/directory/file?foo=1&bar=2#fragment'; ``` -``` +```js new uri.URI('http://username:password@host:8080'); // Output 'http://username:password@host:8080'; ``` @@ -69,7 +69,7 @@ Obtains the query string applicable to this URL. **Example** -``` +```js const url = new uri.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toString() ``` @@ -95,7 +95,7 @@ Checks whether this URI is the same as another URI object. **Example** -``` +```js const uriInstance = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); const uriInstance1 = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da#fragment'); uriInstance.equals(uriInstance1); @@ -115,7 +115,7 @@ Checks whether this URI is an absolute URI (whether the scheme component is defi **Example** -``` +```js const uriInstance = new uri.URI('http://username:password@www.qwer.com:8080?query=pppppp'); uriInstance.checkIsAbsolute(); ``` @@ -134,7 +134,7 @@ Normalizes the path of this URI. | URI | URI with the normalized path.| **Example** -``` +```js const uriInstance = new uri.URI('http://username:password@www.qwer.com:8080/path/path1/../path2/./path3?query=pppppp'); let uriInstance1 = uriInstance.normalize(); uriInstance1.path; diff --git a/en/application-dev/reference/apis/js-apis-url.md b/en/application-dev/reference/apis/js-apis-url.md index a679841ee2324fe8c4b2b672866b92c4fec0ee3e..b3d39d36eb25fb1e43e8f503e8933cb58e008e58 100755 --- a/en/application-dev/reference/apis/js-apis-url.md +++ b/en/application-dev/reference/apis/js-apis-url.md @@ -31,7 +31,7 @@ Creates a **URLSearchParams** instance. **Example** -``` +```js var objectParams = new URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]); var objectParams1 = new URLSearchParams({"fod" : 1 , "bard" : 2}); var objectParams2 = new URLSearchParams('?fod=1&bard=2'); @@ -55,7 +55,7 @@ Appends a key-value pair into the query string. **Example** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.append('fod', 3); @@ -76,7 +76,7 @@ Deletes key-value pairs of the specified key. **Example** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsobject = new URLSearchParams(urlObject.search.slice(1)); paramsobject.delete('fod'); @@ -103,7 +103,7 @@ Obtains all the key-value pairs based on the specified key. **Example** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.append('fod', 3); // Add a second value for the fod parameter. @@ -125,7 +125,7 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th **Example** -``` +```js var searchParamsObject = new URLSearchParams("keyName1=valueName1&keyName2=valueName2"); for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pairs console.log(pair[0]+ ', '+ pair[1]); @@ -156,7 +156,7 @@ Traverses the key-value pairs in the **URLSearchParams** instance by using a cal **Example** -``` +```js const myURLObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); myURLObject.searchParams.forEach((value, name, searchParams) => { console.log(name, value, myURLObject.searchParams === searchParams); @@ -185,7 +185,7 @@ Obtains the value of the first key-value pair based on the specified key. **Example** -``` +```js var paramsOject = new URLSearchParams(document.location.search.substring(1)); var name = paramsOject.get("name"); // is the string "Jonathan" var age = parseInt(paramsOject.get("age"), 10); // is the number 18 @@ -213,7 +213,7 @@ Checks whether a key has a value. **Example** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.has('bard') === true; @@ -235,7 +235,7 @@ Sets the value for a key. If key-value pairs matching the specified key exist, t **Example** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.set('baz', 3); // Add a third parameter. @@ -251,7 +251,7 @@ Sorts all key-value pairs contained in this object based on the Unicode code poi **Example** -``` +```js var searchParamsObject = new URLSearchParams("c=3&a=9&b=4&d=2"); // Create a test URLSearchParams object searchParamsObject.sort(); // Sort the key/value pairs console.log(searchParamsObject.toString()); // Display the sorted query string // Output a=9&b=2&c=3&d=4 @@ -273,7 +273,7 @@ Obtains an ES6 iterator that contains the keys of all the key-value pairs. **Example** -``` +```js var searchParamsObject = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing for (var key of searchParamsObject .keys()) { // Output key-value pairs console.log(key); @@ -295,7 +295,7 @@ Obtains an ES6 iterator that contains the values of all the key-value pairs. **Example** -``` +```js var searchParams = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing for (var value of searchParams.values()) { console.log(value); @@ -318,7 +318,7 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th **Example** -``` +```js const paramsObject = new URLSearchParams('fod=bay&edg=bap'); for (const [name, value] of paramsObject) { console.log(name, value); @@ -341,7 +341,7 @@ Obtains search parameters that are serialized as a string and, if necessary, per **Example** -``` +```js let url = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let params = new URLSearchParams(url.search.slice(1)); params.append('fod', 3); @@ -386,7 +386,7 @@ Creates a URL. **Example** -``` +```js var mm = 'http://username:password@host:8080'; var a = new URL("/", mm); // Output 'http://username:password@host:8080/'; var b = new URL(mm); // Output 'http://username:password@host:8080/'; @@ -416,7 +416,7 @@ Converts the parsed URL into a string. **Example** -``` +```js const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toString() ``` @@ -436,7 +436,7 @@ Converts the parsed URL into a JSON string. | string | Website address in a serialized string.| **Example** -``` +```js const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toJSON() ``` diff --git a/en/application-dev/reference/apis/js-apis-util.md b/en/application-dev/reference/apis/js-apis-util.md index b4a031c8a87a50688d0bcfaa6e7493eeb322004d..ecc46e0c2d4b17d6d6a462c312a7860627b579a2 100755 --- a/en/application-dev/reference/apis/js-apis-util.md +++ b/en/application-dev/reference/apis/js-apis-util.md @@ -23,18 +23,18 @@ Prints the input content in a formatted string. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | format | string | Yes| Format of the string to print.| - | ...args | Object[] | No| Data to format.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| format | string | Yes| Format of the string to print.| +| ...args | Object[] | No| Data to format.| **Return value** - | Type| Description| - | -------- | -------- | - | string | String in the specified format.| +| Type| Description| +| -------- | -------- | +| string | String in the specified format.| **Example** - ``` + ```js var res = util.printf("%s", "hello world!"); console.log(res); ``` @@ -49,17 +49,17 @@ Obtains detailed information about a system error code. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | errno | number | Yes| Error code generated.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| errno | number | Yes| Error code generated.| **Return value** - | Type| Description| - | -------- | -------- | - | string | Detailed information about the error code.| +| Type| Description| +| -------- | -------- | +| string | Detailed information about the error code.| **Example** - ``` + ```js var errnum = 10; // 10 is the system error code. var result = util.getErrorString(errnum); console.log("result = " + result); @@ -76,17 +76,17 @@ Calls back an asynchronous function. In the callback, the first parameter indica **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | original | Function | Yes| Asynchronous function.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| original | Function | Yes| Asynchronous function.| **Return value** - | Type| Description| - | -------- | -------- | - | Function | Callback, in which the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved) and the second parameter indicates the resolved value.| +| Type| Description| +| -------- | -------- | +| Function | Callback, in which the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved) and the second parameter indicates the resolved value.| **Example** - ``` + ```js async function promiseFn() { return Promise.reject('value'); } @@ -107,17 +107,17 @@ Processes an asynchronous function and returns a promise version. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | original | Function | Yes| Asynchronous function.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| original | Function | Yes| Asynchronous function.| **Return value** - | Type| Description| - | -------- | -------- | - | Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise version.| +| Type| Description| +| -------- | -------- | +| Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise version.| **Example** - ``` + ```js function aysnFun(str1, str2, callback) { if (typeof str1 === 'string' && typeof str2 === 'string') { callback(null, str1 + str2); @@ -154,20 +154,20 @@ A constructor used to create a **TextDecoder** object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | encoding | string | No| Encoding format.| - | options | Object | No| Encoding-related options, which include **fatal** and **ignoreBOM**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| encoding | string | No| Encoding format.| +| options | Object | No| Encoding-related options, which include **fatal** and **ignoreBOM**.| **Table 1** options - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fatal | boolean | No| Whether to display fatal errors.| - | ignoreBOM | boolean | No| Whether to ignore the BOM.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| fatal | boolean | No| Whether to display fatal errors.| +| ignoreBOM | boolean | No| Whether to ignore the BOM.| **Example** - ``` + ```js var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); ``` @@ -181,24 +181,24 @@ Decodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | input | Unit8Array | Yes| Uint8Array to decode.| - | options | Object | No| Options related to decoding.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| input | Unit8Array | Yes| Uint8Array to decode.| +| options | Object | No| Options related to decoding.| **Table 2** options - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | stream | boolean | No| Whether to allow data blocks in subsequent **decode()**. If data is processed in blocks, set this parameter to **true**. If this is the last data block to process or data is not divided into blocks, set this parameter to **false**. The default value is **false**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| stream | boolean | No| Whether to allow data blocks in subsequent **decode()**. If data is processed in blocks, set this parameter to **true**. If this is the last data block to process or data is not divided into blocks, set this parameter to **false**. The default value is **false**.| **Return value** - | Type| Description| - | -------- | -------- | - | string | Data decoded.| +| Type| Description| +| -------- | -------- | +| string | Data decoded.| **Example** - ``` + ```js var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); var result = new Uint8Array(6); result[0] = 0xEF; @@ -236,7 +236,7 @@ A constructor used to create a **TextEncoder** object. **System capability**: SystemCapability.Utils.Lang **Example** - ``` + ```js var textEncoder = new util.TextEncoder(); ``` @@ -250,17 +250,17 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | input | string | Yes| String to encode.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| input | string | Yes| String to encode.| **Return value** - | Type| Description| - | -------- | -------- | - | Uint8Array | Encoded text.| +| Type| Description| +| -------- | -------- | +| Uint8Array | Encoded text.| **Example** - ``` + ```js var textEncoder = new util.TextEncoder(); var result = new Uint8Array(buffer); result = textEncoder.encode("\uD800¥¥"); @@ -276,18 +276,18 @@ Stores the UTF-8 encoded text. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | input | string | Yes| String to encode.| - | dest | Uint8Array | Yes| **Uint8Array** instance used to store the UTF-8 encoded text.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| input | string | Yes| String to encode.| +| dest | Uint8Array | Yes| **Uint8Array** instance used to store the UTF-8 encoded text.| **Return value** - | Type| Description| - | -------- | -------- | - | Uint8Array | Encoded text.| +| Type| Description| +| -------- | -------- | +| Uint8Array | Encoded text.| **Example** - ``` + ```js var that = new util.TextEncoder(); var buffer = new ArrayBuffer(4); this.dest = new Uint8Array(buffer); @@ -306,13 +306,13 @@ A constructor used to create a **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | numerator | number | Yes| Numerator, which is an integer.| - | denominator | number | Yes| Denominator, which is an integer.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| numerator | number | Yes| Numerator, which is an integer.| +| denominator | number | Yes| Denominator, which is an integer.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); ``` @@ -326,17 +326,17 @@ Creates a **RationalNumber** object based on the given string. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | rationalString | string | Yes| String used to create the **RationalNumber** object.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| rationalString | string | Yes| String used to create the **RationalNumber** object.| **Return value** - | Type| Description| - | -------- | -------- | - | object | **RationalNumber** object created.| +| Type| Description| +| -------- | -------- | +| object | **RationalNumber** object created.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var rational = rationalNumer.creatRationalFromString("3/4"); ``` @@ -351,17 +351,18 @@ Compares this **RationalNumber** object with a given object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | another | RationalNumber | Yes| Object used to compare with this **RationalNumber** object.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| another | RationalNumber | Yes| Object used to compare with this **RationalNumber** object.| **Return value** - | Type| Description| - | -------- | -------- | - | number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object.| +| Type| Description| +| -------- | -------- | +| number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object.| **Example** - ``` + + ```js var rationalNumber = new util.RationalNumber(1,2); var rational = rationalNumer.creatRationalFromString("3/4"); var result = rationalNumber.compareTo(rational); @@ -377,12 +378,12 @@ Obtains the value of this **RationalNumber** object as an integer or a floating- **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | number | An integer or a floating-point number.| +| Type| Description| +| -------- | -------- | +| number | An integer or a floating-point number.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.valueOf(); ``` @@ -397,17 +398,17 @@ Checks whether this **RationalNumber** object equals the given object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | object | Object | Yes| Object used to compare with this **RationalNumber** object.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| object | Object | Yes| Object used to compare with this **RationalNumber** object.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the two objects are equal; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the two objects are equal; returns **false** otherwise.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var rational = rationalNumer.creatRationalFromString("3/4"); var result = rationalNumber.equals(rational); @@ -423,18 +424,18 @@ Obtains the greatest common divisor of two specified integers. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | number1 | number | Yes| The first integer used to get the greatest common divisor.| - | number2 | number | Yes| The second integer used to get the greatest common divisor.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| number1 | number | Yes| The first integer used to get the greatest common divisor.| +| number2 | number | Yes| The second integer used to get the greatest common divisor.| **Return value** - | Type| Description| - | -------- | -------- | - | number | Greatest common divisor obtained.| +| Type| Description| +| -------- | -------- | +| number | Greatest common divisor obtained.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.getCommonDivisor(4,6); ``` @@ -450,12 +451,12 @@ Obtains the numerator of this **RationalNumber** object. **Return value** - | Type| Description| - | -------- | -------- | - | number | Numerator of this **RationalNumber** object.| +| Type| Description| +| -------- | -------- | +| number | Numerator of this **RationalNumber** object.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.getNumerator(); ``` @@ -470,12 +471,12 @@ Obtains the denominator of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | number | Denominator of this **RationalNumber** object.| +| Type| Description| +| -------- | -------- | +| number | Denominator of this **RationalNumber** object.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.getDenominator(); ``` @@ -490,12 +491,12 @@ Checks whether this **RationalNumber** object is **0**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.isZero(); ``` @@ -510,12 +511,12 @@ Checks whether this **RationalNumber** object is a Not a Number (NaN). **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if this **RationalNumber** object is a NaN (the denominator and numerator are both **0**); returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if this **RationalNumber** object is a NaN (the denominator and numerator are both **0**); returns **false** otherwise.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.isNaN(); ``` @@ -530,12 +531,12 @@ Checks whether this **RationalNumber** object represents a finite value. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if this **RationalNumber** object represents a finite value (the denominator is not **0**); returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if this **RationalNumber** object represents a finite value (the denominator is not **0**); returns **false** otherwise.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.isFinite(); ``` @@ -550,12 +551,12 @@ Obtains the string representation of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | string | Returns **NaN** if the numerator and denominator of this object are both **0**; returns a string in Numerator/Denominator format otherwise, for example, **3/5**.| +| Type| Description| +| -------- | -------- | +| string | Returns **NaN** if the numerator and denominator of this object are both **0**; returns a string in Numerator/Denominator format otherwise, for example, **3/5**.| **Example** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.toString(); ``` @@ -571,7 +572,7 @@ Obtains the string representation of this **RationalNumber** object. | length | number | Yes| No| Total number of values in this buffer.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.put(1,8); @@ -588,12 +589,12 @@ A constructor used to create an **LruBuffer** instance. The default capacity of **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | capacity | number | No| Capacity of the **LruBuffer** to create.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| capacity | number | No| Capacity of the **LruBuffer** to create.| **Example** - ``` + ```js var lrubuffer= new util.LruBuffer(); ``` @@ -607,12 +608,12 @@ Changes the **LruBuffer** capacity. If the new capacity is less than or equal to **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | newCapacity | number | Yes| New capacity of the **LruBuffer**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| newCapacity | number | Yes| New capacity of the **LruBuffer**.| **Example** - ``` + ```js var pro = new util.LruBuffer(); var result = pro.updateCapacity(100); ``` @@ -627,12 +628,12 @@ Obtains the string representation of this **LruBuffer** object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | string | String representation of this **LruBuffer** object.| +| Type| Description| +| -------- | -------- | +| string | String representation of this **LruBuffer** object.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.get(2); @@ -650,12 +651,12 @@ Obtains the capacity of this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | number | Capacity of this buffer.| +| Type| Description| +| -------- | -------- | +| number | Capacity of this buffer.| **Example** - ``` + ```js var pro = new util.LruBuffer(); var result = pro.getCapacity(); ``` @@ -670,7 +671,7 @@ Clears key-value pairs from this buffer. The **afterRemoval()** method will be c **System capability**: SystemCapability.Utils.Lang **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.size(); @@ -687,12 +688,12 @@ Obtains the number of return values for **createDefault()**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | number | Number of return values for **createDefault()**.| +| Type| Description| +| -------- | -------- | +| number | Number of return values for **createDefault()**.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(1,8); var result = pro.getCreateCount(); @@ -708,12 +709,12 @@ Obtains the number of times that the queried values are mismatched. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | number | Number of times that the queried values are mismatched.| +| Type| Description| +| -------- | -------- | +| number | Number of times that the queried values are mismatched.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.get(2); @@ -730,12 +731,12 @@ Obtains the number of removals from this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | number | Number of removals from the buffer.| +| Type| Description| +| -------- | -------- | +| number | Number of removals from the buffer.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.updateCapacity(2); @@ -753,12 +754,12 @@ Obtains the number of times that the queried values are matched. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | number | Number of times that the queried values are matched.| +| Type| Description| +| -------- | -------- | +| number | Number of times that the queried values are matched.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.get(2); @@ -775,12 +776,12 @@ Obtains the number of additions to this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | number | Number of additions to the buffer.| +| Type| Description| +| -------- | -------- | +| number | Number of additions to the buffer.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.getPutCount(); @@ -796,12 +797,12 @@ Checks whether this buffer is empty. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the buffer does not contain any value.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the buffer does not contain any value.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.isEmpty(); @@ -817,17 +818,17 @@ Obtains the value of the specified key. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | key | K | Yes| Key based on which the value is queried.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key based on which the value is queried.| **Return value** - | Type| Description| - | -------- | -------- | - | V \| undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.| +| Type| Description| +| -------- | -------- | +| V \| undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.get(2); @@ -843,18 +844,18 @@ Adds a key-value pair to this buffer. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | key | K | Yes| Key of the key-value pair to add.| - | value | V | Yes| Value of the key-value pair to add.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key of the key-value pair to add.| +| value | V | Yes| Value of the key-value pair to add.| **Return value** - | Type| Description| - | -------- | -------- | - | V | Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown. | +| Type| Description| +| -------- | -------- | +| V | Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown. | **Example** - ``` + ```js var pro = new util.LruBuffer(); var result = pro.put(2,10); ``` @@ -869,12 +870,12 @@ Obtains all values in this buffer, listed from the most to the least recently ac **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | V [] | All values in the buffer, listed from the most to the least recently accessed.| +| Type| Description| +| -------- | -------- | +| V [] | All values in the buffer, listed from the most to the least recently accessed.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.put(2,"anhu"); @@ -892,12 +893,12 @@ Obtains all keys in this buffer, listed from the most to the least recently acce **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | K [] | All keys in the buffer, listed from the most to the least recently accessed.| +| Type| Description| +| -------- | -------- | +| K [] | All keys in the buffer, listed from the most to the least recently accessed.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.keys(); @@ -913,17 +914,17 @@ Removes the specified key and its value from this buffer. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | key | K | Yes| Key to remove.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key to remove.| **Return value** - | Type| Description| - | -------- | -------- | - | V \| undefind | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.| +| Type| Description| +| -------- | -------- | +| V \| undefind | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.remove(20); @@ -939,15 +940,15 @@ Performs subsequent operations after a value is removed. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | isEvict | boolean | No| Whether the buffer capacity is insufficient. If the value is **true**, this method is called due to insufficient capacity.| - | key | K | Yes| Key removed.| - | value | V | Yes| Value removed.| - | newValue | V | No| New value for the key if the **put()** method is called and the key to be added already exists. In other cases, this parameter is left blank.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| isEvict | boolean | No| Whether the buffer capacity is insufficient. If the value is **true**, this method is called due to insufficient capacity.| +| key | K | Yes| Key removed.| +| value | V | Yes| Value removed.| +| newValue | V | No| New value for the key if the **put()** method is called and the key to be added already exists. In other cases, this parameter is left blank.| **Example** - ``` + ```js var arr = []; class ChildLruBuffer extends util.LruBuffer { @@ -984,17 +985,17 @@ Checks whether this buffer contains the specified key. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | key | K | Yes| Key to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.contains(20); @@ -1010,17 +1011,17 @@ Creates a value if the value of the specified key is not available. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | key | K | Yes| Key of which the value is missing.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key of which the value is missing.| **Return value** - | Type| Description| - | -------- | -------- | - | V | Value of the key.| +| Type| Description| +| -------- | -------- | +| V | Value of the key.| **Example** - ``` + ```js var pro = new util.LruBuffer(); var result = pro.createDefault(50); ``` @@ -1035,12 +1036,12 @@ Obtains a new iterator object that contains all key-value pairs in this object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | [K, V] | Iterable array.| +| Type| Description| +| -------- | -------- | +| [K, V] | Iterable array.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.entries(); @@ -1056,12 +1057,12 @@ Obtains a two-dimensional array in key-value pairs. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | [K, V] | Two-dimensional array in key-value pairs.| +| Type| Description| +| -------- | -------- | +| [K, V] | Two-dimensional array in key-value pairs.| **Example** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro[symbol.iterator](); @@ -1076,7 +1077,7 @@ Obtains a two-dimensional array in key-value pairs. Defines the type of values in a **Scope** object. The value type can be **ScopeComparable** or **number**. The values of the **ScopeComparable** type are used to implement the **compareTo** method. Therefore, ensure that the input parameters are comparable. -``` +```js interface ScopeComparable{ compareTo(other: ScopeComparable): boolean; } @@ -1088,7 +1089,7 @@ Create a class to implement the **compareTo** method. In the subsequent sample c Example -``` +```js class Temperature{ constructor(value){ this._temp = value; @@ -1115,13 +1116,13 @@ A constructor used to create a **Scope** object with the specified upper and low **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit of the **Scope** object.| - | upperObj | [ScopeType](#scopetype8) | Yes| Upper limit of the **Scope** object.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit of the **Scope** object.| +| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit of the **Scope** object.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1137,12 +1138,12 @@ Obtains a string representation that contains this **Scope**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | string | String representation containing the **Scope**.| +| Type| Description| +| -------- | -------- | +| string | String representation containing the **Scope**.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1159,17 +1160,17 @@ Obtains the intersection of this **Scope** and the given **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | Yes| **Scope** specified.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | Yes| **Scope** specified.| **Return value** - | Type| Description| - | -------- | -------- | - | [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**.| +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1189,18 +1190,18 @@ Obtains the intersection of this **Scope** and the given lower and upper limits. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.| - | upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.| +| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.| **Return value** - | Type| Description| - | -------- | -------- | - | [Scope](#scope8) | Intersection of this **Scope** and the given lower and upper limits.| +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Intersection of this **Scope** and the given lower and upper limits.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1220,12 +1221,12 @@ Obtains the upper limit of this **Scope**. **Return value** - | Type| Description| - | -------- | -------- | - | [ScopeType](#scopetype8) | Upper limit of this **Scope**.| +| Type| Description| +| -------- | -------- | +| [ScopeType](#scopetype8) | Upper limit of this **Scope**.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1242,12 +1243,12 @@ Obtains the lower limit of this **Scope**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| - | -------- | -------- | - | [ScopeType](#scopetype8) | Lower limit of this **Scope**.| +| Type| Description| +| -------- | -------- | +| [ScopeType](#scopetype8) | Lower limit of this **Scope**.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1264,18 +1265,18 @@ Obtains the union set of this **Scope** and the given lower and upper limits. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.| - | upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.| +| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.| **Return value** - | Type| Description| - | -------- | -------- | - | [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits.| +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1294,17 +1295,17 @@ Obtains the union set of this **Scope** and the given **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | Yes| **Scope** specified.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | Yes| **Scope** specified.| **Return value** - | Type| Description| - | -------- | -------- | - | [Scope](#scope8) | Union set of this **Scope** and the given **Scope**.| +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Union set of this **Scope** and the given **Scope**.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1324,17 +1325,17 @@ Obtains the union set of this **Scope** and the given value. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | Yes| Value specified.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | Yes| Value specified.| **Return value** - | Type| Description| - | -------- | -------- | - | [Scope](#scope8) | Union set of this **Scope** and the given value.| +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Union set of this **Scope** and the given value.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1352,17 +1353,17 @@ Checks whether a value is within this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | Yes| Value specified.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | Yes| Value specified.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1380,17 +1381,17 @@ Checks whether a range is within this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | Yes| **Scope** specified.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | Yes| **Scope** specified.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1410,17 +1411,17 @@ Limits a value to this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | Yes| Value specified.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | Yes| Value specified.| **Return value** - | Type| Description| - | -------- | -------- | - | [ScopeType](#scopetype8) | Returns **lowerObj** if the specified value is less than the lower limit; returns **upperObj** if the specified value is greater than the upper limit; returns the specified value if it is within this **Scope**.| +| Type| Description| +| -------- | -------- | +| [ScopeType](#scopetype8) | Returns **lowerObj** if the specified value is less than the lower limit; returns **upperObj** if the specified value is greater than the upper limit; returns the specified value if it is within this **Scope**.| **Example** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1441,7 +1442,7 @@ A constructor used to create a **Base64** object. **System capability**: SystemCapability.Utils.Lang **Example** - ``` + ```js var base64 = new util.Base64(); ``` @@ -1455,17 +1456,17 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes| Uint8Array to encode.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode.| **Return value** - | Type| Description| - | -------- | -------- | - | Uint8Array | Uint8Array encoded.| +| Type| Description| +| -------- | -------- | +| Uint8Array | Uint8Array encoded.| **Example** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); var result = that.encodeSync(array); @@ -1481,17 +1482,17 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes| Uint8Array to encode.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode.| **Return value** - | Type| Description| - | -------- | -------- | - | string | String encoded from the Uint8Array.| +| Type| Description| +| -------- | -------- | +| string | String encoded from the Uint8Array.| **Example** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); var result = that.encodeToStringSync(array); @@ -1507,17 +1508,17 @@ Decodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | src | Uint8Array \| string | Yes| Uint8Array or string to decode.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array \| string | Yes| Uint8Array or string to decode.| **Return value** - | Type| Description| - | -------- | -------- | - | Uint8Array | Uint8Array decoded.| +| Type| Description| +| -------- | -------- | +| Uint8Array | Uint8Array decoded.| **Example** - ``` + ```js var that = new util.Base64(); var buff = 'czEz'; var result = that.decodeSync(buff); @@ -1533,17 +1534,17 @@ Encodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes| Uint8Array to encode asynchronously.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode asynchronously.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<Uint8Array> | Uint8Array obtained after asynchronous encoding.| +| Type| Description| +| -------- | -------- | +| Promise<Uint8Array> | Uint8Array obtained after asynchronous encoding.| **Example** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); var rarray = new Uint8Array([99,122,69,122]); @@ -1564,17 +1565,17 @@ Encodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes| Uint8Array to encode asynchronously.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode asynchronously.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<string> | String obtained after asynchronous encoding.| +| Type| Description| +| -------- | -------- | +| Promise<string> | String obtained after asynchronous encoding.| **Example** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); that.encodeToString(array).then(val=>{ @@ -1592,17 +1593,17 @@ Decodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | src | Uint8Array \| string | Yes| Uint8Array or string to decode asynchronously.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array \| string | Yes| Uint8Array or string to decode asynchronously.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<Uint8Array> | Uint8Array obtained after asynchronous decoding.| +| Type| Description| +| -------- | -------- | +| Promise<Uint8Array> | Uint8Array obtained after asynchronous decoding.| **Example** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([99,122,69,122]); var rarray = new Uint8Array([115,49,51]); @@ -1626,7 +1627,7 @@ A constructor used to create a **types** object. **System capability**: SystemCapability.Utils.Lang **Example** - ``` + ```js var type = new util.types(); ``` @@ -1640,17 +1641,17 @@ Checks whether the input value is of the **ArrayBuffer** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isAnyArrayBuffer(new ArrayBuffer([])); ``` @@ -1667,17 +1668,17 @@ Checks whether the input value is of the **ArrayBufferView** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isArrayBufferView(new Int8Array([])); ``` @@ -1692,17 +1693,17 @@ Checks whether the input value is of the **arguments** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); function foo() { var result = that.isArgumentsObject(arguments); @@ -1720,17 +1721,17 @@ Checks whether the input value is of the **ArrayBuffer** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isArrayBuffer(new ArrayBuffer([])); ``` @@ -1745,17 +1746,17 @@ Checks whether the input value is an asynchronous function. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isAsyncFunction(async function foo() {}); ``` @@ -1770,17 +1771,17 @@ Checks whether the input value is of the **Boolean** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isBooleanObject(new Boolean(true)); ``` @@ -1795,17 +1796,17 @@ Checks whether the input value is of the **Boolean**, **Number**, **String**, or **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isBoxedPrimitive(new Boolean(false)); ``` @@ -1820,17 +1821,17 @@ Checks whether the input value is of the **DataView** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); const ab = new ArrayBuffer(20); var result = that.isDataView(new DataView(ab)); @@ -1846,17 +1847,17 @@ Checks whether the input value is of the **Date** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isDate(new Date()); ``` @@ -1871,17 +1872,17 @@ Checks whether the input value is of the **native external** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); const data = util.createExternalType(); var result = that.isExternal(data); @@ -1897,17 +1898,17 @@ Checks whether the input value is of the **Float32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isFloat32Array(new Float32Array()); ``` @@ -1922,17 +1923,17 @@ Checks whether the input value is of the **Float64Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isFloat64Array(new Float64Array()); ``` @@ -1947,17 +1948,17 @@ Checks whether the input value is a generator function. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is a generator function; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a generator function; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isGeneratorFunction(function* foo() {}); ``` @@ -1972,17 +1973,17 @@ Checks whether the input value is a generator object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is a generator object; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a generator object; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); function* foo() {} const generator = foo(); @@ -1999,17 +2000,17 @@ Checks whether the input value is of the **Int8Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isInt8Array(new Int8Array([])); ``` @@ -2024,17 +2025,17 @@ Checks whether the input value is of the **Int16Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isInt16Array(new Int16Array([])); ``` @@ -2049,17 +2050,17 @@ Checks whether the input value is of the **Int32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isInt32Array(new Int32Array([])); ``` @@ -2074,17 +2075,17 @@ Checks whether the input value is of the **Map** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isMap(new Map()); ``` @@ -2099,17 +2100,17 @@ Checks whether the input value is of the **MapIterator** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); const map = new Map(); var result = that.isMapIterator(map.keys()); @@ -2125,17 +2126,17 @@ Checks whether the input value is of the **Error** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isNativeError(new TypeError()); ``` @@ -2150,17 +2151,17 @@ Checks whether the input value is a number object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is a number object; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a number object; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isNumberObject(new Number(0)); ``` @@ -2175,17 +2176,17 @@ Checks whether the input value is a promise. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is a promise; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a promise; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isPromise(Promise.resolve(1)); ``` @@ -2200,17 +2201,17 @@ Checks whether the input value is a proxy. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is a proxy; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a proxy; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); const target = {}; const proxy = new Proxy(target, {}); @@ -2227,17 +2228,17 @@ Checks whether the input value is of the **RegExp** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isRegExp(new RegExp('abc')); ``` @@ -2252,17 +2253,17 @@ Checks whether the input value is of the **Set** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isSet(new Set()); ``` @@ -2277,17 +2278,17 @@ Checks whether the input value is of the **SetIterator** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); const set = new Set(); var result = that.isSetIterator(set.keys()); @@ -2303,17 +2304,17 @@ Checks whether the input value is a string object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is a string object; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a string object; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isStringObject(new String('foo')); ``` @@ -2328,17 +2329,17 @@ Checks whether the input value is a symbol object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); const symbols = Symbol('foo'); var result = that.isSymbolObject(Object(symbols)); @@ -2356,17 +2357,17 @@ Checks whether the input value is of the **TypedArray** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isTypedArray(new Float64Array([])); ``` @@ -2381,17 +2382,17 @@ Checks whether the input value is of the **Uint8Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isUint8Array(new Uint8Array([])); ``` @@ -2406,17 +2407,17 @@ Checks whether the input value is of the **Uint8ClampedArray** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isUint8ClampedArray(new Uint8ClampedArray([])); ``` @@ -2431,17 +2432,17 @@ Checks whether the input value is of the **Uint16Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isUint16Array(new Uint16Array([])); ``` @@ -2456,17 +2457,17 @@ Checks whether the input value is of the **Uint32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isUint32Array(new Uint32Array([])); ``` @@ -2481,17 +2482,17 @@ Checks whether the input value is of the **WeakMap** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isWeakMap(new WeakMap()); ``` @@ -2506,17 +2507,17 @@ Checks whether the input value is of the **WeakSet** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | Object | Yes| Object to check.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise.| **Example** - ``` + ```js var that = new util.types(); var result = that.isWeakSet(new WeakSet()); ``` diff --git a/en/application-dev/reference/apis/js-apis-xml.md b/en/application-dev/reference/apis/js-apis-xml.md index 65ad4b643700e21017f06608e538419bcdbdb55d..124d845c0e1101346a0783b9e56cd74b089b2424 100644 --- a/en/application-dev/reference/apis/js-apis-xml.md +++ b/en/application-dev/reference/apis/js-apis-xml.md @@ -32,7 +32,7 @@ A constructor used to create an **XmlSerializer** instance. **Example** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var bufView = new DataView(arrayBuffer); var thatSer = new xml.XmlSerializer(bufView); @@ -54,7 +54,7 @@ Sets an attribute. **Example** -``` +```js var thatSer = new xml.XmlSerializer(bufView); thatSer.setAttributes("importance", "high"); ``` @@ -74,8 +74,8 @@ Adds an empty element. **Example** -``` - var thatSer = new xml.XmlSerializer(bufView); +```js +var thatSer = new xml.XmlSerializer(bufView); thatSer.addEmptyElement("b"); // => ``` @@ -88,7 +88,7 @@ Sets a declaration. **Example** -``` +```js var thatSer = new xml.XmlSerializer(bufView); thatSer.setDeclaration() // => ; ``` @@ -108,7 +108,7 @@ Writes the start tag based on the given element name. **Example** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.startElement("notel"); @@ -124,7 +124,7 @@ Writes the end tag of the element. **Example** -``` +```js var thatSer = new xml.XmlSerializer(bufView); thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); thatSer.startElement("table"); @@ -149,7 +149,7 @@ Sets the namespace for an element tag. **Example** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.setDeclaration(); @@ -172,7 +172,7 @@ Sets the comment. **Example** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.startElement("note"); @@ -195,7 +195,7 @@ Sets CDATA attributes. **Example** -``` +```js var arrayBuffer = new ArrayBuffer(1028); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.setCDATA('root SYSTEM') // => ''; @@ -216,7 +216,7 @@ Sets **Text**. **Example** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.startElement("note"); @@ -240,7 +240,7 @@ Sets **DocType**. **Example** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.setDocType('root SYSTEM'); // => ''; @@ -265,7 +265,7 @@ Creates and returns an **XmlPullParser** object. The **XmlPullParser** object pa **Example** -``` +```js var strXml = '' + '' + @@ -297,7 +297,7 @@ Parses XML information. **Example** -``` +```js var strXml = '' + '' + diff --git a/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md b/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md index 847d8c0c9ac7be32c7f212022aec5ade6f507e82..09004c1c5c37fc6d1a78ba4854bd1fd63a0578f9 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md +++ b/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md @@ -29,7 +29,7 @@ Touch target configuration is not supported. | Name | Type | Default Value | Description | | -------- | -------- | -------- | -------- | -| tabBar | string \| {
icon?: string,
text?: string
}
\|[CustomBuilder](../../ui/ts-types.md) | - | Content displayed on the tab bar.
**CustomBuilder**: builder, to which components can be passed (applicable to API version 8 and later versions).
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> If an icon uses an SVG image, the width and height attributes of the SVG image must be deleted. Otherwise, the icon size will be determined by the width and height attributes of the SVG image. | +| tabBar | string \| {
icon?: string,
text?: string
}
\| [CustomBuilder](../../ui/ts-types.md)8+ | - | Content displayed on the tab bar.
**CustomBuilder**: builder, to which components can be passed (applicable to API version 8 and later versions).
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> If an icon uses an SVG image, the width and height attributes of the SVG image must be deleted. Otherwise, the icon size will be determined by the width and height attributes of the SVG image. | > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > - The **<TabContent>** component does not support setting of the common width attribute. By default, its width is the same as that of the parent **<Tabs>** component. diff --git a/en/application-dev/ui/figures/en-us_image_0000001262954829.png b/en/application-dev/ui/figures/en-us_image_0000001262954829.png new file mode 100644 index 0000000000000000000000000000000000000000..a606cbe3c297f267e77a71816d21def7e3d51d2d Binary files /dev/null and b/en/application-dev/ui/figures/en-us_image_0000001262954829.png differ diff --git a/en/application-dev/ui/ui-ts-basic-components-button.md b/en/application-dev/ui/ui-ts-basic-components-button.md index 8f13accaa19720e3fd8acff04ee2ccd2a30c3c84..cbbcab6f9333b56013b67d7bed7cbd45e5d98d42 100644 --- a/en/application-dev/ui/ui-ts-basic-components-button.md +++ b/en/application-dev/ui/ui-ts-basic-components-button.md @@ -11,7 +11,7 @@ You can create a button by invoking either of the following APIs: - Button(options?: {type?: ButtonType, stateEffect?: boolean}) This API creates a button that contains child components. In the syntax, **type** indicates the button type, and **stateEffect** indicates whether to enable the click effect for the button. - + ``` Button({ type: ButtonType.Normal, stateEffect: true }) { Row() { @@ -26,7 +26,7 @@ You can create a button by invoking either of the following APIs: - Button(label?: string, options?: { type?: ButtonType, stateEffect?: boolean }) This API creates a button that does not contain any child components. In the syntax, **label** indicates whether the created button contains child components. - + ``` Button('Ok', { type: ButtonType.Normal, stateEffect: true }) .borderRadius(8) @@ -42,7 +42,7 @@ You can create a button by invoking either of the following APIs: Use the **type** parameter to set the button type to **Capsule**, **Circle**, or **Normal**. - Capsule button (default type) - + ``` Button('Disable', { type: ButtonType.Capsule, stateEffect: false }) .backgroundColor(0x317aff) @@ -52,7 +52,7 @@ Use the **type** parameter to set the button type to **Capsule**, **Circle**, or ![en-us_image_0000001215645452](figures/en-us_image_0000001215645452.png) - Circle button - + ``` Button('Circle', { type: ButtonType.Circle, stateEffect: false }) .backgroundColor(0x317aff) @@ -68,18 +68,18 @@ Use the **type** parameter to set the button type to **Capsule**, **Circle**, or - Set the border radius: In general cases, you can use universal attributes to define the button styles. For example, you can use the **borderRadius** attribute to set the border radius. - + ``` Button('circle border', { type: ButtonType.Normal }) .borderRadius(20) ``` - ![zh-cn_image_0000001190463780](figures/zh-cn_image_0000001190463780.png) + ![en-us_image_0000001215645452](figures/en-us_image_0000001215645452.png) - Setting Text Styles Add a font style for text displayed on the button. - + ``` Button('font style', { type: ButtonType.Normal }) .fontSize(20) @@ -87,12 +87,12 @@ Use the **type** parameter to set the button type to **Capsule**, **Circle**, or .fontWeight(800) ``` - ![zh-cn_image_0000001189744672](figures/zh-cn_image_0000001189744672.png) + ![en-us_image_0000001215965420](figures/en-us_image_0000001215965420.png) - Set the background color: You can do so by adding the **backgroundColor** attribute. - + ``` Button('background color').backgroundColor(0xF55A42) ``` @@ -102,7 +102,7 @@ Use the **type** parameter to set the button type to **Capsule**, **Circle**, or - Assign a function to the button: In this example, we are creating a button with the delete function. - + ``` Button({ type: ButtonType.Circle, stateEffect: true }) { Image($r('app.media.ic_public_delete_filled')).width(30).height(30) @@ -133,7 +133,7 @@ Button('Ok', { type: ButtonType.Normal, stateEffect: true }) ``` import router from '@ohos.router' - + @Entry @Component struct ButtonCase1 { @@ -144,13 +144,13 @@ Button('Ok', { type: ButtonType.Normal, stateEffect: true }) router.push({ url: 'xxx' }) }) } - + ListItem() { Button("Second").onClick(() => { router.push({ url: 'yyy' }) }) } - + ListItem() { Button("Third").onClick(() => { router.push({ url: 'zzz' }) @@ -170,7 +170,7 @@ Button('Ok', { type: ButtonType.Normal, stateEffect: true }) - Using the Button for Submitting Forms On the user login/registration page, you can use a button to submit a login or registration request. - + ``` @Entry @Component @@ -184,5 +184,5 @@ Button('Ok', { type: ButtonType.Normal, stateEffect: true }) } } ``` - + ![en-us_image_0000001190466492](figures/en-us_image_0000001190466492.png) diff --git a/en/application-dev/ui/ui-ts-layout-mediaquery.md b/en/application-dev/ui/ui-ts-layout-mediaquery.md index 32238aa4870e6176b7cde46e28e8be830b7d35be..fa4a03382cd5c851d46f951c60949b64139bc4df 100644 --- a/en/application-dev/ui/ui-ts-layout-mediaquery.md +++ b/en/application-dev/ui/ui-ts-layout-mediaquery.md @@ -45,9 +45,9 @@ screen and (device-type: tv) or (resolution < 2) // This is a multi-condition ### media-type - | Type| Description| -| -------- | -------- | -| screen | Media query based on screen-related parameters.| +| Type | Description | +| ------ | ---------------------------------------- | +| screen | Media query based on screen-related parameters. | ### Media Logic Operation (and|not|only) @@ -56,48 +56,48 @@ You can use logical operators (**and**, **or**, **not**, and **only**) to compos **Table 1** Media logical operators -| Type| Description| -| -------- | -------- | -| and | The **and** operator is used to combine multiple media features into one media query, in a logical AND operation. The query is valid only when all media features are true. It can also combine media types and media functions.
For example, **screen and (device-type: wearable) and (max-height: 600) ** indicates that the query is valid when the device type is wearable and the maximum height of the application is 600 pixel units.| -| not | The **not** operator is used to perform a logical negation for a media query. **true** is returned if the query condition is not met. Otherwise, **false** is returned. In a media query list, logical negation is performed only for the media query using the **not** operator.
For example, **not screen and (min-height: 50) and (max-height: 600) ** indicates that the query is valid when the height of the application is less than 50 pixel units or greater than 600 pixel units.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> When the **not** operator is used, the media type must be specified.| -| only | The **only** operator applies the selected style only when the entire expression is matched. It can be used to prevent ambiguity on browsers of earlier versions. The statements that contain both media types and media features produce ambiguity when they are received by some browsers of earlier versions. For example:
screen and (min-height: 50)
The browsers of earlier versions would mislead this sentence into screen, causing the fact that the specified style is applied when only the media type is matched. In this case, the **only** operator can be used to avoid this problem.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> When the **only** operator is used, the media type must be specified.| -| ,(comma) | The **or** operator is used to combine multiple media features into one media query, in a logical OR operation. The query is valid if a media feature is true. The effect of a comma operator is equivalent to that of the **or** operator.
For example, **screen and (min-height: 1000),  (round-screen: true) ** indicates that the query is valid when the minimum height of the application is 1000 pixel units or the device screen is round.| -| or | The **or** operator is used to combine multiple media features into one media query, in a logical OR operation. The query is valid if a media feature is true.
For example, **screen and (max-height: 1000) or  (round-screen: true)** indicates that the query is valid when the maximum height of the application is 1000 pixel units or the device screen is round.| +| Type | Description | +| -------- | ---------------------------------------- | +| and | The **and** operator is used to combine multiple media features into one media query, in a logical AND operation. The query is valid only when all media features are true. It can also combine media types and media functions.
For example, **screen and (device-type: wearable) and (max-height: 600) ** indicates that the query is valid when the device type is wearable and the maximum height of the application is 600 pixel units. | +| not | The **not** operator is used to perform a logical negation for a media query. **true** is returned if the query condition is not met. Otherwise, **false** is returned. In a media query list, logical negation is performed only for the media query using the **not** operator.
For example, **not screen and (min-height: 50) and (max-height: 600) ** indicates that the query is valid when the height of the application is less than 50 pixel units or greater than 600 pixel units.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> When the **not** operator is used, the media type must be specified. | +| only | The **only** operator applies the selected style only when the entire expression is matched. It can be used to prevent ambiguity on browsers of earlier versions. The statements that contain both media types and media features produce ambiguity when they are received by some browsers of earlier versions. For example:
screen and (min-height: 50)
The browsers of earlier versions would mislead this sentence into screen, causing the fact that the specified style is applied when only the media type is matched. In this case, the **only** operator can be used to avoid this problem.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> When the **only** operator is used, the media type must be specified. | +| ,(comma) | The **or** operator is used to combine multiple media features into one media query, in a logical OR operation. The query is valid if a media feature is true. The effect of a comma operator is equivalent to that of the **or** operator.
For example, **screen and (min-height: 1000),  (round-screen: true) ** indicates that the query is valid when the minimum height of the application is 1000 pixel units or the device screen is round. | +| or | The **or** operator is used to combine multiple media features into one media query, in a logical OR operation. The query is valid if a media feature is true.
For example, **screen and (max-height: 1000) or  (round-screen: true)** indicates that the query is valid when the maximum height of the application is 1000 pixel units or the device screen is round. | At MediaQuery Level 4, range query is imported so that you can use the operators including <=, >=, <, and > besides the **max-** and **min-** operators. **Table 2** Logical operators for range query -| Type| Description| -| -------- | -------- | -| <= | Less than or equal to, for example, **screen and (50 <= height)**.| -| >= | Greater than or equal to, for example, **screen and (600 >= height)**.| -| < | Less than, for example, **screen and (50 < height)**.| -| > | Greater than, for example, **screen and (600 > height)**.| +| Type | Description | +| ----- | ---------------------------------------- | +| <= | Less than or equal to, for example, **screen and (50 <= height)**. | +| >= | Greater than or equal to, for example, **screen and (600 >= height)**. | +| < | Less than, for example, **screen and (50 < height)**. | +| > | Greater than, for example, **screen and (600 > height)**. | ### media-feature - | Type| Description| -| -------- | -------- | -| height | Height of the display area on the application page.| -| min-height | Minimum height of the display area on the application page.| -| max-height | Maximum height of the display area on the application page.| -| width | Width of the display area on the app page.| -| min-width | Minimum width of the display area on the application page.| -| max-width | Maximum width of the display area on the application page.| -| resolution | Resolution of the device. The unit can be dpi, dppx, or dpcm.
- **dpi** indicates the number of physical pixels per inch. 1 dpi ≈ 0.39 dpcm.
- **dpcm** indicates the number of physical pixels per centimeter. 1 dpcm ≈ 2.54 dpi.
- **dppx** indicates the number of physical pixels in each pixel. (This unit is calculated based on this formula: 96 px = 1 inch, which is different from the calculation method of the px unit on the page.) 1 dppx = 96 dpi.| -| min-resolution | Minimum device resolution.| -| max-resolution | Maximum device resolution.| -| orientation | Screen orientation.
Options are as follows:
- orientation: portrait
- orientation: landscape| -| device-height | Height of the device.| -| min-device-height | Minimum height of the device.| -| max-device-height | Maximum height of the device.| -| device-width | Width of the device.| -| min-device-width | Minimum width of the device.| -| max-device-width | Maximum width of the device.| -| round-screen | Screen type. The value **true** means that the screen is round, and **false** means the opposite.| -| dark-mode | Whether the device is in dark mode. The value **true** means that the device is in dark mode, and **false** means the opposite.| +| Type | Description | +| ----------------- | ---------------------------------------- | +| height | Height of the display area on the application page. | +| min-height | Minimum height of the display area on the application page. | +| max-height | Maximum height of the display area on the application page. | +| width | Width of the display area on the app page. | +| min-width | Minimum width of the display area on the application page. | +| max-width | Maximum width of the display area on the application page. | +| resolution | Resolution of the device. The unit can be dpi, dppx, or dpcm.
- **dpi** indicates the number of physical pixels per inch. 1 dpi ≈ 0.39 dpcm.
- **dpcm** indicates the number of physical pixels per centimeter. 1 dpcm ≈ 2.54 dpi.
- **dppx** indicates the number of physical pixels in each pixel. (This unit is calculated based on this formula: 96 px = 1 inch, which is different from the calculation method of the px unit on the page.) 1 dppx = 96 dpi. | +| min-resolution | Minimum device resolution. | +| max-resolution | Maximum device resolution. | +| orientation | Screen orientation.
Options are as follows:
- orientation: portrait
- orientation: landscape | +| device-height | Height of the device. | +| min-device-height | Minimum height of the device. | +| max-device-height | Maximum height of the device. | +| device-width | Width of the device. | +| min-device-width | Minimum width of the device. | +| max-device-width | Maximum width of the device. | +| round-screen | Screen type. The value **true** means that the screen is round, and **false** means the opposite. | +| dark-mode | Whether the device is in dark mode. The value **true** means that the device is in dark mode, and **false** means the opposite. | ## Example Scenario @@ -139,7 +139,7 @@ Use media queries to apply different content and styles to the page text when th } ``` When the device is in landscape orientation, the text content is displayed in landscape mode in the color of #FFD700.
-![zh-cn_image_0000001262954829](figures/zh-cn_image_0000001262954829.png) +![en-us_image_0000001262954829](figures/en-us_image_0000001262954829.png) When the device is not in landscape orientation, the text content is displayed in portrait mode in the color of #DB7093.
![en-us_image_0000001263074739](figures/en-us_image_0000001263074739.png) diff --git a/en/application-dev/website.md b/en/application-dev/website.md index 2ebf0b336340d2836eb0c916e899bc4d237f0af6..9322878428f6801d80fa085a386ffd5bdaa4c434 100644 --- a/en/application-dev/website.md +++ b/en/application-dev/website.md @@ -556,7 +556,7 @@ - [@ohos.data.distributedData](reference/apis/js-apis-distributed-data.md) - [@ohos.data.distributedDataObject](reference/apis/js-apis-data-distributedobject.md) - [@ohos.data.rdb](reference/apis/js-apis-data-rdb.md) - - [@ohos.data.storage](reference/apis/js-apis-data-storage.md) + - [@ohos.data.storage](reference/apis/js-apis-data-storage.md) - [@ohos.settings](reference/apis/js-apis-settings.md) - [resultSet](reference/apis/js-apis-data-resultset.md) diff --git a/en/device-dev/guide/device-iotcamera-control-example.md b/en/device-dev/guide/device-iotcamera-control-example.md index 0d2fbf23bf92862441b826088fbc42b55ba3beea..0b241bf85e5ebd5a774c2b23984e0525c5be9de9 100644 --- a/en/device-dev/guide/device-iotcamera-control-example.md +++ b/en/device-dev/guide/device-iotcamera-control-example.md @@ -1,6 +1,6 @@ # Use Case -- For details about the development board, compilation, burning, and image running, see [Hi3518 Development Board](../quick-start/quickstart-lite-introduction-hi3518.md#section14815247616). A compilation result file of sample code is stored in **out/ipcamera\_hi3518ev300/dev\_tools/bin/camera\_sample**. You can copy the file to a TF card, or modify the compilation script of **camera\_sample** to copy the result to **rootfs.img**. +- A Hi318 compilation result file of sample code is stored in **out/ipcamera\_hi3518ev300/dev\_tools/bin/camera\_sample**. You can copy the file to a TF card, or modify the compilation script of **camera\_sample** to copy the result to **rootfs.img**. Modify **output\_dir** in **applications/sample/camera/media/BUILD.gn**. diff --git a/en/device-dev/guide/device-wlan-led-control.md b/en/device-dev/guide/device-wlan-led-control.md index 08fa2a01992eb40a3cc7927a3ec50510f48dbdae..ba3f8f29838d810c92057077bda04cb25e1cf0d0 100644 --- a/en/device-dev/guide/device-wlan-led-control.md +++ b/en/device-dev/guide/device-wlan-led-control.md @@ -97,7 +97,7 @@ Based on the Hi3861 platform, the OpenHarmony WLAN module provides abundant peri ## Verification -For details about the compilation and burning processes, see [Building Source Code](../quick-start/quickstart-lite-steps-hi3861-connection.md#section191121332125319) and [Burning Images](../quick-start/quickstart-lite-steps-hi3861-connection.md#section3288165814218) in the _Getting Started with Hi3861_. +For details about the compilation and burning processes, see [Building Source Code](../quick-start/quickstart-ide-lite-steps-hi3861-building.md) and [Burning Images](../quick-start/quickstart-ide-lite-steps-hi3861-burn.md) in the _Getting Started with Hi3861_. After the preceding two steps are complete, press the **RST** button to reset the module. If the LED blinks periodically as expected, the verification is passed. diff --git a/en/device-dev/quick-start/quickstart-ide-lite-overview.md b/en/device-dev/quick-start/quickstart-ide-lite-overview.md index 0c8a543a8c9d0731f063ae7e4d14b4ee473a6e09..f23028f755bd48bb7c7f6ce8f1c05370551565ab 100644 --- a/en/device-dev/quick-start/quickstart-ide-lite-overview.md +++ b/en/device-dev/quick-start/quickstart-ide-lite-overview.md @@ -12,7 +12,7 @@ To accommodate different developer habits, OpenHarmony provides two modes for ge - Installation package mode: Dependency download and installation as well as building operations are performed using commands. Burning and running are performed in DevEco Device Tool. OpenHarmony also provides the [Docker environment](../get-code/gettools-acquire.md), which can significantly simplify the environment configuration before compilation. You can build your source code in the Docker environment if you are more accustomed to using the installation package mode. -This document exemplifies how to use the IDE mode. For details about the installation package mode, see [Getting Started with Mini and Small Systems (Installation Package Mode)](../quick-start/quickstart-lite-package-directory.md). +This document exemplifies how to use the IDE mode. For details about the installation package mode, see [Getting Started with Mini and Small Systems (Installation Package Mode)](../quick-start/quickstart-lite-overview.md). ## Development Environment @@ -28,7 +28,7 @@ This document describes how to develop OpenHarmony in the Windows+Ubuntu environ ## Development Boards -In this document, two development board models are used as examples: Hi3861 and Hi3516D V300. For details about these development boards, see [Appendix](../quick-start/quickstart-ide-lite-board-introduction.md). You can purchase the development board as required. +In this document, two development board models are used as examples: Hi3861 and Hi3516D V300. For details about these development boards, see [Appendix](../quick-start/quickstart-ide-lite-introduction-hi3861.md). You can purchase the development board as required. ## Development Process diff --git a/en/device-dev/quick-start/quickstart-ide-standard-overview.md b/en/device-dev/quick-start/quickstart-ide-standard-overview.md index c6a87ed86cf78b9c3f5bffadd84b838193f6f3f1..28485c75534254c9d286168ff94eadf3971ac0a4 100644 --- a/en/device-dev/quick-start/quickstart-ide-standard-overview.md +++ b/en/device-dev/quick-start/quickstart-ide-standard-overview.md @@ -12,7 +12,7 @@ To accommodate different developer habits, OpenHarmony provides two modes for ge - Installation package mode: Dependency download and installation as well as building operations are performed using commands. Burning and running are performed in DevEco Device Tool. OpenHarmony also provides the [Docker environment](../get-code/gettools-acquire.md), which can significantly simplify the environment configuration before compilation. You can build your source code in the Docker environment if you are more accustomed to using the installation package mode. -This document exemplifies how to use the IDE mode. For details about the installation package mode, see [Getting Started with Standard System (Installation Package Mode)](../quick-start/quickstart-standard-package-directory.md). +This document exemplifies how to use the IDE mode. For details about the installation package mode, see [Getting Started with Standard System (Installation Package Mode)](../quick-start/quickstart-standard-overview.md). ## Development Environment @@ -28,7 +28,7 @@ This document describes how to develop OpenHarmony in the Windows+Ubuntu environ ## Development Boards -In this document, two development board models are used as examples: Hi3516D V300 and RK3568. For details about these development boards, see [Appendix](../quick-start/quickstart-standard-board-introduction.md). You can purchase the development board as required. +In this document, two development board models are used as examples: Hi3516D V300 and RK3568. For details about these development boards, see [Appendix](../quick-start/quickstart-ide-standard-board-introduction-hi3516.md). You can purchase the development board as required. ## Development Process diff --git a/en/device-dev/quick-start/quickstart-lite-faq-burning.md b/en/device-dev/quick-start/quickstart-lite-faq-burning.md index 02fc1cfa341525b77efbe6391418ba52099b2525..d8555b3cc7c816d6e4cc6ce30c5f9918ddf40eb2 100644 --- a/en/device-dev/quick-start/quickstart-lite-faq-burning.md +++ b/en/device-dev/quick-start/quickstart-lite-faq-burning.md @@ -7,9 +7,9 @@ Error: Opening COMxx: Access denied is displayed after clicking Burn and selecting a serial port. - **Figure 1** Failed to open the serial port + **Figure 1** Failed to open the serial port - ![en-us_image_0000001226634728](figures/en-us_image_0000001226634728.png) + ![en-us_image_0000001226634728](figures/en-us_image_0000001226634728.png) - **Possible Causes** @@ -42,9 +42,9 @@ The file image cannot be obtained after clicking Burn and selecting a serial port. - **Figure 5** Failed to obtain the file image due to network disconnection + **Figure 5** Failed to obtain the file image due to network disconnection - ![en-us_image_0000001271234757](figures/en-us_image_0000001271234757.png) + ![en-us_image_0000001271234757](figures/en-us_image_0000001271234757.png) - **Possible Causes** @@ -125,15 +125,12 @@ 1. Obtain the U-Boot file. > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE** - > The U-Boot file of the two boards can be obtained from the following paths, respectively. - > - > Hi3516D V300: device\hisilicon\hispark_taurus\sdk_liteos\uboot\out\boot\u-boot-hi3516dv300.bin - > - > Hi3518E V300: device\hisilicon\hispark_aries\sdk_liteos\uboot\out\boot\u-boot-hi3518ev300.bin + > + > The U-Boot file can be obtained from the following path: device\hisilicon\hispark_taurus\sdk_liteos\uboot\out\boot\u-boot-hi3516dv300.bin. 2. Burn the U-Boot file by following the procedures for burning a U-Boot file over USB. - Select the U-Boot files of corresponding development boards for burning by referring to [Burning to Hi3516D V300](https://device.harmonyos.com/en/docs/documentation/guide/ide-hi3516-upload-0000001052148681)/[Burning to Hi3518E V300](https://device.harmonyos.com/en/docs/documentation/guide/ide-hi3518-upload-0000001057313128#section93591711580). + Select the U-Boot files of corresponding development boards for burning by referring to [Burning to Hi3516D V300](https://device.harmonyos.com/en/docs/documentation/guide/ide-hi3516-upload-0000001052148681). 3. Log in to the serial port after the burning is complete. diff --git a/en/device-dev/quick-start/quickstart-lite-overview.md b/en/device-dev/quick-start/quickstart-lite-overview.md index d3a580e6766caf3cb699088ffbb9d2f82575255b..478e08faa121d531456a8365999fe443d2d058ee 100644 --- a/en/device-dev/quick-start/quickstart-lite-overview.md +++ b/en/device-dev/quick-start/quickstart-lite-overview.md @@ -15,7 +15,7 @@ To accommodate different developer habits, OpenHarmony provides two modes for ge - Installation package mode: Dependency download and installation as well as building operations are performed using commands. Burning and running are performed in DevEco Device Tool. OpenHarmony also provides the [Docker environment](../get-code/gettools-acquire.md), which can significantly simplify the environment configuration before compilation. You can build your source code in the Docker environment if you are more accustomed to using the installation package mode. -This document exemplifies how to use the installation package mode. For details about the IDE mode, see [Getting Started with Mini and Small Systems (IDE Mode)](../quick-start/quickstart-lite-ide-directory.md). +This document exemplifies how to use the installation package mode. For details about the IDE mode, see [Getting Started with Mini and Small Systems (IDE Mode)](../quick-start/quickstart-ide-lite-overview.md). ## Development Environment @@ -31,7 +31,7 @@ This document describes how to develop OpenHarmony in the Windows+Ubuntu environ ## Development Boards -In this document, two development board models are used as examples: Hi3861 and Hi3516D V300. For details about these development boards, see [Appendix](../quick-start/quickstart-lite-board-introduction.md). You can purchase the development board as required. +In this document, two development board models are used as examples: Hi3861 and Hi3516D V300. For details about these development boards, see [Appendix](../quick-start/quickstart-lite-introduction-hi3861.md). You can purchase the development board as required. ## Development Process diff --git a/en/device-dev/quick-start/quickstart-standard-overview.md b/en/device-dev/quick-start/quickstart-standard-overview.md index 8b2dfb427ff73c4b4247cec57a079f9e790f6f8d..b7bb434f6b1ac67d26f86d4fab96b7041e9456d8 100644 --- a/en/device-dev/quick-start/quickstart-standard-overview.md +++ b/en/device-dev/quick-start/quickstart-standard-overview.md @@ -12,7 +12,7 @@ To accommodate different developer habits, OpenHarmony provides two modes for ge - Installation package mode: Dependency download and installation as well as building operations are performed using commands. Burning and running are performed in DevEco Device Tool. OpenHarmony also provides the [Docker environment](../get-code/gettools-acquire.md), which can significantly simplify the environment configuration before compilation. You can build your source code in the Docker environment if you are more accustomed to using the installation package mode. -This document exemplifies how to use the installation package mode. For details about the IDE mode, see [Getting Started with Standard System (IDE Mode)](../quick-start/quickstart-standard-ide-directory.md). +This document exemplifies how to use the installation package mode. For details about the IDE mode, see [Getting Started with Standard System (IDE Mode)](../quick-start/quickstart-ide-standard-overview.md). ## Development Environment @@ -28,7 +28,7 @@ This document describes how to develop OpenHarmony in the Windows+Ubuntu environ ## Development Boards -In this document, two development board models are used as examples: Hi3516D V300 and RK3516. For details about these development boards, see [Appendix](../quick-start/quickstart-standard-board-introduction.md). You can purchase the development board as required. +In this document, two development board models are used as examples: Hi3516D V300 and RK3516. For details about these development boards, see [Appendix](../quick-start/quickstart-standard-board-introduction-hi3516.md). You can purchase the development board as required. ## Development Process diff --git a/en/device-dev/quick-start/quickstart-standard-running-hi3516-create.md b/en/device-dev/quick-start/quickstart-standard-running-hi3516-create.md index e0ffea9670c0285a8731fd220e2d7173a1093bf0..7462695f2fd07300520ab566434c6082589d3bf4 100644 --- a/en/device-dev/quick-start/quickstart-standard-running-hi3516-create.md +++ b/en/device-dev/quick-start/quickstart-standard-running-hi3516-create.md @@ -8,7 +8,7 @@ The following exemplifies how to run the first program on the development board. The complete code directory is as follows: - + ``` applications/sample/hello │ │── BUILD.gn @@ -21,7 +21,7 @@ build └── subsystem_config.json productdefine/common └── products - └── Hi3568DV300.json + └── Hi3516DV300.json ``` @@ -34,7 +34,7 @@ Perform the steps below in the source code directory: Create the **applications/sample/hello/src/helloworld.c** directory and file whose code is shown in the following example. You can customize the content to be printed. For example, you can change **World** to **OH**. Declare the string printing function **HelloPrint** in the **helloworld.h** file. You can use either C or C++ to develop a program. - + ``` #include #include "helloworld.h" @@ -55,7 +55,7 @@ Perform the steps below in the source code directory: Add the header file **applications/sample/hello/include/helloworld.h**. The sample code is as follows: - + ``` #ifndef HELLOWORLD_H #define HELLOWORLD_H @@ -78,7 +78,7 @@ Perform the steps below in the source code directory: 2. Create a build file. 1. Create the **applications/sample/hello/BUILD.gn** file. The file content is as follows: - + ``` import("//build/ohos.gni") # Import the build template. ohos_executable("helloworld") {# Executable module. @@ -99,7 +99,7 @@ Perform the steps below in the source code directory: } ``` 2. Create the **applications/sample/hello/bundle.json** file and add the description of the **sample** component. The content is as follows: - + ``` { "name": "@ohos/hello", @@ -141,7 +141,7 @@ Perform the steps below in the source code directory: Add the configuration of the new subsystem to the **build/subsystem_config.json** file. - + ``` "sample": { "path": "applications/sample/hello", @@ -153,7 +153,7 @@ Perform the steps below in the source code directory: In the **productdefine/common/products/Hi3516DV300.json** file, add the **hello** part after the existing part. - + ``` "usb:usb_manager_native":{}, "applications:prebuilt_hap":{}, diff --git a/en/device-dev/subsystems/subsys-dfx-hichecker.md b/en/device-dev/subsystems/subsys-dfx-hichecker.md new file mode 100644 index 0000000000000000000000000000000000000000..afcb93bf9caac772e7afa714495ab6e72629c478 --- /dev/null +++ b/en/device-dev/subsystems/subsys-dfx-hichecker.md @@ -0,0 +1,110 @@ +# HiChecker Development + + +## Overview + +HiChecker is a framework provided by OpenHarmony for checking code errors and runtime results. It can be used for checking runtime errors during application and system development. This section applies only to the standard system. + + +## Development Guidelines + + +### Use Cases + +HiChecker is provided for you to check issues that may be easily ignored during development of OpenHarmony applications (including system-built and third-party applications). Such issues include calling of time-consuming functions by key application threads, event distribution and execution timeout in application processes, and ability resource leakage in application processes. The issues are recorded in logs or lead to process crashes explicitly so that you can notice them and take correction measures. + + +### Available APIs + +HiChecker provides the APIs listed in the following table. + + **Table 1** HiChecker APIs + +| **API**| **Description**| +| -------- | -------- | +| uint_64_t RULE_CAUTION_PRINT_LOG
= 1<<63; | Defines an alarm rule, which is programmed to record a log when an alarm is generated.| +| uint_64_t RULE_CAUTION_TRIGGER_CRASH = 1<<62; | Defines an alarm rule, which is programmed to force the application to exit when an alarm is generated.| +| uint_64_t RULE_THREAD_CHECK_SLOW_PROCESS = 1; | Defines a check rule, which is programmed to check whether any time-consuming function is called.| +| uint_64_t RULE_CHECK_SLOW_EVENT = 1<<32; | Defines a check rule, which is programmed to check whether the event distribution or processing time has exceeded the specified time threshold.| +| uint_64_t RULE_CHECK_ABILITY_CONNECTION_LEAK = 1<<33; | Defines a check rule, which is programmed to check ability leakage.| +| AddRule(uint_64_t rule) : void | Adds one or more rules. HiChecker detects unexpected operations or gives feedback based on the added rules.| +| RemoveRule(uint_64_t rule) : void | Removes one or more rules. The removed rules will no longer take effect.| +| GetRule() : uint_64_t | Obtains a collection of thread, process, and alarm rules that have been added.| +| Contains(uint_64_t rule) : bool | Checks whether the collection of added rules contains a specific rule. If a thread-level rule is specified, the system only checks whether it is contained in the current thread.| +| NotifySlowProcess(std::string tag) : void | Notifies your application of a slow process so that your application avoids calling it directly in key threads.| +| NotifySlowEvent(std::string tag) : void | Notifies your application that event distribution or execution has timed out.| +| NotifyAbilityConnectionLeak(Caution caution) : void | Notifies your application that AbilityConnection leakage has occurred.| +| GetTriggerRule() : uint_64_t | Obtains the rule that triggers the current alarm.| +| GetCautionMsg() : std::string | Obtains the alarm message.| +| GetStackTrace() : std::string | Obtains the stack when an alarm is triggered.| + + +### Development Example + +C++ + +1. Include the following HiChecker header file in the code file: + + ``` + #include "hichecker.h" + ``` + + For a non-DFX subsystem, add the **HiviewDFX** field. + + + ``` + using namespace OHOS::HiviewDFX; + ``` + + Use related APIs through static calls. + + + ``` + HiChecker::AddRule(Rule::RULE_THREAD_CHECK_SLOW_PROCESS); // Add a rule. + HiChecker::AddRule(Rule::RULE_CHECK_SLOW_EVENT | Rule::RULE_CAUTION_PRINT_LOG); // Add multiple rules. + HiChecker::Contains(Rule::RULE_CAUTION_PRINT_LOG); // true + HiChecker::GetRule(); //RULE_THREAD_CHECK_SLOW_PROCESS | RULE_CHECK_SLOW_EVENT | RULE_CAUTION_PRINT_LOG + ``` + + When a rule is triggered, an alarm is generated based on the rule, and a log is recorded by default. + + - RULE_CAUTION_PRINT_LOG + The log prints information such as the rule, thread ID, thread name, and stack that triggers the alarm. + + - RULE_CAUTION_TRIGGER_CRASH + The process exits directly, and the log prints the exit prompt and other auxiliary information. + + Usage of the **Notify** APIs: + + - NotifySlowProcess(std::string tag) + Notifies your application that a slow process has been called. The following is an example of the input arguments: + + + ``` + "threadId: xx,threadName:xx,actualTime:xx,delayTime:xx" + ``` + + - NotifySlowEvent(std::string tag) + Notifies your application that event distribution or execution has timed out. The following is an example of the input arguments: + + + ``` + "threadId: xx,threadName:xx,eventName:xx,actualTime:xx,delayTime:xx" + ``` + + - NotifyAbilityConnectionLeak(Caution caution) + Notifies your application that AbilityConnection leakage has occurred. The following example shows that a **Caution** instance is passed into this API. + + + ``` + Caution caution(Rule::RULE_CHECK_ABILITY_CONNECTION_LEAK , cautionMessage, stackTrace) + // cautionMessage is similar to other Notify APIs. + // stackTrace indicates the stack information when leakage occurs. + ``` + +2. Add the subsystem dependency to the **BUILD.gn** file that has imported the HiChecker module. + + ``` + include_dirs = [ "//base/hiviewdfx/interfaces/innerkits/libhichecker/include" ] + external_deps = [ "hichecker_native:libhichecker" ] + ``` diff --git a/en/device-dev/subsystems/subsys-dfx-hidumper.md b/en/device-dev/subsystems/subsys-dfx-hidumper.md new file mode 100644 index 0000000000000000000000000000000000000000..d647101d9117deb01b1e7389321aa6d81f75b314 --- /dev/null +++ b/en/device-dev/subsystems/subsys-dfx-hidumper.md @@ -0,0 +1,180 @@ +# HiDumper Development + + +## Overview + + +### Introduction + +HiDumper is a tool provided by OpenHarmony for developers, testers, and IDE tool engineers to obtain system information necessary for analyzing and locating faults. This section applies only to the standard system. + +### Source Code Directories + + +``` +/base/hiviewdfx/hidumper +├── frameworks # Framework code +│ ├── native # Core function code +│ │ │── include # Header files +│ │ │── src # Source files +│ │ │── common # Common function code +│ │ │── executor # Process executor code +│ │ │── factory # Factory code +│ │ │── manager # Core manager code +│ │ │── util # Utility source code +│── sa_profile # HiDumper SA profile +│── services # HiDumper service code +│ │── native # C++ service code +│ │── zidl # Communication function +│ │ │── include # Header files of the communication function +│ │ │── src # Source code of the communication function +├── test # Test cases +│ ├── unittest # Unit test code +│ ├── moduletest # Module-level test code +``` + + +## Usage + + +### Command-Line Options + + **Table 1** HiDumper command-line options + +| Option| Description| +| -------- | -------- | +| -h | Shows the help Information.| +| -t [timeout] | Specifies the timeout period, in seconds. The default value is **30**. Value **0** indicates no timeout limit.| +| -lc | Shows the system information cluster list.| +| -ls | Shows the system ability list.| +| -c | Exports system cluster information.| +| -c [base system] | Exports system cluster information based on **base** or **system** tags.| +| -s | Exports all system ability information.| +| -s [SA0 SA1] | Exports ability information corresponding to SA0 and SA1.| +| -s [SA] -a ['-h'] | Exports the system ability information **SA** using the **-h** parameter.| +| -e | Exports crash logs generated by the FaultLogger module.| +| --net | Exports network information.| +| --storage | Exports storage information.| +| -p | Exports the process list and all process information.| +| -p [pid] | Exports all information about a specified process.| +| --cpuusage [pid] | Exports the CPU usage information based on **pid**.| +| --cpufreq | Exports the actual CPU frequency.| +| --mem [pid] | Exports the memory usage information based on **pid**.| +| --zip | Compresses the exported information to a specified folder.| + + +### Development Example + +HiDumper helps you export basic system information to locate and analyze faults. Complex parameters passed to sub-services and abilities must be enclosed in double quotation marks. + +The procedure is as follows: + +1. Access the device CLI, and run the **hidumper -h** command to obtain the help information, which includes basic information and function syntax. + + ``` + hidumper -h + ``` + +2. Run the **hidumper -lc** command to obtain the system information cluster list. + + ``` + hidumper -lc + ``` + +3. Run the **hidumper -c** command to obtain all information that is classified by **base** and **system**. + + ``` + hidumper -c + ``` + +4. Run the **hidumper -c [base | system]** to obtain the system cluster information that is classified by **base** or **system**. + + ``` + hidumper -c base + hidumper -c system + ``` + +5. Run the **hidumper -ls** command to obtain the system ability list. + + ``` + hidumper -ls + ``` + +6. Run the **hidumper -s** command to obtain all system ability information. + + ``` + hidumper -s + ``` + +7. Run the **hidumper -s 3301 -a "-h"** command to obtain the help information about the ability whose ID is **3301**. + + ``` + hidumper -s 3301 -a "-h" + ``` + +8. Run the **hidumper -s 3008** command to obtain all information about the ability whose ID is **3008**. + + ``` + hidumper -s 3008 + ``` + +9. Run the **hidumper -e** command to obtain the crash information generated by the FaultLogger module. + + ``` + hidumper -e + ``` + +10. Run the **hidumper --net** command to obtain network information. + + ``` + hidumper --net + ``` + +11. Run the **hidumper --storage** command to obtain storage information. + + ``` + hidumper --storage + ``` + +12. Run the **hidumper -p** command to obtain process information, including the list and information of processes and threads. + + ``` + hidumper -p + ``` + +13. Run the **hidumper -p 1024** command to obtain information about the process whose PID is **1024**. + + ``` + hidumper -p 1024 + ``` + +14. Run the **hidumper --cpuusage [pid]** command to obtain the CPU usage information of the process whose PID has been specified. + + ``` + hidumper --cpuusage + hidumper --cpuusage 1024 + ``` + +15. Run the **hidumper --cpufreq** command to obtain the actual operating frequency of each CPU core. + + ``` + hidumper --cpufreq + ``` + +16. Run the **hidumper --mem [pid]** command to obtain all memory usage information of the process whose PID has been specified. + + ``` + hidumper --mem [pid] + ``` + +17. Run the **hidumper --zip** command to compress data to the **/data/dumper** directory. + + ``` + hidumper --zip + ``` + +18. Run the **hidumper -t timeout** command to set the timeout period, in seconds. The default value is **30**. Value **0** indicates no timeout limit. + + ``` + hidumper -t [timeout] + ``` diff --git a/en/device-dev/subsystems/subsys-dfx-overview.md b/en/device-dev/subsystems/subsys-dfx-overview.md index 6f10a07749d9fea236f098555710eb29a857fbab..ad0ada15bbcde99d901ea4e8d914467cc95aa63d 100644 --- a/en/device-dev/subsystems/subsys-dfx-overview.md +++ b/en/device-dev/subsystems/subsys-dfx-overview.md @@ -4,11 +4,14 @@ The DFX subsystem provides the following functions: -- HiLog: implements the logging function. It is applicable to Mini-System Devices \(reference memory ≥ 128 KiB\), Small-System Devices \(reference memory ≥ 1 MiB\), and Standard-System Devices \(reference memory ≥ 128 MB\). +- HiLog: implements the logging function. It is applicable to mini-system devices \(reference memory ≥ 128 KiB\), small-system devices \(reference memory ≥ 1 MiB\), and standard-system devices \(reference memory ≥ 128 MB\). -- HiTrace: implements distributed call chain tracing. It is applicable to Standard-System Devices \(reference memory ≥ 128 MB\). -- HiCollie: implements thread suspension detection. It is applicable to Standard-System Devices \(reference memory ≥ 128 MB\). -- HiSysEvent: implements system event logging. It is applicable to Standard-System Devices \(reference memory ≥ 128 MB\). +- HiTrace: implements distributed call chain tracing. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). +- HiCollie: implements thread suspension detection. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). +- HiSysEvent: implements system event logging. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). +- HiChecker: implements defect scanning. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). +- HiDumper: exports system information. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). +- FaultLogger: implements crash detection. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). ## Basic Concepts @@ -31,4 +34,3 @@ Event logging means to collect and log events reported during system running. Th **System event** A system event is an indication of the system status at a given time point during system running. You can use these events to analyze the status change of the system. - diff --git a/en/device-dev/website.md b/en/device-dev/website.md index a44a1fa93261925151a7731b7c9297e90639e6d6..cbf383fc3d133fab7dea6b0c69ca4ccce60d0d4b 100644 --- a/en/device-dev/website.md +++ b/en/device-dev/website.md @@ -1,5 +1,6 @@ +# OpenHarmony Device Development Documentation - [Device Development Guide](device-dev-guide.md) -- Quick Start +- Getting Started - Getting Started with Mini and Small Systems (IDE Mode, Recommended) - [Mini and Small System Overview](quick-start/quickstart-ide-lite-overview.md) - Environment Preparation @@ -20,8 +21,9 @@ - [Burning](quick-start/quickstart-ide-lite-steps-hi3516-burn.md) - [Running](quick-start/quickstart-ide-lite-steps-hi3516-running.md) - Appendix - - [Introduction to the Hi3861 Development Board](quick-start/quickstart-ide-lite-introduction-hi3861.md) - - [Introduction to the Hi3516 Development Board](quick-start/quickstart-ide-lite-introduction-hi3516.md) + - Introduction to Development Boards + - [Introduction to the Hi3861 Development Board](quick-start/quickstart-ide-lite-introduction-hi3861.md) + - [Introduction to the Hi3516 Development Board](quick-start/quickstart-ide-lite-introduction-hi3516.md) - Getting Started with Mini and Small Systems (Installation Package Mode) - [Mini and Small System Overview](quick-start/quickstart-lite-overview.md) - [Environment Preparation](quick-start/quickstart-lite-env-setup.md) @@ -67,8 +69,9 @@ - [Burning](quick-start/quickstart-ide-standard-running-rk3568-burning.md) - [Running](quick-start/quickstart-ide-standard-running-rk3568-running.md) - Appendix - - [Introduction to the Hi3516 Development Board](quick-start/quickstart-ide-standard-board-introduction-hi3516.md) - - [Introduction to the RK3568 Development Board](quick-start/quickstart-ide-standard-board-introduction-rk3568.md) + - Introduction to Development Boards + - [Introduction to the Hi3516 Development Board](quick-start/quickstart-ide-standard-board-introduction-hi3516.md) + - [Introduction to the RK3568 Development Board](quick-start/quickstart-ide-standard-board-introduction-rk3568.md) - Getting Started with Standard System (Installation Package Mode) - [Standard System Overview](quick-start/quickstart-standard-overview.md) - [Setting Up Environments for Standard System](quick-start/quickstart-standard-env-setup.md) @@ -92,14 +95,14 @@ - [Introduction to the Hi3516 Development Board](quick-start/quickstart-standard-board-introduction-hi3516.md) - [Introduction to the RK3568 Development Board](quick-start/quickstart-standard-board-introduction-rk3568.md) - [Reference](quick-start/quickstart-standard-reference.md) - - [Obtaining Source Code](get-code/sourcecode-acquire.md) + - [Obtaining Source Code](get-code/sourcecode-acquire.md) - Compatibility and Security - [Privacy Protection](security/security-privacy-protection.md) - [Security Guidelines](security/security-guidelines-overall.md) - Porting - Mini System SoC Porting Guide - Porting Preparations - - [Before You Start](porting/oem_transplant_chip_prepare_knows.md) + - [Before You Start](porting/porting-chip-prepare-knows.md) - [Building Adaptation Process](porting/porting-chip-prepare-process.md) - Kernel Porting - [Overview](porting/porting-chip-kernel-overview.md) @@ -133,8 +136,8 @@ - [Porting a Library Built Using CMake](porting/porting-thirdparty-cmake.md) - [Porting a Library Built Using Makefile](porting/porting-thirdparty-makefile.md) - Mini System SoC Porting Cases - - [Mini-System Devices with Screens — Bestechnic SoC Porting Case](porting/porting-bes2600w-on-minisystem-display-demo.md) - - [Combo Solution – ASR Chip Porting Case](porting/porting-asr582x-combo-demo.md) + - [Mini-System Devices with Screens — Bestechnic SoC Porting Case](porting-bes2600w-on-minisystem-display-demo.md) + - [Combo Solution – ASR Chip Porting Case](porting-asr582x-combo-demo.md) - Subsystem Development - Kernel - Kernel for Mini Systems @@ -170,8 +173,7 @@ - [LMS](kernel/kernel-mini-memory-lms.md) - Appendix - [Kernel Coding Specification](kernel/kernel-mini-appx-code.md) - - Basic Data Structure - - [Doubly Linked List](kernel/kernel-mini-appx-data-list.md) + - [Doubly Linked List](kernel/kernel-mini-appx-data-list.md) - Standard Libraries - [CMSIS Support](kernel/kernel-mini-appx-lib-cmsis.md) - [POSIX Support](kernel/kernel-mini-appx-lib-posix.md) @@ -245,8 +247,6 @@ - [uname](kernel/kernel-small-debug-shell-cmd-uname.md) - [vmm](kernel/kernel-small-debug-shell-cmd-vmm.md) - [watch](kernel/kernel-small-debug-shell-cmd-watch.md) - - [reboot](kernel/kernel-small-debug-shell-cmd-reboot.md) - - [top](kernel/kernel-small-debug-shell-cmd-top.md) - File Commands - [cat](kernel/kernel-small-debug-shell-file-cat.md) - [cd](kernel/kernel-small-debug-shell-file-cd.md) @@ -269,8 +269,6 @@ - [touch](kernel/kernel-small-debug-shell-file-touch.md) - [writeproc](kernel/kernel-small-debug-shell-file-write.md) - [umount](kernel/kernel-small-debug-shell-file-umount.md) - - [du](kernel/kernel-small-debug-shell-file-du.md) - - [mv](kernel/kernel-small-debug-shell-file-mv.md) - Network Commands - [arp](kernel/kernel-small-debug-shell-net-arp.md) - [dhclient](kernel/kernel-small-debug-shell-net-dhclient.md) @@ -285,8 +283,8 @@ - [Magic Key](kernel/kernel-small-debug-shell-magickey.md) - [User-Space Exception Information](kernel/kernel-small-debug-shell-error.md) - [Trace](kernel/kernel-small-debug-trace.md) - - [perf](kernel/kernel-mini-memory-perf.md) - - [LMS](kernel/kernel-small-memory-lms.md) + - [perf](kernel/kernel-mini-memory-perf) + - [LMS](kernel/kernel-small-memory-lms) - [CPUP](kernel/kernel-small-debug-process-cpu.md) - Memory Debugging - [Memory Information Statistics](kernel/kernel-small-debug-memory-info.md) @@ -328,31 +326,39 @@ - [HDF Development Example](driver/driver-hdf-sample.md) - Platform Driver Development - [ADC](driver/driver-platform-adc-develop.md) + - [DAC](driver/driver-platform-dac-develop.md) - [GPIO](driver/driver-platform-gpio-develop.md) - [HDMI](driver/driver-platform-hdmi-develop.md) - [I2C](driver/driver-platform-i2c-develop.md) - [I3C](driver/driver-platform-i3c-develop.md) + - [MIPI CSI](driver/driver-platform-mipicsi-develop.md) - [MIPI DSI](driver/driver-platform-mipidsi-develop.md) - [MMC](driver/driver-platform-mmc-develop.md) + - [PIN](driver/driver-platform-pin-develop.md) - [PWM](driver/driver-platform-pwm-develop.md) + - [Regulator](driver/driver-platform-regulator-develop.md) - [RTC](driver/driver-platform-rtc-develop.md) - [SDIO](driver/driver-platform-sdio-develop.md) - [SPI](driver/driver-platform-spi-develop.md) - [UART](driver/driver-platform-uart-develop.md) - - [Watchdog](driver/driver-platform-watchdog-develop.md) + - [WatchDog](driver/driver-platform-watchdog-develop.md) - Platform Driver Usage - [ADC](driver/driver-platform-adc-des.md) + - [DAC](driver/driver-platform-dac-des.md) - [GPIO](driver/driver-platform-gpio-des.md) - [HDMI](driver/driver-platform-hdmi-des.md) - [I2C](driver/driver-platform-i2c-des.md) - [I3C](driver/driver-platform-i3c-des.md) + - [MIPI CSI](driver/driver-platform-mipicsi-des.md) - [MIPI DSI](driver/driver-platform-mipidsi-des.md) + - [PIN](driver/driver-platform-pin-des.md) - [PWM](driver/driver-platform-pwm-des.md) + - [Regulator](driver/driver-platform-regulator-des.md) - [RTC](driver/driver-platform-rtc-des.md) - [SDIO](driver/driver-platform-sdio-des.md) - [SPI](driver/driver-platform-spi-des.md) - [UART](driver/driver-platform-uart-des.md) - - [Watchdog](driver/driver-platform-watchdog-des.md) + - [WatchDog](driver/driver-platform-watchdog-des.md) - Peripheral Driver Usage - [LCD](driver/driver-peripherals-lcd-des.md) - [Touchscreen](driver/driver-peripherals-touch-des.md) @@ -361,6 +367,8 @@ - [Audio](driver/driver-peripherals-audio-des.md) - [USB](driver/driver-peripherals-usb-des.md) - [Camera](driver/driver-peripherals-camera-des.md) + - [Vibrator](driver/driver-peripherals-vibrator-des.md) + - [Light](driver/driver-peripherals-light-des.md) - Compilation and Building - [Building Guidelines for Mini and Small Systems](subsystems/subsys-build-mini-lite.md) - [Building Guidelines for Standard Systems](subsystems/subsys-build-standard-large.md) @@ -379,7 +387,7 @@ - [Development Guidelines on Photographing](subsystems/subsys-multimedia-camera-photo-guide.md) - [Development Guidelines on Video Recording](subsystems/subsys-multimedia-camera-record-guide.md) - [Development Guidelines on Previewing](subsystems/subsys-multimedia-camera-preview-guide.md) - - Audio/Video + - Audio and Video - [Overview](subsystems/subsys-multimedia-video-overview.md) - [Development Guidelines on Media Playback](subsystems/subsys-multimedia-video-play-guide.md) - [Development Guidelines on Media Recording](subsystems/subsys-multimedia-video-record-guide.md) @@ -422,16 +430,15 @@ - [Setting Up a Development Environment](subsystems/subsys-application-framework-envbuild.md) - [Development Guidelines](subsystems/subsys-application-framework-guide.md) - [Development Example](subsystems/subsys-application-framework-demo.md) - - [OTA Upgrade](subsystems/subsys-ota-guide.md) - - Telephony Service - - [Telephony Service](subsystems/telephony-service.md) - - [Development Guidelines](subsystems/development-guidelines.md) + - [OTA Update](subsystems/subsys-ota-guide.md) + - Telephony + - [Telephony Overview](subsystems/subsys-tel-overview.md) + - [Telephony Development](subsystems/subsys-tel-guide.md) - Security - [Overview](subsystems/subsys-security-overview.md) - [Development Guidelines on Application Signature Verification](subsystems/subsys-security-sigverify.md) - [Development Guidelines on Application Permission Management](subsystems/subsys-security-rightmanagement.md) - [Development Guidelines on IPC Authentication](subsystems/subsys-security-communicationverify.md) - - [Development on Device Security Level Management](subsystems/subsys-security-devicesecuritylevel.md) - Startup - [Startup](subsystems/subsys-boot-overview.md) - [init Module](subsystems/subsys-boot-init.md) @@ -470,7 +477,7 @@ - [Photographing](guide/device-iotcamera-control-demo-photodevguide.md) - [Video Recording](guide/device-iotcamera-control-demo-videodevguide.md) - [Use Case](guide/device-iotcamera-control-example.md) - - Cameras with a Screen + - Cameras with a Screen) - Screen and Camera Control - [Overview](guide/device-camera-control-overview.md) - Development Guidelines @@ -493,10 +500,10 @@ - [Development Example for Peripheral Drivers](guide/device-outerdriver-demo.md) - Debugging - [Test Subsystem](subsystems/subsys-testguide-test.md) - - [R&D Tools](subsystems/subsys-toolchain.md) + - Debugging Tools - [bytrace Usage Guidelines](subsystems/subsys-toolchain-bytrace-guide.md) - [hdc_std Usage Guidelines](subsystems/subsys-toolchain-hdc-guide.md) -- [XTS](subsystems/subsys-xts-guide.md) +- [XTS Certification](subsystems/subsys-xts-guide.md) - Tools - [Docker Environment](get-code/gettools-acquire.md) - [IDE](get-code/gettools-ide.md) diff --git a/zh-cn/application-dev/ability/context-userguide.md b/zh-cn/application-dev/ability/context-userguide.md deleted file mode 100644 index f5472f3e5427dc48d1a51322b1dbec335197d053..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ability/context-userguide.md +++ /dev/null @@ -1,238 +0,0 @@ -# 应用上下文使用指导 - -## Context概述 -​ context是应用中对象的上下文,提供获取应用程序环境信息的能力。 - -## Context整体结构介绍 - -​ OpenHarmony的应用框架分为FA模型和Stage两种模型。对应存在两套Context机制适配两种应用框架模型: - -​ **application/BaseContext** 属于一个通用的Context基类,既不属于FA模型也不属于Stage模型,里面只有一个属性stageMode,用来区分开发模型是FA还是Stage。 - -​ **FA模型** 只有app/Context中的方法属于FA模型对应的Context。该模式下,应用级别的Context和Ability级别的Context都是该类型的实例,如果在应用级别的Context里面调用了Ability级别的方法,会产生错误。所以开发者需要注意context实例所代表的实际含义。 - -​ **Stage模型** 除了app/Context之外的Context都属于Stage模型,分别有application/Context、application/AbilityStageContext、application/ExtensionContext、application/AbilityContext、application/FormExtensionContext和application/ServiceExtensionContext六种Context。这些Context的介绍及使用方式将会在[Stage模型和Context详细介绍](#stage模型和context详细介绍)种进行说明。 - - -![contextIntroduction](figures/contextIntroduction.png) - -## FA模型的Context详细介绍 - -​ 只有app/Context中的方法属于FA模型对应的Context。 - -​ FA模型只有一个Context定义。Context中所有的功能都是通过方法来提供的,它提供了一些featureAbility中不存在的方法,相当于featureAbility的一个扩展和补全。 - -​ d.ts文件如下: - -​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/app/context.d.ts - -​ 应用的使用方式: - -```javascript -// 1.引入featureAbility -import featureAbility from '@ohos.ability.featureAbility' - -export default { - onCreate() { - console.log('Application onCreate') - - // 2.获取Context - let context = featureAbility.getContext(); - - // 3.调用对应的方法 - context.setShowOnLockScreen(false, (data) => { - console.log("data: " + JSON.stringify(data)); - }); - }, - onActive() { - console.log('Application onActive') - }, - onDestroy() { - console.log('Application onDestroy') - }, -} -``` - -## Stage模型和Context详细介绍 - -​ Stage模型有6大Context: - -### application/Context - -**概述** - -​ application/Context类型的Context是基类Context,里面提供了应用的一些基础信息:resourceManager、applicationInfo、cacheDir等,还有应用的一些基本方法:createBundleContext、switchArea等。应用级别的Context也是application/Context这种类型。 - -**获取方法** - -​ 需要在AbilityStage、Ability、Extension等组件中通过context.getApplicationContext()拿到。 - -**示例** - -```javascript -export default class MainAbility extends Ability { - onCreate(want, launchParam) { - console.log('MainAbility onCreate is called' + want + launchParam); - // 获取ApplicationContext - let appContext = this.context.getApplicationContext(); - // 获取路径 - console.log('filesDir is ' + appContext.filesDir); - } - - onDestroy() { - console.log('MainAbility onDestroy is called'); - } -} -``` - -**d.ts声明** - -​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/Context.d.ts - -### application/AbilityStageContext - -​ **概述** - -​ application/AbilityStageContext是Hap包级别的Context。和基类Context相比,Hap包级别的Context中多了HapModuleInfo和Configuration两个信息。 - -**获取方法** - -​ 可以直接在AbilityStage中通过context属性拿到。 - -**示例** - -```javascript -export default class MyAbilityStage extends AbilityStage { - onCreate() { - // 属性context就是AbilityStageContext类型的 - console.log('HapModuleInfo is ' + context.currentHapModuleInfo); - } -} -``` - -**d.ts声明** - -​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/AbilityStageContext.d.ts - -### application/AbilityContext - -​ **概述** - -​ Stage模型下,每个Ability中都包含了一个Context属性。 - -​ Ability功能主要是处理生命周期,其余操作Ability的方法(如startAbility、connectAbility等)都是在AbilityContext中实现的。 - -**获取方法** - -​ 在Ability中通过context属性拿到。 - -**示例** - -```javascript -export default class MainAbility extends Ability { - onCreate(want, launchParam) { - console.log('MainAbility onCreate is called' + want + launchParam); - var want = { - "bundleName": "com.example.MyApplication", - "abilityName": "ServiceExtAbility", - } - // 1.这里的Context就是AbilityContext - let contxt = this.context; - // 2.startAbility - contxt.startAbility(want).then((data) => { - console.info("startAbility success:" + JSON.stringify(data)); - }).catch((error) => { - console.error("startAbility failed:" + JSON.stringify(error)); - }); - } - - onDestroy() { - console.log("MainAbility on Destroy is called"); - } -} -``` - -**d.ts声明** - -​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/AbilityContext.d.ts - -### application/ExtensionContext - -​ **概述** - -​ 和FA模型不同的是,Stage模型把Service从Ability中剥离出来,单独定义了一组通用扩展类Extension用来处理等同的功能。Extension是一个基类,不承担具体业务功能。业务方根据自己的需要去扩展对应的Extension,例如:ServiceAbility扩展为了ServiceExtensionAbility,卡片扩展为了FormExtension。 - -​ 因此新增了一种和Extension匹配的ExtensionContext。ExtensionContext中包含HapModuleInfo和Configuration两个属性。 - -**获取方法** - -​ 不会单独使用。 - -**d.ts声明** - -​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/ExtensionContext.d.ts - -### application/ServiceExtensionContext - -​ **概述** - -​ ServiceExtensionAbility类似于FA模型的ServiceAbility,里面只有生命周期回调相关的处理。 - -​ 操作ServiceExtensionAbility的方法移动到了ServiceExtensionContext中(如startAbility、connectAbility等)。 - -**获取方法** - -​ ServiceExtensionAbility中通过context属性获取。 - -**示例** -```javascript -export default class ServiceExtAbility extends ServiceExtensionAbility { - onCreate(want) { - console.info("ServiceAbility onCreate**"); - // 1.这里的Context就是ServiceExtensionContext - let contxt = this.context; - } - - onRequest(want, startId) { - console.info("ServiceAbility onRequest**"); - } - - onConnect(want) { - console.info("ServiceAbility onConnect**"); - return new StubTest("test"); - } - - onDisconnect(want) { - console.info("ServiceAbility onDisconnect**"); - } - - onDestroy() { - console.info("ServiceAbility onDestroy**"); - } -} - -``` - -**d.ts声明** - -​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/ServiceExtensionContext.d.ts - -### application/FormExtensionContext - -​ [FormExtensionContext](/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md) - -**d.ts声明** - -​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/FormExtensionContext.d.ts - -## 常见问题 - -**通过globalThis去获取Context** - -**结论** - -​ FA模型可以通过该方式去获取;Stage模型不可通过该方式去获取,要通过对应组件的属性去获取。 - -**原因** - -​ 应用框架在API8上推出了新的应用模型(Stage模型)。在老的模型(FA模型)下,每个Ability实例有一个js虚拟机实例,所以可以从js引擎的global对象上,获取到一个全局的Ability实例,但是在新的模型(Stage模型)下,整个应用进程共用一个js虚拟机实例,其中可以运行多个Ability实例,这样就不存在一个全局的Ability实例。如果开发者在新的模型(Stage模型)下,调用的API实现仍然走到了获取全局Ability实例的方法,就可能会发生错误或者崩溃。 \ No newline at end of file diff --git a/zh-cn/application-dev/ability/fa-formability.md b/zh-cn/application-dev/ability/fa-formability.md index 41ed0fec0e7952625a2bf1ae578a6a5977f540a8..2cfba0d06c0b3dd13bc987127fdf9acbe41fa49e 100644 --- a/zh-cn/application-dev/ability/fa-formability.md +++ b/zh-cn/application-dev/ability/fa-formability.md @@ -231,7 +231,7 @@ Form需要在应用配置文件config.json中进行配置。 } ``` -具体的持久化方法可以参考[轻量级数据存储开发指导](../database/database-preference-guidelines.md)。 +具体的持久化方法可以参考[轻量级数据存储开发指导](../database/database-storage-guidelines.md)。 需要注意的是,卡片使用方在请求卡片时传递给提供方应用的Want数据中存在临时标记字段,表示此次请求的卡片是否为临时卡片: diff --git a/zh-cn/application-dev/ability/fa-serviceability.md b/zh-cn/application-dev/ability/fa-serviceability.md index f1406df29a6e9d2e38adbe1d7d06d84565cd8749..4afa94f47ee503f544cdfd59e543a1473a519fe5 100644 --- a/zh-cn/application-dev/ability/fa-serviceability.md +++ b/zh-cn/application-dev/ability/fa-serviceability.md @@ -24,16 +24,16 @@ ```javascript export default { - onStart(want) { + onStart() { console.log('ServiceAbility onStart'); }, - onCommand(want, restart, startId) { + onCommand(want, startId) { console.log('ServiceAbility onCommand'); }, onConnect(want) { console.log('ServiceAbility OnConnect'); }, - onDisconnect() { + onDisconnect(want) { console.log('ServiceAbility OnDisConnect'); }, onStop() { @@ -174,7 +174,7 @@ import rpc from "@ohos.rpc"; let mMyStub; export default { - onStart(want) { + onStart() { class MyStub extends rpc.RemoteObject{ constructor(des) { if (typeof des === 'string') { @@ -182,7 +182,7 @@ export default { } return null; } - onRemoteRequest(code, message, reply, option) { + onRemoteRequest(code, data, reply, option) { console.log("ServiceAbility onRemoteRequest called"); if (code === 1) { let op1 = data.readInt(); @@ -197,14 +197,14 @@ export default { } mMyStub = new MyStub("ServiceAbility-test"); }, - onCommand(want, restart, startId) { + onCommand(want, startId) { console.log('ServiceAbility onCommand'); }, onConnect(want) { console.log('ServiceAbility OnConnect'); return mMyStub; }, - onDisconnect() { + onDisconnect(want) { console.log('ServiceAbility OnDisConnect'); }, onStop() { @@ -225,12 +225,12 @@ export default { ```ts let mRemote; function onConnectCallback(element, remote){ - console.log('onConnectLocalService onConnectDone element: ' + element); - console.log('onConnectLocalService onConnectDone remote: ' + remote); + console.log('onConnectRemoteService onConnectDone element: ' + element); + console.log('onConnectRemotelService onConnectDone remote: ' + remote); mRemote = remote; if (mRemote == null) { prompt.showToast({ - message: "onConnectLocalService not connected yet" + message: "onConnectRemoteService not connected yet" }); return; } @@ -243,7 +243,7 @@ function onConnectCallback(element, remote){ console.log('sendRequest success'); let msg = reply.readInt(); prompt.showToast({ - message: "onConnectLocalService connect result: " + msg, + message: "onConnectRemoteService connect result: " + msg, duration: 3000 }); }).catch((e) => { diff --git a/zh-cn/application-dev/ability/stage-formextension.md b/zh-cn/application-dev/ability/stage-formextension.md index d6977be8d4e88b1a33d01c416197a81959db4002..b9b095df6c828a9fe3672cc0b9c8a548543c18d0 100644 --- a/zh-cn/application-dev/ability/stage-formextension.md +++ b/zh-cn/application-dev/ability/stage-formextension.md @@ -244,7 +244,7 @@ Form需要在应用配置文件module.json中进行配置。 } ``` -具体的持久化方法可以参考[轻量级数据存储开发指导](../database/database-preference-guidelines.md)。 +具体的持久化方法可以参考[轻量级数据存储开发指导](../database/database-storage-guidelines.md)。 需要注意的是,卡片使用方在请求卡片时传递给提供方应用的Want数据中存在临时标记字段,表示此次请求的卡片是否为临时卡片: diff --git a/zh-cn/application-dev/application-dev-website.md b/zh-cn/application-dev/application-dev-website.md index 92036448771eb28017517abb7655f75ce415dcc0..a849a0cffef36e1fda7b1749f996bc87f4dc8c2e 100644 --- a/zh-cn/application-dev/application-dev-website.md +++ b/zh-cn/application-dev/application-dev-website.md @@ -159,13 +159,13 @@ - [自定义组件生命周期回调函数](ui/ts-custom-component-lifecycle-callbacks.md) - [组件创建和重新初始化示例](ui/ts-component-creation-re-initialization.md) - [语法糖](ui/ts-syntactic-sugar.md) - - 常见组件开发指导 - - [Button开发指导](ui/ui-ts-basic-components-button.md) - - [Web开发指导](ui/ui-ts-components-web.md) - - 常见布局开发指导 - - [弹性布局](ui/ui-ts-layout-flex.md) - - [栅格布局](ui/ui-ts-layout-grid-container.md) - - [媒体查询](ui/ui-ts-layout-mediaquery.md) + - 常见组件开发指导 + - [Button开发指导](ui/ui-ts-basic-components-button.md) + - [Web开发指导](ui/ui-ts-components-web.md) + - 常见布局开发指导 + - [弹性布局](ui/ui-ts-layout-flex.md) + - [栅格布局](ui/ui-ts-layout-grid-container.md) + - [媒体查询](ui/ui-ts-layout-mediaquery.md) - 体验声明式UI - [创建声明式UI工程](ui/ui-ts-creating-project.md) - [初识Component](ui/ui-ts-components.md) @@ -198,6 +198,7 @@ - [音频采集开发指导](media/audio-capturer.md) - 视频 - [视频播放开发指导](media/video-playback.md) + - [视频录制开发指导](media/video-recorder.md) - 图片 - [图片开发指导](media/image.md) - 安全 diff --git a/zh-cn/application-dev/media/Readme-CN.md b/zh-cn/application-dev/media/Readme-CN.md index 4d7b4bd16188112e67ab3b3b5113e2166766f8b0..f069d43ad040419bc6efdbda2b6051b6e3d055cc 100755 --- a/zh-cn/application-dev/media/Readme-CN.md +++ b/zh-cn/application-dev/media/Readme-CN.md @@ -9,5 +9,7 @@ - 视频 - [视频播放开发指导](video-playback.md) + - [视频录制开发指导](video-recorder.md) + - 图片 - [图片开发指导](image.md) diff --git a/zh-cn/application-dev/media/video-recorder.md b/zh-cn/application-dev/media/video-recorder.md new file mode 100644 index 0000000000000000000000000000000000000000..efe3d29d97b70f6bf3870fff05206d3196633800 --- /dev/null +++ b/zh-cn/application-dev/media/video-recorder.md @@ -0,0 +1,152 @@ +# 视频录制开发指导 + +## 场景介绍 + +视频录制的主要工作是捕获音视频信号,完成音视频编码并保存到文件中,帮助开发者轻松实现音视频录制功能。它允许调用者指定录制的编码格式、封装格式、文件路径等参数。 + +**图1** 视频录制状态机 + +![zh-ch_image_video_recorder_state_machine](figures/zh-ch_image_video_recorder_state_machine.png) + + + +**图2** 视频录制零层图 + +![zh-ch_image_video_recorder_zero](figures/zh-ch_image_video_recorder_zero.png) + +## 开发步骤 + +详细API含义可参考:[媒体服务API文档VideoRecorder](../reference/apis/js-apis-media.md) + +### 全流程场景 + +包含流程:创建实例,设置录制参数,录制视频,暂停录制,恢复录制,停止录制,释放资源等流程。 + +```js +import media from '@ohos.multimedia.media' +import mediaLibrary from '@ohos.multimedia.mediaLibrary' +export class VideoRecorderDemo { + private testFdNumber; // 用于保存fd地址 + // pathName是传入的录制文件名,例如:01.mp4,生成后的文件地址:/storage/media/100/local/files/Video/01.mp4 + // 使用mediaLibrary需要添加以下权限, ohos.permission.MEDIA_LOCATION、ohos.permission.WRITE_MEDIA、ohos.permission.READ_MEDIA + async getFd(pathName) { + let displayName = pathName; + const mediaTest = mediaLibrary.getMediaLibrary(); + let fileKeyObj = mediaLibrary.FileKey; + let mediaType = mediaLibrary.MediaType.VIDEO; + let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); + let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); + if (dataUri != undefined) { + let args = dataUri.id.toString(); + let fetchOp = { + selections : fileKeyObj.ID + "=?", + selectionArgs : [args], + } + let fetchFileResult = await mediaTest.getFileAssets(fetchOp); + let fileAsset = await fetchFileResult.getAllObject(); + let fdNumber = await fileAsset[0].open('Rw'); + this.testFdNumber = "fd://" + fdNumber.toString(); + } + } + + // 当发生错误上上报的错误回调接口 + failureCallback(error) { + console.info('error happened, error name is ' + error.name); + console.info('error happened, error code is ' + error.code); + console.info('error happened, error message is ' + error.message); + } + + // 当发生异常时,系统调用的错误回调接口 + catchCallback(error) { + console.info('catch error happened, error name is ' + error.name); + console.info('catch error happened, error code is ' + error.code); + console.info('catch error happened, error message is ' + error.message); + } + + async videoRecorderDemo() { + let videoRecorder = null; // videoRecorder空对象在createVideoRecorder成功后赋值 + let surfaceID = null; // 用于保存getInputSurface返回的surfaceID + // 获取需要录制的视频的fd地址 + await this.getFd('01.mp4'); + // 录制相关参数配置 + let videoProfile = { + audioBitrate : 48000, + audioChannels : 2, + audioCodec : 'audio/mp4a-latm', + audioSampleRate : 48000, + fileFormat : 'mp4', + videoBitrate : 48000, + videoCodec : 'video/mp4v-es', + videoFrameWidth : 640, + videoFrameHeight : 480, + videoFrameRate : 30 + } + + let videoConfig = { + audioSourceType : 1, + videoSourceType : 0, + profile : videoProfile, + url : this.testFdNumber, // testFdNumber由getFd生成 + orientationHint : 0, + location : { latitude : 30, longitude : 130 }, + } + // 创建videoRecorder对象 + await media.createVideoRecorder().then((recorder) => { + console.info('case createVideoRecorder called'); + if (typeof (recorder) != 'undefined') { + videoRecorder = recorder; + console.info('createVideoRecorder success'); + } else { + console.info('createVideoRecorder failed'); + } + }, this.failureCallback).catch(this.catchCallback); + + // 调用prepare完成视频录制前的准备工作 + await videoRecorder.prepare(videoConfig).then(() => { + console.info('prepare success'); + }, this.failureCallback).catch(this.catchCallback); + + // 获取surfaceID并保存下来传递给camera相关接口 + await videoRecorder.getInputSurface().then((surface) => { + console.info('getInputSurface success'); + surfaceID = surface; + }, this.failureCallback).catch(this.catchCallback); + + // 视频录制依赖相机相关接口,以下需要先调用相机起流接口后才能继续执行,具体的相机接口调用请参考sample用例 + // 视频录制启动接口 + await videoRecorder.start().then(() => { + console.info('start success'); + }, this.failureCallback).catch(this.catchCallback); + + // 调用pause接口时需要暂停camera出流 + await videoRecorder.pause().then(() => { + console.info('pause success'); + }, this.failureCallback).catch(this.catchCallback); + + // 调用resume接口时需要恢复camera出流 + await videoRecorder.resume().then(() => { + console.info('resume success'); + }, this.failureCallback).catch(this.catchCallback); + + // 停止camera出流后,停止视频录制 + await videoRecorder.stop().then(() => { + console.info('stop success'); + }, this.failureCallback).catch(this.catchCallback); + + // 重置录制相关配置 + await videoRecorder.reset().then(() => { + console.info('reset success'); + }, this.failureCallback).catch(this.catchCallback); + + // 释放视频录制相关资源并释放camera对象相关资源 + await videoRecorder.release().then(() => { + console.info('release success'); + }, this.failureCallback).catch(this.catchCallback); + + // 相关对象置null + videoRecorder = undefined; + surfaceID = undefined; + } +} +``` + diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-context.md b/zh-cn/application-dev/reference/apis/js-apis-application-context.md new file mode 100644 index 0000000000000000000000000000000000000000..4fa6b87cffc617ec1ed7562389fee67aa32bcced --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-application-context.md @@ -0,0 +1,81 @@ +# Context + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +提供开发者运行代码的上下文环境,包括应用信息、ResourceManager等信息。 + + +## 使用说明 + + +通过AbilityContext等继承实现。 + + +## 属性 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core + + | 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| resourceManager | ResourceManager | 是 | 否 | ResourceManager对象。 | +| applicationInfo | ApplicationInfo | 是 | 否 | 当前应用信息。 | +| cacheDir | string | 是 | 否 | 应用在内部存储上的缓存路径。 | +| tempDir | string | 是 | 否 | 应用的临时文件路径。 | +| filesDir | string | 是 | 否 | 应用在内部存储上的文件路径。 | +| databaseDir | string | 是 | 否 | 获取本地数据存储路径。 | +| storageDir | string | 是 | 否 | 获取轻量级数据存储路径。 | +| bundleCodeDir | string | 是 | 否 | 应用安装路径。 | +| distributedFilesDir | string | 是 | 否 | 应用的分布式文件路径。 | +| eventHub | [EventHub](js-apis-eventhub.md) | 是 | 否 | 事件中心信息。| + + +## Context.createBundleContext + +createBundleContext(bundleName: string): Context; + +创建指定应用上下文。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | bundleName | string | 是 | 应用bundle名。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Context | 对应创建应用的上下文context。 | + +**示例:** + + ```js + let test = "com.example.test"; + let context = this.context.createBundleContext(test); + ``` + + +## Context.getApplicationContext + +getApplicationContext(): Context; + +获取当前context。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Context | 当前Context 信息。 | + +**示例:** + + ```js + // 必选项。 + let context = this.context.getApplicationContext(); + ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-convertxml.md b/zh-cn/application-dev/reference/apis/js-apis-convertxml.md index 0e4e1a1c71610ceaca065c396e2f70fc0a7a74fe..30530aceb78375f3bcae9d8c3c0e858b9af366cb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-convertxml.md +++ b/zh-cn/application-dev/reference/apis/js-apis-convertxml.md @@ -39,7 +39,7 @@ convert(xml: string, options?: ConvertOptions) : Object - 示例: - ``` + ```js let xml = '' + '' + diff --git a/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md b/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md new file mode 100644 index 0000000000000000000000000000000000000000..cad850c9aff0bcbb7aef3803645caa47a489de65 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md @@ -0,0 +1,63 @@ +# FormExtensionContext + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +FormExtension的上下文环境,提供FormExtension具有的能力和接口,继承自ExtensionContext。 + +## FormExtensionContext.updateForm + +updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\): void + +主动更新卡片。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --------------- | ------------------------------------------------------------ | ---- | -------------------------------------- | + | formId | string | 是 | 请求更新的卡片ID。 | + | formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 卡片新的数据。 | + | callback | AsyncCallback\ | 是 | 回调函数,返回接口调用是否成功的结果。 | + +**示例:** + + ```js + let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + this.context.updateForm(formId, obj2, (data)=>{ + console.log('FormExtension context updateForm, data:' + data); + }); + ``` + +## FormExtensionContext.updateForm + +updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise\ + +更新卡片。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --------------- | ------------------------------------------------------------ | ---- | ------------------ | + | formId | string | 是 | 请求更新的卡片ID。 | + | formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 卡片新的数据。 | + +**返回值:** + + | 类型 | 说明 | + | -------------- | --------------------------------- | + | Promise\ | 返回一个Promise,包含接口的结果。 | + +**示例:** + + ``` + let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + this.context.updateForm(formId, obj2) + .then((data)=>{ + console.log('FormExtension context updateForm, data:' + data); + }).catch((error) => { + console.error('Operation updateForm failed. Cause: ' + error);}); + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-process.md b/zh-cn/application-dev/reference/apis/js-apis-process.md index 8cf388df7ac0a971829eb6d4a29e395c1883af3b..e4e429a80f5ab1215e7fe9f3308ff61f03ed9128 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-process.md +++ b/zh-cn/application-dev/reference/apis/js-apis-process.md @@ -60,7 +60,7 @@ wait(): Promise<number> **示例:** -``` +```js var child = process.runCmd('ls'); var result = child.wait(); result.then(val=>{ @@ -85,7 +85,7 @@ getOutput(): Promise<Uint8Array> **示例:** -``` +```js var child = process.runCmd('ls'); var result = child.wait(); child.getOutput.then(val=>{ @@ -110,7 +110,7 @@ getErrorOutput(): Promise<Uint8Array> **示例:** -``` +```js var child = process.runCmd('madir test.text'); var result = child.wait(); child.getErrorOutput.then(val=>{ @@ -129,7 +129,7 @@ close(): void **示例:** -``` +```js var child = process.runCmd('sleep 5; ls'); child.close(); ``` @@ -151,7 +151,7 @@ kill(signal: number | string): void **示例:** -``` +```js var child = process.runCmd('sleep 5; ls'); child.kill(9); ``` @@ -173,7 +173,7 @@ isIsolatedProcess(): boolean **示例:** -``` +```js var result = process.isIsolatedProcess(); ``` @@ -200,7 +200,7 @@ isAppUid(v: number): boolean **示例:** -``` +```js var result = process.isAppUid(688); ``` @@ -221,7 +221,7 @@ is64Bit(): boolean **示例:** -``` +```js var ressult = process.is64Bit(); ``` @@ -248,7 +248,7 @@ getUidForName(v: string): number **示例:** -``` +```js var pres = process.getUidForName("tool") ``` @@ -275,7 +275,7 @@ getThreadPriority(v: number): number **示例:** -``` +```js var tid = process.getTid(); var pres = process.getThreadPriority(tid); ``` @@ -297,7 +297,7 @@ getStartRealtime(): number **示例:** -``` +```js var realtime = process.getStartRealtime(); ``` @@ -317,7 +317,7 @@ getPastCpuTime(): number **示例:** -``` +```js var result = process.getPastCpuTime() ; ``` @@ -344,7 +344,7 @@ getSystemConfig(name: number): number **示例:** -``` +```js var _SC_ARG_MAX = 0 var pres = process.getSystemConfig(_SC_ARG_MAX) ``` @@ -372,7 +372,7 @@ getEnvironmentVar(name: string): string **示例:** -``` +```js var pres = process.getEnvironmentVar("PATH") ``` @@ -408,7 +408,7 @@ runCmd(command: string, options?: { timeout : number, killSignal : number | stri **示例:** -``` +```js var child = process.runCmd('ls', { maxBuffer : 2 }); var result = child.wait(); child.getOutput.then(val=>{ @@ -427,7 +427,7 @@ abort(): void **示例:** -``` +```js process.abort(); ``` @@ -455,7 +455,7 @@ on(type: string, listener: EventListener): void **示例:** -``` +```js process.on("data", (e)=>{ console.log("data callback"); }) @@ -484,7 +484,7 @@ off(type: string): boolean **示例:** -``` +```js process.on("data", (e)=>{ console.log("data callback"); }) @@ -510,7 +510,7 @@ exit(code: number): void **示例:** -``` +```js process.exit(0); ``` @@ -525,7 +525,7 @@ cwd(): string **示例:** -``` +```js var path = process.cwd(); ``` @@ -546,7 +546,7 @@ chdir(dir: string): void **示例:** -``` +```js process.chdir('/system'); ``` @@ -567,7 +567,7 @@ uptime(): number **示例:** -``` +```js var time = process.uptime(); ``` @@ -594,7 +594,8 @@ kill(signal: number, pid: number): boolean | boolean | 信号是否发送成功。 | **示例:** -``` + +```js var pres = process.pid var result = that.kill(pres, 28) ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md b/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md new file mode 100644 index 0000000000000000000000000000000000000000..4a0c2748f211e444f436c7821de63772305d1343 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md @@ -0,0 +1,223 @@ +# ServiceExtensionContext + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +ServiceExtension的上下文环境,提供ServiceExtension具有的能力和接口,继承自ExtensionContext。 + + +## startAbility + +startAbility(want: Want, callback: AsyncCallback<void>): void; + +启动Ability。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | Want类型参数,传入需要启动的ability的信息,如ability名称,包名等。 | + | callback | AsyncCallback<void> | 否 | 回调函数,返回接口调用是否成功的结果。 | + +**示例:** + + ```js + let want = { + "bundleName": "com.example.myapp", + "abilityName": "com.example.myapp.MyAbility" + }; + this.context.startAbility(want, (err) => { + console.log('startAbility result:' + JSON.stringfy(err)); + }); + ``` + + +## ServiceExtensionContext.startAbility + +startAbility(want: Want): Promise<void>; + +启动Ability。通过Promise返回结果。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | Want类型参数,传入需要启动的ability的信息,如ability名称,包名等。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包含接口的结果。 | + +**示例:** + + ```js + let want = { + "bundleName": "com.example.myapp", + "abilityName": "com.example.myapp.MyAbility" + }; + this.context.startAbility(want).then((data) => { + console.log('success:' + JSON.stringfy(data)); + }).catch((error) => { + console.log('failed:' + JSON.stringfy(error)); + }); + ``` + + +## ServiceExtensionContext.terminateSelf + +terminateSelf(callback: AsyncCallback<void>): void; + +停止Ability自身。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | 否 | 回调函数,返回接口调用是否成功的结果。 | + +**示例:** + + ```js + this.context.terminateSelf((err) => { + console.log('terminateSelf result:' + JSON.stringfy(err)); + }); + ``` + + +## ServiceExtensionContext.terminateSelf + +terminateSelf(): Promise<void>; + +停止自身。通过Promise返回结果。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包含接口的结果。 | + +**示例:** + + ```js + this.context.terminateSelf(want).then((data) => { + console.log('success:' + JSON.stringfy(data)); + }).catch((error) => { + console.log('failed:' + JSON.stringfy(error)); + }); + ``` + + +## ServiceExtensionContext.connectAbility + +connectAbility(want: Want, options: ConnectOptions): number; + +将一个Ability与服务类型的Ability绑定。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | Want类型参数,传入需要启动的ability的信息,如ability名称,包名等。 | + | options | [ConnectOptions](#connectoptions) | 是 | ConnectOptions类型的回调函数,返回服务连接成功、断开或连接失败后的信息。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | number | 返回一个number,后续根据这个number去断开连接。 | + +**示例:** + + ```js + let want = { + "bundleName": "com.example.myapp", + "abilityName": "com.example.myapp.MyAbility" + }; + let options = { + onConnect: function(elementName, proxy) {}, + onDisConnect: function(elementName) {}, + onFailed: function(code) {} + } + let connection = this.context.connectAbility(want,options); + ``` + + +## ServiceExtensionContext.disconnectAbility + +disconnectAbility(connection: number, callback:AsyncCallback<void>): void; + +将一个Ability与绑定的服务类型的Ability解绑。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | connection | number | 是 | 在connectAbility中返回的number。 | + | callback | AsyncCallback<void> | 否 | 回调函数,返回接口调用是否成功的结果。 | + +**示例:** + + ```js + this.context.disconnectAbility(connection, (err) => { // connection为connectAbility中的返回值 + console.log('terminateSelf result:' + JSON.stringfy(err)); + }); + ``` + + +## ServiceExtensionContext.disconnectAbility + +disconnectAbility(connection: number): Promise<void>; + +将一个Ability与绑定的服务类型的Ability解绑。通过Promise返回结果。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | connection | number | 是 | 在connectAbility中返回的number。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包含接口的结果。 | + +**示例:** + + ```js + this.context.disconnectAbility(connection).then((data) => { // connection为connectAbility中的返回值 + console.log('success:' + JSON.stringfy(data)); + }).catch((error) => { + console.log('failed:' + JSON.stringfy(error)); + }); + ``` + + +## ConnectOptions + +ConnectOptions数据结构。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core + +| 名称 | 说明 | +| -------- | -------- | +| onConnect(elementName:ElementName, remote:IRemoteObject) | Ability成功连接一个服务类型Ability的回调接口。 | +| onDisconnect(elementName:ElementName) | 对端服务发生异常或者被杀死回调该接口。 | +| onFailed(code: number) | 连接失败时回调该接口。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-settings.md b/zh-cn/application-dev/reference/apis/js-apis-settings.md index 20e07393953849127eaddf314ce2a7142028f825..80f832bab548df8fa5945458e8f0c20b94991a8c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-settings.md +++ b/zh-cn/application-dev/reference/apis/js-apis-settings.md @@ -9,7 +9,7 @@ ## 导入模块 -``` +```typescript import settings from '@ohos.settings'; ``` @@ -34,7 +34,7 @@ getUriSync(name: string): string | string | 数据项的URI。 | - 示例: - ``` + ```typescript // 获取数据项的URI let urivar = settings.getUriSync('settings.screen.brightness'); ``` @@ -61,7 +61,7 @@ getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: strin | string | 返回数据项的值。 | - 示例: - ``` + ```typescript import featureAbility from '@ohos.featureAbility'; //获取数据项亮度的值(该数据项在数据库中已存在) @@ -96,7 +96,7 @@ setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): | boolean | 返回设置数据项的值是否成功的结果。true表示设置成功,false则表示设置失败。 | - 示例: - ``` + ```typescript import featureAbility from '@ohos.featureAbility'; //更新数据项亮度的值(该数据项在数据库中已存在,故setValueSync方法将更新该数据项的值) diff --git a/zh-cn/application-dev/reference/apis/js-apis-uri.md b/zh-cn/application-dev/reference/apis/js-apis-uri.md index b23c9fc62cec17b5b0cbd9fc61a69c9ce3339f10..c15f3ae77155fc6d876e74fd5421c7b25cbab041 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-uri.md +++ b/zh-cn/application-dev/reference/apis/js-apis-uri.md @@ -46,11 +46,11 @@ constructor是URI的构造函数。 **示例:** -``` +```js var mm = 'http://username:password@host:8080/directory/file?foo=1&bar=2#fragment'; new uri.URI(mm); // Output 'http://username:password@host:8080/directory/file?foo=1&bar=2#fragment'; ``` -``` +```js new uri.URI('http://username:password@host:8080'); // Output 'http://username:password@host:8080'; ``` @@ -69,7 +69,7 @@ toString(): string **示例:** -``` +```js const url = new uri.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toString() ``` @@ -95,7 +95,7 @@ equals(other: URI): boolean **示例:** -``` +```js const uriInstance = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); const uriInstance1 = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da#fragment'); uriInstance.equals(uriInstance1); @@ -115,7 +115,7 @@ checkIsAbsolute(): boolean **示例:** -``` +```js const uriInstance = new uri.URI('http://username:password@www.qwer.com:8080?query=pppppp'); uriInstance.checkIsAbsolute(); ``` @@ -134,7 +134,7 @@ normalize(): URI | URI | 返回一个path被规范化后的URI对象。 | **示例:** -``` +```js const uriInstance = new uri.URI('http://username:password@www.qwer.com:8080/path/path1/../path2/./path3?query=pppppp'); let uriInstance1 = uriInstance.normalize(); uriInstance1.path; diff --git a/zh-cn/application-dev/reference/apis/js-apis-url.md b/zh-cn/application-dev/reference/apis/js-apis-url.md index 1c2c93f6e64079d70e4716be6286dcd70f25f22c..685e6ee2241ee3646516d27912dbba75455c7e58 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-url.md +++ b/zh-cn/application-dev/reference/apis/js-apis-url.md @@ -31,7 +31,7 @@ URLSearchParams的构造函数。 **示例:** -``` +```js var objectParams = new URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]); var objectParams1 = new URLSearchParams({"fod" : 1 , "bard" : 2}); var objectParams2 = new URLSearchParams('?fod=1&bard=2'); @@ -55,7 +55,7 @@ append(name: string, value: string): void **示例:** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.append('fod', 3); @@ -76,7 +76,7 @@ delete(name: string): void **示例:** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsobject = new URLSearchParams(urlObject.search.slice(1)); paramsobject.delete('fod'); @@ -103,7 +103,7 @@ getAll(name: string): string[] **示例:** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.append('fod', 3); // Add a second value for the fod parameter. @@ -125,7 +125,7 @@ entries(): IterableIterator<[string, string]> **示例:** -``` +```js var searchParamsObject = new URLSearchParams("keyName1=valueName1&keyName2=valueName2"); for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pairs console.log(pair[0]+ ', '+ pair[1]); @@ -156,7 +156,7 @@ forEach(callbackfn: (value: string, key: string, searchParams: this) => void, th **示例:** -``` +```js const myURLObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); myURLObject.searchParams.forEach((value, name, searchParams) => { console.log(name, value, myURLObject.searchParams === searchParams); @@ -185,7 +185,7 @@ get(name: string): string | null **示例:** -``` +```js var paramsOject = new URLSearchParams(document.location.search.substring(1)); var name = paramsOject.get("name"); // is the string "Jonathan" var age = parseInt(paramsOject.get("age"), 10); // is the number 18 @@ -213,7 +213,7 @@ has(name: string): boolean **示例:** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.has('bard') === true; @@ -235,7 +235,7 @@ set(name: string, value: string): void **示例:** -``` +```js let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); paramsObject.set('baz', 3); // Add a third parameter. @@ -251,7 +251,7 @@ sort(): void **示例:** -``` +```js var searchParamsObject = new URLSearchParams("c=3&a=9&b=4&d=2"); // Create a test URLSearchParams object searchParamsObject.sort(); // Sort the key/value pairs console.log(searchParamsObject.toString()); // Display the sorted query string // Output a=9&b=2&c=3&d=4 @@ -273,7 +273,7 @@ keys(): IterableIterator<string> **示例:** -``` +```js var searchParamsObject = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing for (var key of searchParamsObject .keys()) { // Output key-value pairs console.log(key); @@ -295,7 +295,7 @@ values(): IterableIterator<string> **示例:** -``` +```js var searchParams = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing for (var value of searchParams.values()) { console.log(value); @@ -318,7 +318,7 @@ for (var value of searchParams.values()) { **示例:** -``` +```js const paramsObject = new URLSearchParams('fod=bay&edg=bap'); for (const [name, value] of paramsObject) { console.log(name, value); @@ -341,7 +341,7 @@ toString(): string **示例:** -``` +```js let url = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let params = new URLSearchParams(url.search.slice(1)); params.append('fod', 3); @@ -386,7 +386,7 @@ URL的构造函数。 **示例:** -``` +```js var mm = 'http://username:password@host:8080'; var a = new URL("/", mm); // Output 'http://username:password@host:8080/'; var b = new URL(mm); // Output 'http://username:password@host:8080/'; @@ -416,7 +416,7 @@ toString(): string **示例:** -``` +```js const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toString() ``` @@ -436,7 +436,7 @@ toJSON(): string | string | 用于返回网址的字符串序列化。 | **示例:** -``` +```js const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toJSON() ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-util.md b/zh-cn/application-dev/reference/apis/js-apis-util.md index 4f160237ffa92af7655936bba888696dbc78778a..4cf333c4ac6890d61d2332e4f92f48ae0b8fd6c2 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-util.md +++ b/zh-cn/application-dev/reference/apis/js-apis-util.md @@ -23,18 +23,18 @@ printf(format: string, ...args: Object[]): string **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | format | string | 是 | 式样化字符串。 | - | ...args | Object[] | 否 | 待式样化数据。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| format | string | 是 | 式样化字符串。 | +| ...args | Object[] | 否 | 待式样化数据。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | string | 按特定格式式样化后的字符串。 | +| 类型 | 说明 | +| -------- | -------- | +| string | 按特定格式式样化后的字符串。 | **示例:** - ``` + ```js var res = util.printf("%s", "hello world!"); console.log(res); ``` @@ -49,17 +49,17 @@ getErrorString(errno: number): string **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | errno | number | 是 | 系统发生错误产生的错误码。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| errno | number | 是 | 系统发生错误产生的错误码。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | string | 错误码对应的详细信息。 | +| 类型 | 说明 | +| -------- | -------- | +| string | 错误码对应的详细信息。 | **示例:** - ``` + ```js var errnum = 10; // 10:a system error number var result = util.getErrorString(errnum); console.log("result = " + result); @@ -76,17 +76,17 @@ callbackWrapper(original: Function): (err: Object, value: Object )=>void **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | original | Function | 是 | 异步函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| original | Function | 是 | 异步函数。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Function | 返回一个第一个参数是拒绝原因(如果 Promise 已解决,则为 null),第二个参数是已解决的回调函数。 | +| 类型 | 说明 | +| -------- | -------- | +| Function | 返回一个第一个参数是拒绝原因(如果 Promise 已解决,则为 null),第二个参数是已解决的回调函数。 | **示例:** - ``` + ```js async function promiseFn() { return Promise.reject('value'); } @@ -107,17 +107,17 @@ promiseWrapper(original: (err: Object, value: Object) => void): Object **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | original | Function | 是 | 异步函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| original | Function | 是 | 异步函数。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Function | 采用遵循常见的错误优先的回调风格的函数(也就是将 (err, value) => ... 回调作为最后一个参数),并返回一个返回 promise 的版本。 | +| 类型 | 说明 | +| -------- | -------- | +| Function | 采用遵循常见的错误优先的回调风格的函数(也就是将 (err, value) => ... 回调作为最后一个参数),并返回一个返回 promise 的版本。 | **示例:** - ``` + ```js function aysnFun(str1, str2, callback) { if (typeof str1 === 'string' && typeof str2 === 'string') { callback(null, str1 + str2); @@ -154,20 +154,20 @@ TextDecoder的构造函数。 **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | encoding | string | 否 | 编码格式。 | - | options | Object | 否 | 编码相关选项参数,存在两个属性fatal和ignoreBOM。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| encoding | string | 否 | 编码格式。 | +| options | Object | 否 | 编码相关选项参数,存在两个属性fatal和ignoreBOM。 | **表1** options - | 名称 | 参数类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fatal | boolean | 否 | 是否显示致命错误。 | - | ignoreBOM | boolean | 否 | 是否忽略BOM标记。 | +| 名称 | 参数类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| fatal | boolean | 否 | 是否显示致命错误。 | +| ignoreBOM | boolean | 否 | 是否忽略BOM标记。 | **示例:** - ``` + ```js var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); ``` @@ -181,24 +181,24 @@ decode(input: Uint8Array, options?: { stream?: false }): string **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | input | Unit8Array | 是 | 符合格式需要解码的数组。 | - | options | Object | 否 | 解码相关选项参数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| input | Unit8Array | 是 | 符合格式需要解码的数组。 | +| options | Object | 否 | 解码相关选项参数。 | **表2** options - | 名称 | 参数类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | stream | boolean | 否 | 在随后的decode()调用中是否跟随附加数据块。如果以块的形式处理数据,则设置为true;如果处理最后的数据块或数据未分块,则设置为false。默认为false。 | +| 名称 | 参数类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| stream | boolean | 否 | 在随后的decode()调用中是否跟随附加数据块。如果以块的形式处理数据,则设置为true;如果处理最后的数据块或数据未分块,则设置为false。默认为false。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | string | 解码后的数据。 | +| 类型 | 说明 | +| -------- | -------- | +| string | 解码后的数据。 | **示例:** - ``` + ```js var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); var result = new Uint8Array(6); result[0] = 0xEF; @@ -236,7 +236,7 @@ TextEncoder的构造函数。 **系统能力:** SystemCapability.Utils.Lang **示例:** - ``` + ```js var textEncoder = new util.TextEncoder(); ``` @@ -250,17 +250,17 @@ encode(input?: string): Uint8Array **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | input | string | 是 | 需要编码的字符串。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| input | string | 是 | 需要编码的字符串。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Uint8Array | 返回编码后的文本。 | +| 类型 | 说明 | +| -------- | -------- | +| Uint8Array | 返回编码后的文本。 | **示例:** - ``` + ```js var textEncoder = new util.TextEncoder(); var result = new Uint8Array(buffer); result = textEncoder.encode("\uD800¥¥"); @@ -276,18 +276,18 @@ encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number } **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | input | string | 是 | 需要编码的字符串。 | - | dest | Uint8Array | 是 | Uint8Array对象实例,用于将生成的UTF-8编码文本放入其中。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| input | string | 是 | 需要编码的字符串。 | +| dest | Uint8Array | 是 | Uint8Array对象实例,用于将生成的UTF-8编码文本放入其中。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Uint8Array | 返回编码后的文本。 | +| 类型 | 说明 | +| -------- | -------- | +| Uint8Array | 返回编码后的文本。 | **示例:** - ``` + ```js var that = new util.TextEncoder(); var buffer = new ArrayBuffer(4); this.dest = new Uint8Array(buffer); @@ -306,13 +306,13 @@ RationalNumber的构造函数。 **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | numerator | number | 是 | 分子,整数类型。 | - | denominator | number | 是 | 分母,整数类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| numerator | number | 是 | 分子,整数类型。 | +| denominator | number | 是 | 分母,整数类型。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); ``` @@ -326,17 +326,17 @@ static createRationalFromString​(rationalString: string): RationalNumber​ **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | rationalString | string | 是 | 字符串格式。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| rationalString | string | 是 | 字符串格式。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | object | 返回有理数类的对象。 | +| 类型 | 说明 | +| -------- | -------- | +| object | 返回有理数类的对象。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var rational = rationalNumer.creatRationalFromString("3/4"); ``` @@ -351,17 +351,17 @@ compareTo​(another: RationalNumber): number​ **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | another | RationalNumber | 是 | 其他的有理数对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| another | RationalNumber | 是 | 其他的有理数对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 如果两个对象相等,则返回0;如果给定对象小于当前对象,则返回1;如果给定对象大于当前对象,则返回-1。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 如果两个对象相等,则返回0;如果给定对象小于当前对象,则返回1;如果给定对象大于当前对象,则返回-1。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var rational = rationalNumer.creatRationalFromString("3/4"); var result = rationalNumber.compareTo(rational); @@ -377,12 +377,12 @@ valueOf(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回整数或者浮点数的值。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回整数或者浮点数的值。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.valueOf(); ``` @@ -397,17 +397,17 @@ equals​(obj: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | object | Object | 是 | 其他类型对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| object | Object | 是 | 其他类型对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果给定对象与当前对象相同,则返回true;否则返回false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果给定对象与当前对象相同,则返回true;否则返回false。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var rational = rationalNumer.creatRationalFromString("3/4"); var result = rationalNumber.equals(rational); @@ -423,18 +423,18 @@ static getCommonDivisor​(number1: number,number2: number): number **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | number1 | number | 是 | 整数类型。 | - | number2 | number | 是 | 整数类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| number1 | number | 是 | 整数类型。 | +| number2 | number | 是 | 整数类型。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回两个给定数字的最大公约数。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回两个给定数字的最大公约数。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.getCommonDivisor(4,6); ``` @@ -450,12 +450,12 @@ getNumerator​(): number **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回RationalNumber对象的分子的值。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回RationalNumber对象的分子的值。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.getNumerator(); ``` @@ -470,12 +470,12 @@ getDenominator​(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回RationalNumber对象的分母的值。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回RationalNumber对象的分母的值。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.getDenominator(); ``` @@ -490,12 +490,12 @@ isZero​():boolean **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果当前对象表示的值为0,则返回true;否则返回false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果当前对象表示的值为0,则返回true;否则返回false。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.isZero(); ``` @@ -510,12 +510,12 @@ isNaN​(): boolean **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果分母和分子都为0,则返回true;否则返回false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果分母和分子都为0,则返回true;否则返回false。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.isNaN(); ``` @@ -530,12 +530,12 @@ isFinite​():boolean **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果分母不为0,则返回true;否则返回false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果分母不为0,则返回true;否则返回false。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.isFinite(); ``` @@ -550,12 +550,12 @@ toString​(): string **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | string | 返回Numerator/Denominator格式的字符串,例如3/5,如果当前对象的分子和分母都为0,则返回NaN。 | +| 类型 | 说明 | +| -------- | -------- | +| string | 返回Numerator/Denominator格式的字符串,例如3/5,如果当前对象的分子和分母都为0,则返回NaN。 | **示例:** - ``` + ```js var rationalNumber = new util.RationalNumber(1,2); var result = rationalNumber.toString(); ``` @@ -571,7 +571,7 @@ toString​(): string | length | number | 是 | 否 | 当前缓冲区中值的总数。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.put(1,8); @@ -588,12 +588,12 @@ constructor(capacity?: number) **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | capacity | number | 否 | 指示要为缓冲区自定义的容量。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| capacity | number | 否 | 指示要为缓冲区自定义的容量。 | **示例:** - ``` + ```js var lrubuffer= new util.LruBuffer(); ``` @@ -607,12 +607,12 @@ updateCapacity(newCapacity: number): void **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | newCapacity | number | 是 | 指示要为缓冲区自定义的容量。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| newCapacity | number | 是 | 指示要为缓冲区自定义的容量。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); var result = pro.updateCapacity(100); ``` @@ -627,12 +627,12 @@ toString(): string **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | string | 返回对象的字符串表示形式。 | +| 类型 | 说明 | +| -------- | -------- | +| string | 返回对象的字符串表示形式。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.get(2); @@ -650,12 +650,12 @@ getCapacity(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回当前缓冲区的容量。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回当前缓冲区的容量。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); var result = pro.getCapacity(); ``` @@ -670,7 +670,7 @@ clear(): void **系统能力:** SystemCapability.Utils.Lang **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.size(); @@ -687,12 +687,12 @@ getCreateCount(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回createDefault()返回值的次数。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回createDefault()返回值的次数。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(1,8); var result = pro.getCreateCount(); @@ -708,12 +708,12 @@ getMissCount(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回查询值不匹配的次数。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回查询值不匹配的次数。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.get(2); @@ -730,12 +730,12 @@ getRemovalCount(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回从缓冲区中驱逐的次数。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回从缓冲区中驱逐的次数。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.updateCapacity(2); @@ -753,12 +753,12 @@ getMatchCount(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回查询值匹配成功的次数。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回查询值匹配成功的次数。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.get(2); @@ -775,12 +775,12 @@ getPutCount(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回将值添加到缓冲区的次数。 | +| 类型 | 说明 | +| -------- | -------- | +| number | 返回将值添加到缓冲区的次数。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.getPutCount(); @@ -796,12 +796,12 @@ isEmpty(): boolean **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果当前缓冲区不包含任何值,则返回true。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果当前缓冲区不包含任何值,则返回true。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.isEmpty(); @@ -817,17 +817,17 @@ get(key: K): V | undefined **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | K | 是 | 要查询的键。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | K | 是 | 要查询的键。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | V \| undefind | 如果指定的键存在于缓冲区中,则返回与键关联的值;否则返回undefined。 | +| 类型 | 说明 | +| -------- | -------- | +| V \| undefind | 如果指定的键存在于缓冲区中,则返回与键关联的值;否则返回undefined。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.get(2); @@ -843,18 +843,18 @@ put(key: K,value: V): V **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | K | 是 | 要添加的密钥。 | - | value | V | 是 | 指示与要添加的键关联的值。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | K | 是 | 要添加的密钥。 | +| value | V | 是 | 指示与要添加的键关联的值。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | V | 返回与添加的键关联的值;如果要添加的键已经存在,则返回原始值,如果键或值为空,则抛出此异常。 | +| 类型 | 说明 | +| -------- | -------- | +| V | 返回与添加的键关联的值;如果要添加的键已经存在,则返回原始值,如果键或值为空,则抛出此异常。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); var result = pro.put(2,10); ``` @@ -869,12 +869,12 @@ values(): V[] **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | V [] | 按从最近访问到最近最少访问的顺序返回当前缓冲区中所有值的列表。 | +| 类型 | 说明 | +| -------- | -------- | +| V [] | 按从最近访问到最近最少访问的顺序返回当前缓冲区中所有值的列表。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); pro.put(2,"anhu"); @@ -892,12 +892,12 @@ keys(): K[] **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | K [] | 按升序返回当前缓冲区中所有键的列表,从最近访问到最近最少访问。 | +| 类型 | 说明 | +| -------- | -------- | +| K [] | 按升序返回当前缓冲区中所有键的列表,从最近访问到最近最少访问。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.keys(); @@ -913,17 +913,17 @@ remove(key: K): V | undefined **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | K | 是 | 要删除的密钥。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | K | 是 | 要删除的密钥。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | V \| undefind | 返回一个包含已删除键值对的Optional对象;如果key不存在,则返回一个空的Optional对象,如果key为null,则抛出异常。 | +| 类型 | 说明 | +| -------- | -------- | +| V \| undefind | 返回一个包含已删除键值对的Optional对象;如果key不存在,则返回一个空的Optional对象,如果key为null,则抛出异常。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.remove(20); @@ -939,15 +939,15 @@ afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | isEvict | boolean | 否 | 因容量不足而调用该方法时,参数值为true,其他情况为false。 | - | key | K | 是 | 表示删除的键。 | - | value | V | 是 | 表示删除的值。 | - | newValue | V | 否 | 如果已调用put方法并且要添加的键已经存在,则参数值是关联的新值。其他情况下参数值为空。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| isEvict | boolean | 否 | 因容量不足而调用该方法时,参数值为true,其他情况为false。 | +| key | K | 是 | 表示删除的键。 | +| value | V | 是 | 表示删除的值。 | +| newValue | V | 否 | 如果已调用put方法并且要添加的键已经存在,则参数值是关联的新值。其他情况下参数值为空。 | **示例:** - ``` + ```js var arr = []; class ChildLruBuffer extends util.LruBuffer { @@ -984,17 +984,17 @@ contains(key: K): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | K | 是 | 表示要检查的键。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | K | 是 | 表示要检查的键。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果缓冲区包含指定的键,则返回 true。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果缓冲区包含指定的键,则返回 true。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.contains(20); @@ -1010,17 +1010,17 @@ createDefault(key: K): V **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | K | 是 | 表示丢失的键。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | K | 是 | 表示丢失的键。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | V | 返回与键关联的值。 | +| 类型 | 说明 | +| -------- | -------- | +| V | 返回与键关联的值。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); var result = pro.createDefault(50); ``` @@ -1035,12 +1035,12 @@ entries(): IterableIterator<[K,V]> **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [K, V] | 返回一个可迭代数组。 | +| 类型 | 说明 | +| -------- | -------- | +| [K, V] | 返回一个可迭代数组。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro.entries(); @@ -1056,12 +1056,12 @@ entries(): IterableIterator<[K,V]> **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [K, V] | 返回一个键值对形式的二维数组。 | +| 类型 | 说明 | +| -------- | -------- | +| [K, V] | 返回一个键值对形式的二维数组。 | **示例:** - ``` + ```js var pro = new util.LruBuffer(); pro.put(2,10); var result = pro[symbol.iterator](); @@ -1076,7 +1076,7 @@ entries(): IterableIterator<[K,V]> 用于表示范围中的值的类型。该类型的值,类型可以为ScopeComparable或number。 ScopeComparable类型的值需要实现compareTo方法,确保传入的数据具有可比性。 -``` +```js interface ScopeComparable{ compareTo(other: ScopeComparable): boolean; } @@ -1088,7 +1088,7 @@ type ScopeType = ScopeComparable | number; 示例: -``` +```js class Temperature{ constructor(value){ this._temp = value; @@ -1115,13 +1115,13 @@ constructor(lowerObj: ScopeType, upperObj: ScopeType) **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | lowerObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的下限。 | - | upperObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的上限。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的下限。 | +| upperObj | [ScopeType](#scopetype8) | 是 | 指定作用域实例的上限。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1137,12 +1137,12 @@ toString(): string **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | string | 返回包含当前范围对象的字符串表示形式。 | +| 类型 | 说明 | +| -------- | -------- | +| string | 返回包含当前范围对象的字符串表示形式。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1159,17 +1159,17 @@ intersect(range: Scope): Scope **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | 是 | 传入一个给定范围。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | 是 | 传入一个给定范围。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [Scope](#scope8) | 返回给定范围和当前范围的交集。 | +| 类型 | 说明 | +| -------- | -------- | +| [Scope](#scope8) | 返回给定范围和当前范围的交集。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1189,18 +1189,18 @@ intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 | - | upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 | +| upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [Scope](#scope8) | 返回当前范围与给定下限和上限范围的交集。 | +| 类型 | 说明 | +| -------- | -------- | +| [Scope](#scope8) | 返回当前范围与给定下限和上限范围的交集。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1220,12 +1220,12 @@ getUpper(): ScopeType **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [ScopeType](#scopetype8) | 返回当前范围的上限值。 | +| 类型 | 说明 | +| -------- | -------- | +| [ScopeType](#scopetype8) | 返回当前范围的上限值。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1242,12 +1242,12 @@ getLower(): ScopeType **系统能力:** SystemCapability.Utils.Lang **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [ScopeType](#scopetype8) | 返回当前范围的下限值。 | +| 类型 | 说明 | +| -------- | -------- | +| [ScopeType](#scopetype8) | 返回当前范围的下限值。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1264,18 +1264,19 @@ expand(lowerObj: ScopeType,upperObj: ScopeType): Scope **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 | - | upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | 是 | 给定范围的下限。 | +| upperObj | [ScopeType](#scopetype8) | 是 | 给定范围的上限。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [Scope](#scope8) | 返回当前范围和给定下限和上限的并集。 | +| 类型 | 说明 | +| -------- | -------- | +| [Scope](#scope8) | 返回当前范围和给定下限和上限的并集。 | **示例:** - ``` + + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1294,17 +1295,17 @@ expand(range: Scope): Scope **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | 是 | 传入一个给定范围。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | 是 | 传入一个给定范围。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [Scope](#scope8) | 返回包括当前范围和给定范围的并集。 | +| 类型 | 说明 | +| -------- | -------- | +| [Scope](#scope8) | 返回包括当前范围和给定范围的并集。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1324,17 +1325,17 @@ expand(value: ScopeType): Scope **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [Scope](#scope8) | 返回包括当前范围和给定值的并集。 | +| 类型 | 说明 | +| -------- | -------- | +| [Scope](#scope8) | 返回包括当前范围和给定值的并集。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1352,17 +1353,17 @@ contains(value: ScopeType): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | 是 | 传入一个给定值。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果给定值包含在当前范围内返回true,否则返回false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果给定值包含在当前范围内返回true,否则返回false。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1380,17 +1381,17 @@ contains(range: Scope): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | 是 | 传入一个给定范围。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | 是 | 传入一个给定范围。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果给定范围包含在当前范围内返回true,否则返回false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果给定范围包含在当前范围内返回true,否则返回false。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var range = new util.Scope(tempLower, tempUpper); @@ -1410,17 +1411,17 @@ clamp(value: ScopeType): ScopeType **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | 是 | 传入的给定值。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | 是 | 传入的给定值。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [ScopeType](#scopetype8) | 如果传入的value小于下限,则返回lowerObj;如果大于上限值则返回upperObj;如果在当前范围内,则返回value。 | +| 类型 | 说明 | +| -------- | -------- | +| [ScopeType](#scopetype8) | 如果传入的value小于下限,则返回lowerObj;如果大于上限值则返回upperObj;如果在当前范围内,则返回value。 | **示例:** - ``` + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); var tempMiDF = new Temperature(35); @@ -1441,7 +1442,7 @@ Base64的构造函数。 **系统能力:** SystemCapability.Utils.Lang **示例:** - ``` + ```js var base64 = new util.Base64(); ``` @@ -1455,17 +1456,17 @@ encodeSync(src: Uint8Array): Uint8Array **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | 是 | 编码输入Uint8数组。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| src | Uint8Array | 是 | 编码输入Uint8数组。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Uint8Array | 返回编码后新分配的Uint8数组。 | +| 类型 | 说明 | +| -------- | -------- | +| Uint8Array | 返回编码后新分配的Uint8数组。 | **示例:** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); var result = that.encodeSync(array); @@ -1481,17 +1482,17 @@ encodeToStringSync(src: Uint8Array): string **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | 是 | 编码输入Uint8数组。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| src | Uint8Array | 是 | 编码输入Uint8数组。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | string | 返回编码后的字符串。 | +| 类型 | 说明 | +| -------- | -------- | +| string | 返回编码后的字符串。 | **示例:** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); var result = that.encodeToStringSync(array); @@ -1507,17 +1508,17 @@ decodeSync(src: Uint8Array | string): Uint8Array **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | src | Uint8Array \| string | 是 | 解码输入Uint8数组或者字符串。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| src | Uint8Array \| string | 是 | 解码输入Uint8数组或者字符串。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Uint8Array | 返回解码后新分配的Uint8数组。 | +| 类型 | 说明 | +| -------- | -------- | +| Uint8Array | 返回解码后新分配的Uint8数组。 | **示例:** - ``` + ```js var that = new util.Base64(); var buff = 'czEz'; var result = that.decodeSync(buff); @@ -1533,17 +1534,17 @@ encode(src: Uint8Array): Promise<Uint8Array> **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | 是 | 异步编码输入Uint8数组。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| src | Uint8Array | 是 | 异步编码输入Uint8数组。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<Uint8Array> | 返回异步编码后新分配的Uint8数组。 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<Uint8Array> | 返回异步编码后新分配的Uint8数组。 | **示例:** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); var rarray = new Uint8Array([99,122,69,122]); @@ -1564,17 +1565,17 @@ encodeToString(src: Uint8Array): Promise<string> **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | 是 | 异步编码输入Uint8数组。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| src | Uint8Array | 是 | 异步编码输入Uint8数组。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<string> | 返回异步编码后的字符串。 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<string> | 返回异步编码后的字符串。 | **示例:** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([115,49,51]); that.encodeToString(array).then(val=>{ @@ -1592,17 +1593,17 @@ decode(src: Uint8Array | string): Promise<Uint8Array> **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | src | Uint8Array \| string | 是 | 异步解码输入Uint8数组或者字符串。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| src | Uint8Array \| string | 是 | 异步解码输入Uint8数组或者字符串。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<Uint8Array> | 返回异步解码后新分配的Uint8数组。 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<Uint8Array> | 返回异步解码后新分配的Uint8数组。 | **示例:** - ``` + ```js var that = new util.Base64(); var array = new Uint8Array([99,122,69,122]); var rarray = new Uint8Array([115,49,51]); @@ -1614,7 +1615,7 @@ decode(src: Uint8Array | string): Promise<Uint8Array> ``` -## Types8+ +## types8+ ### constructor8+ @@ -1626,8 +1627,8 @@ Types的构造函数。 **系统能力:** SystemCapability.Utils.Lang **示例:** - ``` - var type = new util.Types(); + ```js + var type = new util.types(); ``` @@ -1640,18 +1641,18 @@ isAnyArrayBuffer(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是ArrayBuffer类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是ArrayBuffer类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isAnyArrayBuffer(new ArrayBuffer([])); ``` @@ -1667,18 +1668,18 @@ ArrayBufferView辅助类型包括:Int8Array、Int16Array、Int32Array、Uint8A **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的ArrayBufferView辅助类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的ArrayBufferView辅助类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isArrayBufferView(new Int8Array([])); ``` @@ -1692,18 +1693,18 @@ isArgumentsObject(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的arguments类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的arguments类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); function foo() { var result = that.isArgumentsObject(arguments); } @@ -1720,18 +1721,18 @@ isArrayBuffer(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的ArrayBuffer类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的ArrayBuffer类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isArrayBuffer(new ArrayBuffer([])); ``` @@ -1745,18 +1746,18 @@ isAsyncFunction(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的异步函数类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的异步函数类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isAsyncFunction(async function foo() {}); ``` @@ -1770,18 +1771,18 @@ isBooleanObject(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Boolean对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Boolean对象类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isBooleanObject(new Boolean(true)); ``` @@ -1795,18 +1796,18 @@ isBoxedPrimitive(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Boolean或Number或String或Symbol对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Boolean或Number或String或Symbol对象类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isBoxedPrimitive(new Boolean(false)); ``` @@ -1820,18 +1821,18 @@ isDataView(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的DataView对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的DataView对象类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); const ab = new ArrayBuffer(20); var result = that.isDataView(new DataView(ab)); ``` @@ -1846,18 +1847,18 @@ isDate(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Date对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Date对象类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isDate(new Date()); ``` @@ -1871,18 +1872,18 @@ isExternal(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含native External类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含native External类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); const data = util.createExternalType(); var result = that.isExternal(data); ``` @@ -1897,18 +1898,18 @@ isFloat32Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Float32Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Float32Array数组类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isFloat32Array(new Float32Array()); ``` @@ -1922,18 +1923,18 @@ isFloat64Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Float64Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Float64Array数组类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isFloat64Array(new Float64Array()); ``` @@ -1947,18 +1948,18 @@ isGeneratorFunction(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的generator函数类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的generator函数类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isGeneratorFunction(function* foo() {}); ``` @@ -1972,18 +1973,18 @@ isGeneratorObject(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的generator对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的generator对象类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); function* foo() {} const generator = foo(); var result = that.isGeneratorObject(generator); @@ -1999,18 +2000,18 @@ isInt8Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Int8Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Int8Array数组类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isInt8Array(new Int8Array([])); ``` @@ -2024,18 +2025,18 @@ isInt16Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Int16Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Int16Array数组类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isInt16Array(new Int16Array([])); ``` @@ -2049,18 +2050,18 @@ isInt32Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Int32Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Int32Array数组类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isInt32Array(new Int32Array([])); ``` @@ -2074,18 +2075,18 @@ isMap(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Map类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Map类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isMap(new Map()); ``` @@ -2099,18 +2100,18 @@ isMapIterator(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Map的Iterator类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Map的Iterator类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); const map = new Map(); var result = that.isMapIterator(map.keys()); ``` @@ -2125,18 +2126,18 @@ isNativeError(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Error类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Error类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isNativeError(new TypeError()); ``` @@ -2150,18 +2151,18 @@ isNumberObject(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Number对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Number对象类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isNumberObject(new Number(0)); ``` @@ -2175,18 +2176,18 @@ isPromise(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Promise类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Promise类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isPromise(Promise.resolve(1)); ``` @@ -2200,18 +2201,18 @@ isProxy(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Proxy类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Proxy类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); const target = {}; const proxy = new Proxy(target, {}); var result = that.isProxy(proxy); @@ -2227,18 +2228,18 @@ isRegExp(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的RegExp类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的RegExp类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isRegExp(new RegExp('abc')); ``` @@ -2252,18 +2253,18 @@ isSet(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Set类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Set类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isSet(new Set()); ``` @@ -2277,18 +2278,18 @@ isSetIterator(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Set的Iterator类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Set的Iterator类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); const set = new Set(); var result = that.isSetIterator(set.keys()); ``` @@ -2303,18 +2304,18 @@ isStringObject(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的String对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的String对象类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isStringObject(new String('foo')); ``` @@ -2328,18 +2329,18 @@ isSymbolObject(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Symbol对象类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Symbol对象类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); const symbols = Symbol('foo'); var result = that.isSymbolObject(Object(symbols)); ``` @@ -2356,18 +2357,18 @@ TypedArray类型的辅助类型,包括Int8Array、Int16Array、Int32Array、Ui **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的TypedArray包含的类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的TypedArray包含的类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isTypedArray(new Float64Array([])); ``` @@ -2381,18 +2382,18 @@ isUint8Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Uint8Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Uint8Array数组类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isUint8Array(new Uint8Array([])); ``` @@ -2406,18 +2407,18 @@ isUint8ClampedArray(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Uint8ClampedArray数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Uint8ClampedArray数组类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isUint8ClampedArray(new Uint8ClampedArray([])); ``` @@ -2431,18 +2432,18 @@ isUint16Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Uint16Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Uint16Array数组类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isUint16Array(new Uint16Array([])); ``` @@ -2456,18 +2457,18 @@ isUint32Array(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的Uint32Array数组类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的Uint32Array数组类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isUint32Array(new Uint32Array([])); ``` @@ -2481,18 +2482,18 @@ isWeakMap(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的WeakMap类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的WeakMap类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isWeakMap(new WeakMap()); ``` @@ -2506,17 +2507,17 @@ isWeakSet(value: Object): boolean **系统能力:** SystemCapability.Utils.Lang **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | Object | 是 | 待检测对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | Object | 是 | 待检测对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 判断的结果,如果是内置包含的WeakSet类型为true,反之为false。 | +| 类型 | 说明 | +| -------- | -------- | +| boolean | 判断的结果,如果是内置包含的WeakSet类型为true,反之为false。 | **示例:** - ``` - var that = new util.Types(); + ```js + var that = new util.types(); var result = that.isWeakSet(new WeakSet()); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-window.md b/zh-cn/application-dev/reference/apis/js-apis-window.md index 2ebdfbce75c359c12cccd18543f8447a1634391b..047d75eb83c7769c53c78b1130c64b43710efbbe 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -235,18 +235,20 @@ create(id: string, type: WindowType): Promise<Window> create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Window>): void -当Context为[ServiceExtAbilityContext](js-apis-serviceExtAbilityContext.md)时,创建系统窗口,使用callback方式作为异步方法。 +创建子窗口,使用callback方式作为异步方法,其中Context详见[Context](js-apis-Context.md)。 + +从API version 9开始,当Context为[ServiceExtAbilityContext](js-apis-serviceExtAbilityContext.md)时,创建系统窗口,使用callback方式作为异步方法。 **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------------------------------- | ---- | ---------------------- | - | ctx | [Context](js-apis-serviceExtAbilityContext.md) | 是 | 当前应用上下文信息。 | - | id | string | 是 | 窗口id。 | - | type | [WindowType](#windowtype) | 是 | 窗口类型。 | - | callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前窗口对象。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | + | ctx | Context | 是 | 当前应用上下文信息。
API version 8的Context定义见[Context](js-apis-Context.md)。
API version 9的Context定义见[Context](js-apis-serviceExtAbilityContext.md)。 | + | id | string | 是 | 窗口id。 | + | type | [WindowType](#windowtype) | 是 | 窗口类型。 | + | callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前窗口对象。 | - 示例 @@ -267,17 +269,19 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Wi create(ctx: Context, id: string, type: WindowType): Promise<Window> -当Context为[ServiceExtAbilityContext](js-apis-serviceExtAbilityContext.md)时,创建系统窗口,使用Promise方式作为异步方法。 +创建子窗口,使用Promise方式作为异步方法,其中Context详见[Context](js-apis-Context.md)。 + +从API version 9开始,当Context为[ServiceExtAbilityContext](js-apis-serviceExtAbilityContext.md)时,创建系统窗口,使用Promise方式作为异步方法。 **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ---------------------------------------------- | ---- | -------------------- | - | ctx | [Context](js-apis-serviceExtAbilityContext.md) | 是 | 当前应用上下文信息。 | - | id | string | 是 | 窗口id。 | - | type | [WindowType](#windowtype) | 是 | 窗口类型。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------------------------- | ---- | ------------------------------------------------------------ | + | ctx | Context | 是 | 当前应用上下文信息。
API version 8的Context定义见[Context](js-apis-Context.md)。
API version 9的Context定义见[Context](js-apis-serviceExtAbilityContext.md)。 | + | id | string | 是 | 窗口id。 | + | type | [WindowType](#windowtype) | 是 | 窗口类型。 | - 返回值 @@ -427,7 +431,7 @@ getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | - | ctx | Context | 是 | 当前应用上下文信息。API 8的Context定义见[Context](js-apis-Context.md)。API 9的Context定义见[Context](js-apis-ability-context.md)。 | + | ctx | Context | 是 | 当前应用上下文信息。
API version 8的Context定义见[Context](js-apis-Context.md)。
API version 9的Context定义见[Context](js-apis-ability-context.md)。 | | callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前应用内最后显示的窗口对象。 | - 示例 @@ -456,7 +460,7 @@ getTopWindow(ctx: Context): Promise<Window> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------- | ---- | ------------------------------------------------------------ | - | ctx | Context | 是 | 当前应用上下文信息。API8的Context定义见[Context](js-apis-Context.md)。API 9的Context定义见[Context](js-apis-ability-context.md)。 | + | ctx | Context | 是 | 当前应用上下文信息。
API version 8的Context定义见[Context](js-apis-Context.md)。
API version 9的Context定义见[Context](js-apis-ability-context.md)。 | - 返回值 diff --git a/zh-cn/application-dev/reference/apis/js-apis-xml.md b/zh-cn/application-dev/reference/apis/js-apis-xml.md index b78a86e5703cf9afef70a14f3276580d7e9472c5..0ec2c2a72d4626959720529deb9256bdca728ca1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-xml.md +++ b/zh-cn/application-dev/reference/apis/js-apis-xml.md @@ -25,14 +25,14 @@ XmlSerializer的构造函数。 **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------- | ---- | ----------------------------------- | -| buffer | ArrayBuffer \| DataView | 是 | 用于接收写入xml信息的ArrayBuffer或DataView内存。 | -| encoding | string | 否 | 编码格式。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| buffer | ArrayBuffer \| DataView | 是 | 用于接收写入xml信息的ArrayBuffer或DataView内存。 | +| encoding | string | 否 | 编码格式。 | **示例:** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var bufView = new DataView(arrayBuffer); var thatSer = new xml.XmlSerializer(bufView); @@ -47,14 +47,14 @@ setAttributes(name: string, value: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----- | ------ | ---- | ---------- | -| name | string | 是 | 属性的key值。 | -| value | string | 是 | 属性的value值。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| name | string | 是 | 属性的key值。 | +| value | string | 是 | 属性的value值。 | **示例:** -``` +```js var thatSer = new xml.XmlSerializer(bufView); thatSer.setAttributes("importance", "high"); ``` @@ -68,14 +68,14 @@ addEmptyElement(name: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | --------- | -| name | string | 是 | 该空元素的元素名。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| name | string | 是 | 该空元素的元素名。 | **示例:** -``` - var thatSer = new xml.XmlSerializer(bufView); +```js +var thatSer = new xml.XmlSerializer(bufView); thatSer.addEmptyElement("b"); // => ``` @@ -88,7 +88,7 @@ setDeclaration(): void **示例:** -``` +```js var thatSer = new xml.XmlSerializer(bufView); thatSer.setDeclaration() // => ; ``` @@ -102,13 +102,13 @@ startElement(name: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | --------- | -| name | string | 是 | 当前元素的元素名。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| name | string | 是 | 当前元素的元素名。 | **示例:** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.startElement("notel"); @@ -124,7 +124,7 @@ endElement(): void **示例:** -``` +```js var thatSer = new xml.XmlSerializer(bufView); thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); thatSer.startElement("table"); @@ -142,14 +142,14 @@ setNamespace(prefix: string, namespace: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------- | ------ | ---- | --------------- | -| prefix | string | 是 | 当前元素及其子元素的前缀。 | -| namespace | string | 是 | 当前元素及其子元素的命名空间。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| prefix | string | 是 | 当前元素及其子元素的前缀。 | +| namespace | string | 是 | 当前元素及其子元素的命名空间。 | **示例:** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.setDeclaration(); @@ -166,13 +166,13 @@ setComment(text: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | ---------- | -| text | string | 是 | 当前元素的注释内容。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| text | string | 是 | 当前元素的注释内容。 | **示例:** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.startElement("note"); @@ -189,13 +189,13 @@ setCDATA(text: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | ----------- | -| text | string | 是 | CDATA属性的内容。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| text | string | 是 | CDATA属性的内容。 | **示例:** -``` +```js var arrayBuffer = new ArrayBuffer(1028); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.setCDATA('root SYSTEM') // => ''; @@ -210,13 +210,13 @@ setText(text: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | ---------- | -| text | string | 是 | text属性的内容。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| text | string | 是 | text属性的内容。 | **示例:** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.startElement("note"); @@ -234,13 +234,13 @@ setDocType(text: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | ------------- | -| text | string | 是 | DocType属性的内容。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| text | string | 是 | DocType属性的内容。 | **示例:** -``` +```js var arrayBuffer = new ArrayBuffer(1024); var thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.setDocType('root SYSTEM'); // => ''; @@ -258,14 +258,14 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string) **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------- | ---- | -------------------------------- | -| buffer | ArrayBuffer \| DataView | 是 | 含有xml文本信息的ArrayBuffer或者DataView。 | -| encoding | string | 否 | 编码格式(仅支持utf-8)。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| buffer | ArrayBuffer \| DataView | 是 | 含有xml文本信息的ArrayBuffer或者DataView。 | +| encoding | string | 否 | 编码格式(仅支持utf-8)。 | **示例:** -``` +```js var strXml = '' + '' + @@ -291,13 +291,13 @@ parse(option: ParseOptions): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ----------------------------- | ---- | ---------------- | -| option | [ParseOptions](#parseoptions) | 是 | 用户控制以及获取解析信息的选项。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| option | [ParseOptions](#parseoptions) | 是 | 用户控制以及获取解析信息的选项。 | **示例:** -``` +```js var strXml = '' + '' + @@ -330,13 +330,13 @@ that.parse(options); xml解析选项。 -| 名称 | 类型 | 必填 | 说明 | -| ------------------------------ | ---------------------------------------- | ---- | -------------------------------- | -| supportDoctype | boolean | 否 | 是否忽略Doctype , 默认false。 | -| ignoreNameSpace | boolean | 否 | 是否忽略NameSpace,默认false。 | -| tagValueCallbackFunction | (name: string, value: string)=> boolean | 否 | 获取tagValue回调函数。 | -| attributeValueCallbackFunction | (name: string, value: string)=> boolean | 否 | 获取attributeValue回调函数。 | -| tokenValueCallbackFunction | (eventType: [EventType](#eventtype), value: [ParseInfo](#parseinfo))=> boolean | 否 | 获取tokenValue回调函数。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| supportDoctype | boolean | 否 | 是否忽略Doctype , 默认false。 | +| ignoreNameSpace | boolean | 否 | 是否忽略NameSpace,默认false。 | +| tagValueCallbackFunction | (name: string, value: string)=> boolean | 否 | 获取tagValue回调函数。 | +| attributeValueCallbackFunction | (name: string, value: string)=> boolean | 否 | 获取attributeValue回调函数。 | +| tokenValueCallbackFunction | (eventType: [EventType](#eventtype), value: [ParseInfo](#parseinfo))=> boolean | 否 | 获取tokenValue回调函数。 | ## ParseInfo @@ -351,8 +351,8 @@ getColumnNumber(): number **返回值:** -| 类型 | 说明 | -| ------ | ------- | +| 类型 | 说明 | +| -------- | -------- | | number | 返回当前列号。 | @@ -364,8 +364,8 @@ getDepth(): number **返回值:** -| 类型 | 说明 | -| ------ | ---------- | +| 类型 | 说明 | +| -------- | -------- | | number | 返回元素的当前深度。 | @@ -377,8 +377,8 @@ getLineNumber(): number **返回值:** -| 类型 | 说明 | -| ------ | ------- | +| 类型 | 说明 | +| -------- | -------- | | number | 返回当前行号。 | @@ -390,8 +390,8 @@ getName(): string **返回值:** -| 类型 | 说明 | -| ------ | --------- | +| 类型 | 说明 | +| -------- | -------- | | string | 返回当前元素名称。 | @@ -403,8 +403,8 @@ getNamespace(): string **返回值:** -| 类型 | 说明 | -| ------ | ------------ | +| 类型 | 说明 | +| -------- | -------- | | string | 返回当前元素的命名空间。 | @@ -416,8 +416,8 @@ getPrefix(): string **返回值:** -| 类型 | 说明 | -| ------ | --------- | +| 类型 | 说明 | +| -------- | -------- | | string | 返回当前元素前缀。 | @@ -429,8 +429,8 @@ getText(): string **返回值:** -| 类型 | 说明 | -| ------ | ------------ | +| 类型 | 说明 | +| -------- | -------- | | string | 返回当前事件的文本内容。 | @@ -442,8 +442,8 @@ isEmptyElementTag(): boolean **返回值:** -| 类型 | 说明 | -| ------- | ---------------- | +| 类型 | 说明 | +| -------- | -------- | | boolean | 返回true,当前元素为空元素。 | @@ -455,8 +455,8 @@ isWhitespace(): boolean **返回值:** -| 类型 | 说明 | -| ------- | --------------------- | +| 类型 | 说明 | +| -------- | -------- | | boolean | 返回true,当前文本事件仅包含空格字符。 | @@ -467,8 +467,8 @@ getAttributeCount(): number 获取当前开始标记的属性数。 **返回值:** -| 类型 | 说明 | -| ------ | ----------- | +| 类型 | 说明 | +| -------- | -------- | | number | 当前开始标记的属性数。 | @@ -476,16 +476,16 @@ getAttributeCount(): number 事件枚举。 -| 名称 | 枚举值 | 说明 | -| ---------------- | ---- | ------------ | -| START_DOCUMENT | 0 | 启动文件事件。 | -| END_DOCUMENT | 1 | 结束文件事件。 | -| START_TAG | 2 | 启动标签事件。 | -| END_TAG | 3 | 结束标签事件。 | -| TEXT | 4 | 文本事件。 | -| CDSECT | 5 | CDATA事件。 | -| COMMENT | 6 | XML注释事件。 | -| DOCDECL | 7 | XML文档类型声明事件。 | -| INSTRUCTION | 8 | XML处理指令声明事件。 | -| ENTITY_REFERENCE | 9 | 实体引用事件。 | -| WHITESPACE | 10 | 空白事件。 | +| 名称 | 枚举值 | 说明 | +| -------- | -------- | -------- | +| START_DOCUMENT | 0 | 启动文件事件。 | +| END_DOCUMENT | 1 | 结束文件事件。 | +| START_TAG | 2 | 启动标签事件。 | +| END_TAG | 3 | 结束标签事件。 | +| TEXT | 4 | 文本事件。 | +| CDSECT | 5 | CDATA事件。 | +| COMMENT | 6 | XML注释事件。 | +| DOCDECL | 7 | XML文档类型声明事件。 | +| INSTRUCTION | 8 | XML处理指令声明事件。 | +| ENTITY_REFERENCE | 9 | 实体引用事件。 | +| WHITESPACE | 10 | 空白事件。 | diff --git a/zh-cn/application-dev/webgl/Readme-CN.md b/zh-cn/application-dev/webgl/Readme-CN.md index 89d715d5a45a30e3a78c76937f835d89d2527549..0a2a1aa80df27bf99eb8077133c396774819fca2 100644 --- a/zh-cn/application-dev/webgl/Readme-CN.md +++ b/zh-cn/application-dev/webgl/Readme-CN.md @@ -1,4 +1,4 @@ # WebGL -- [概述](webgl-overview.md) +- [WebGL开发概述](webgl-overview.md) - [WebGL开发指导](webgl-guidelines.md) diff --git a/zh-cn/application-dev/website.md b/zh-cn/application-dev/website.md index 4717b423c14696a71c8575cd92f0b828349f7b5d..a849a0cffef36e1fda7b1749f996bc87f4dc8c2e 100644 --- a/zh-cn/application-dev/website.md +++ b/zh-cn/application-dev/website.md @@ -14,15 +14,22 @@ - [SysCap说明](quick-start/syscap.md) - 开发 - Ability开发 - - [FA模型综述](ability/fa-brief.md) - - [PageAbility开发指导](ability/fa-pageability.md) - - [ServiceAbility开发指导](ability/fa-serviceability.md) - - [DataAbility开发指导](ability/fa-dataability.md) - - [FA卡片开发指导](ability/fa-formability.md) + - [Ability框架概述](ability/ability-brief.md) + - FA模型 + - [FA模型综述](ability/fa-brief.md) + - [PageAbility开发指导](ability/fa-pageability.md) + - [ServiceAbility开发指导](ability/fa-serviceability.md) + - [DataAbility开发指导](ability/fa-dataability.md) + - [FormAbility开发指导](ability/fa-formability.md) + - Stage模型 + - [Stage模型综述](ability/stage-brief.md) + - [Ability开发指导](ability/stage-ability.md) + - [ServiceExtensionAbility开发指导](ability/stage-serviceextension.md) + - [FormExtensionAbility开发指导](ability/stage-formextension.md) + - [应用迁移开发指导](ability/stage-ability-continuation.md) - 其他 - [WantAgent使用指导](ability/wantagent.md) - [Ability助手使用指导](ability/ability-assistant-guidelines.md) - - [测试框架使用指导](ability-delegator.md) - UI开发 - [方舟开发框架(ArkUI)概述](ui/arkui-overview.md) - 基于JS扩展的类Web开发范式 @@ -152,13 +159,13 @@ - [自定义组件生命周期回调函数](ui/ts-custom-component-lifecycle-callbacks.md) - [组件创建和重新初始化示例](ui/ts-component-creation-re-initialization.md) - [语法糖](ui/ts-syntactic-sugar.md) - - 常见组件开发指导 - - [Button开发指导](ui/ui-ts-basic-components-button.md) - - [Web开发指导](ui/ui-ts-components-web.md) - - 常见布局开发指导 - - [弹性布局](ui/ui-ts-layout-flex.md) - - [栅格布局](ui/ui-ts-layout-grid-container.md) - - [媒体查询](ui/ui-ts-layout-mediaquery.md) + - 常见组件开发指导 + - [Button开发指导](ui/ui-ts-basic-components-button.md) + - [Web开发指导](ui/ui-ts-components-web.md) + - 常见布局开发指导 + - [弹性布局](ui/ui-ts-layout-flex.md) + - [栅格布局](ui/ui-ts-layout-grid-container.md) + - [媒体查询](ui/ui-ts-layout-mediaquery.md) - 体验声明式UI - [创建声明式UI工程](ui/ui-ts-creating-project.md) - [初识Component](ui/ui-ts-components.md) @@ -191,6 +198,7 @@ - [音频采集开发指导](media/audio-capturer.md) - 视频 - [视频播放开发指导](media/video-playback.md) + - [视频录制开发指导](media/video-recorder.md) - 图片 - [图片开发指导](media/image.md) - 安全 diff --git a/zh-cn/device-dev/driver/driver-platform-gpio-des.md b/zh-cn/device-dev/driver/driver-platform-gpio-des.md index 28cc26f4f695d821cc92e153a7c18c65e95fda4b..aa833d1b9c54c57a7f60f3bc281de0c954123a29 100644 --- a/zh-cn/device-dev/driver/driver-platform-gpio-des.md +++ b/zh-cn/device-dev/driver/driver-platform-gpio-des.md @@ -65,7 +65,7 @@ GPIO接口定义了操作GPIO管脚的标准方法集合,包括:

设置管脚对应的中断服务函数

-

GpioUnSetIrq

+

GpioUnsetIrq

取消管脚对应的中断服务函数

@@ -245,7 +245,7 @@ GPIO标准API通过GPIO管脚号来操作指定管脚,使用GPIO的一般流 示例代码: - ``` + ```c int32_t ret; uint16_t val; /* 将3号GPIO管脚配置为输出 */ @@ -326,76 +326,38 @@ GPIO标准API通过GPIO管脚号来操作指定管脚,使用GPIO的一般流 >![](../public_sys-resources/icon-caution.gif) **注意:** >同一时间,只能为某个GPIO管脚设置一个中断服务函数,如果重复调用GpioSetIrq函数,则之前设置的中断服务函数会被取代。 - 当不再需要响应中断服务函数时,使用如下函数取消中断设置: +- 当不再需要响应中断服务函数时,使用如下函数取消中断设置: - int32\_t GpioUnSetIrq\(uint16\_t gpio\); + int32\_t GpioUnsetIrq\(uint16\_t gpio, void *arg\); - **表 6** GpioUnSetIrq参数和返回值描述 + **表 6** GpioUnsetIrq参数和返回值描述 - - - - - - - - - - - - - - - - -

参数

-

参数描述

-

gpio

-

GPIO管脚号

-

返回值

-

返回值描述

-

0

-

取消成功

-

负数

-

取消失败

-
+ + | **参数** | **参数描述** | + | ---------- | -------------- | + | gpio | GPIO管脚号 | + | arg | GPIO中断数据 | + | **返回值** | **返回值描述** | + | 0 | 取消成功 | + | 负数 | 取消失败 | - 在中断服务程序设置完成后,还需要先通过如下函数使能GPIO管脚的中断: +- 在中断服务程序设置完成后,还需要先通过如下函数使能GPIO管脚的中断: int32\_t GpioEnableIrq\(uint16\_t gpio\); - + **表 7** GpioEnableIrq参数和返回值描述 - + - - - - - - - - - - - - - - - - -

参数

-

参数描述

-

gpio

-

GPIO管脚号

-

返回值

-

返回值描述

-

0

-

使能成功

-

负数

-

使能失败

-
- + | **参数** | **参数描述** | + | ---------- | -------------- | + | gpio | GPIO管脚号 | + | **返回值** | **返回值描述** | + | 0 | 使能成功 | + | 负数 | 使能失败 | + + + >![](../public_sys-resources/icon-caution.gif) **注意:** >必须通过此函数使能管脚中断,之前设置的中断服务函数才能被正确响应。 @@ -406,37 +368,16 @@ GPIO标准API通过GPIO管脚号来操作指定管脚,使用GPIO的一般流 **表 8** GpioDisableIrq参数和返回值描述 - - - - - - - - - - - - - - - - -

参数

-

参数描述

-

gpio

-

GPIO管脚号

-

返回值

-

返回值描述

-

0

-

禁止成功

-

负数

-

禁止失败

-
- + | **参数** | **参数描述** | + | ---------- | -------------- | + | gpio | GPIO管脚号 | + | **返回值** | **返回值描述** | + | 0 | 禁止成功 | + | 负数 | 禁止失败 | + 示例代码: - - ``` + +```c /* 中断服务函数 */ int32_t MyCallBackFunc(uint16_t gpio, void *data) @@ -459,21 +400,21 @@ GPIO标准API通过GPIO管脚号来操作指定管脚,使用GPIO的一般流 HDF_LOGE("GpioEnableIrq: failed, ret %d\n", ret); return; } - + /* 禁止3号GPIO管脚中断 */ ret = GpioDisableIrq(3); if (ret != 0) { HDF_LOGE("GpioDisableIrq: failed, ret %d\n", ret); return; } - + /* 取消3号GPIO管脚中断服务程序 */ - ret = GpioUnSetIrq(3); + ret = GpioUnsetIrq(3, NULL); if (ret != 0) { HDF_LOGE("GpioUnSetIrq: failed, ret %d\n", ret); return; } - ``` +``` ## 使用实例 @@ -484,7 +425,7 @@ GPIO标准API通过GPIO管脚号来操作指定管脚,使用GPIO的一般流 读者可以根据自己使用的开发板,参考其原理图,选择一个空闲的GPIO管脚即可。 -``` +```c #include "gpio_if.h" #include "hdf_log.h" #include "osal_irq.h" @@ -550,7 +491,7 @@ static int32_t TestCaseGpioIrqEdge(void) OsalMDelay(200); /* wait for irq trigger */ timeout += 200; } - (void)GpioUnSetIrq(gpio); + (void)GpioUnsetIrq(gpio, NULL); return (g_irqCnt > 0) ? HDF_SUCCESS : HDF_FAILURE; } ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-overview.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-overview.md index bb73222e4580bbb3ca1698da91a517ac03016c85..489f016ca2cb39aade136f63d97f31c5247011b1 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-overview.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-overview.md @@ -12,7 +12,7 @@ OpenHarmony轻量和小型系统适用于内存较小的IOT设备(参考内存 - 安装包方式:通过命令行进行编译依赖工具的下载安装,编译操作也通过命令实现。烧录、运行等操作使用IDE。 OpenHarmony还为开发者提供了[Docker环境](../get-code/gettools-acquire.md),在很大程度上简化了编译前的环境配置,习惯使用安装包方式的开发者也可以选择Docker环境进行编译 。 -本文采用DevEco Device Tool进行一站式开发介绍,习惯使用命令行的开发者可参考[轻量和小型系统快速入门(安装包方式)](../quick-start/quickstart-lite-package-directory.md)。 +本文采用DevEco Device Tool进行一站式开发介绍,习惯使用命令行的开发者可参考[轻量和小型系统快速入门(安装包方式)](../quick-start/quickstart-lite-overview.md)。 ## 开发环境 @@ -28,7 +28,7 @@ OpenHarmony轻量和小型系统适用于内存较小的IOT设备(参考内存 ## 开发板 -本文基于以下两款典型开发板进行开发介绍 :Hi3861 WLAN模组、Hi3516DV300。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-ide-lite-board-introduction.md),开发者可根据需要自行购买开发板。 +本文基于以下两款典型开发板进行开发介绍 :Hi3861 WLAN模组、Hi3516DV300。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-ide-lite-introduction-hi3861.md),开发者可根据需要自行购买开发板。 ## 开发流程 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-overview.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-overview.md index f6f1961c270e114ca0d7c4fe8025a0d357ddc3e5..7ff52660f208a7cbf85c40bf69e1bfedd1e0a05b 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-overview.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-overview.md @@ -12,7 +12,7 @@ OpenHarmony标准系统适用于参考内存≥128MiB的设备。通过本文, - 安装包方式:通过命令行进行编译依赖工具的下载安装,编译操作也通过命令实现。烧录、运行等操作使用IDE。 OpenHarmony还为开发者提供了[Docker环境](../get-code/gettools-acquire.md),在很大程度上简化了编译前的环境配置,习惯使用安装包方式的开发者也可以选择Docker环境进行编译 。 -本文采用DevEco Device Tool进行一站式开发介绍,习惯使用命令行的开发者可参考[标准系统快速入门(安装包方式)](../quick-start/quickstart-standard-package-directory.md)。 +本文采用DevEco Device Tool进行一站式开发介绍,习惯使用命令行的开发者可参考[标准系统快速入门(安装包方式)](../quick-start/quickstart-standard-overview.md)。 ## 开发环境 @@ -28,7 +28,7 @@ OpenHarmony标准系统适用于参考内存≥128MiB的设备。通过本文, ## 开发板 -本文选取了两款典型开发板:Hi3516DV300、RK3568,并基于上述两款开发板进行开发介绍。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-standard-board-introduction.md),开发者可根据需要自行购买开发板。 +本文选取了两款典型开发板:Hi3516DV300、RK3568,并基于上述两款开发板进行开发介绍。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-ide-standard-board-introduction-hi3516.md),开发者可根据需要自行购买开发板。 ## 开发流程 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-overview.md b/zh-cn/device-dev/quick-start/quickstart-lite-overview.md index 291ad0accad339b86416c7656c503b7021110e6a..ec0e29dda6fb2958e263c54177d262fd5de56d6a 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-overview.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-overview.md @@ -15,7 +15,7 @@ OpenHarmony轻量和小型系统适用于内存较小的IOT设备(参考内存 - 安装包方式:通过命令行进行编译依赖工具的下载安装,编译操作也通过命令实现。烧录、运行等操作使用IDE。OpenHarmony还为开发者提供了[Docker环境](../get-code/gettools-acquire.md),在很大程度上简化了编译前的环境配置,习惯使用安装包方式的开发者也可以选择Docker环境进行编译 。 -本文采用安装包方式进行介绍,习惯使用DevEco Device Tool的开发者可参考[轻量与小型系统快速入门(IDE方式)](../quick-start/quickstart-ide-lite.md)。 +本文采用安装包方式进行介绍,习惯使用DevEco Device Tool的开发者可参考[轻量与小型系统快速入门(IDE方式)](../quick-start/quickstart-ide-lite-overview.md)。 ## 开发环境 @@ -31,7 +31,7 @@ OpenHarmony轻量和小型系统适用于内存较小的IOT设备(参考内存 ## 开发板 -本文基于以下两款典型开发板进行开发介绍 :Hi3861 WLAN模组、Hi3516DV300。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-lite-board-introduction.md),开发者可根据需要自行购买开发板。 +本文基于以下两款典型开发板进行开发介绍 :Hi3861 WLAN模组、Hi3516DV300。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-lite-introduction-hi3861.md),开发者可根据需要自行购买开发板。 ## 开发流程 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-overview.md b/zh-cn/device-dev/quick-start/quickstart-standard-overview.md index c3e39d1ca784e4c584d62008c10b7efb9622f1a3..e2d825ec44324e800f75d5b54233792d1773c561 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-overview.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-overview.md @@ -12,7 +12,7 @@ OpenHarmony标准系统适用于参考内存≥128MiB的设备。通过本文, - 安装包方式:通过命令行进行编译依赖工具的下载安装,编译操作也通过命令实现。烧录、运行等操作使用IDE。 OpenHarmony还为开发者提供了[Docker环境](../get-code/gettools-acquire.md),在很大程度上简化了编译前的环境配置,习惯使用安装包方式的开发者也可以选择Docker环境进行编译 。 -本文采用安装包方式进行介绍,习惯使用DevEco Device Tool的开发者可参考[标准系统快速入门(IDE方式)](../quick-start/quickstart-standard-ide.md)。 +本文采用安装包方式进行介绍,习惯使用DevEco Device Tool的开发者可参考[标准系统快速入门(IDE方式)](../quick-start/quickstart-ide-standard-overview.md)。 ## 开发环境 @@ -28,7 +28,7 @@ OpenHarmony标准系统适用于参考内存≥128MiB的设备。通过本文, ## 开发板 -本文选取了两款典型开发板:Hi3516DV300、RK3516,并基于上述两款开发板进行开发介绍。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-standard-board-introduction.md),开发者可根据需要自行购买开发板。 +本文选取了两款典型开发板:Hi3516DV300、RK3516,并基于上述两款开发板进行开发介绍。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-standard-board-introduction-hi3516.md),开发者可根据需要自行购买开发板。 ## 开发流程 diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hichecker.md b/zh-cn/device-dev/subsystems/subsys-dfx-hichecker.md index 0b9030838e3ef2da1f862ca828b32fcf28e2538b..5122141a151d8e283dcf29191ee3e5d5664244b5 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hichecker.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hichecker.md @@ -23,20 +23,20 @@ HiChecker提供的主要接口及功能如下: | **类** | **方法(包括返回值、方法名、参数列表)** | **描述** | | -------- | -------- | -------- | | HiChecker | uint_64_t RULE_CAUTION_PRINT_LOG
= 1<<63; | 告警规则,当有告警时记录日志。 | -| uint_64_t RULE_CAUTION_TRIGGER_CRASH = 1<<62; | 告警规则,当有告警时让应用退出。 | -| uint_64_t RULE_THREAD_CHECK_SLOW_PROCESS = 1; | 检测规则,检测是否有耗时函数被调用。 | -| uint_64_t RULE_CHECK_SLOW_EVENT = 1<<32; | 检测规则,检测有事件分发或处理超过规定的时间阈值。 | -| uint_64_t RULE_CHECK_ABILITY_CONNECTION_LEAK = 1<<33; | 检测规则,检测ability泄露。 | -| AddRule(uint_64_t rule) : void | 添加一条或者多条规则到系统,系统根据添加的规则进行检测或反馈。 | -| RemoveRule(uint_64_t rule) : void | 删除一组规则,删除的规则后续将不再生效。 | -| GetRule() : uint_64_t | 获取当前线程规则、进程规则、告警规则的合集。 | -| Contains(uint_64_t rule) : bool | 当前已添加的规则集中是否包含了某一个特定的规则, 如果传入的rule是线程级别的rule,仅查询当前线程中是否包含。 | -| NotifySlowProcess(std::string tag) : void | 通知有慢处理,通知系统当前代码调用了耗时较长的慢处理流程,以告知应用重要线程中尽量避开直接调用。 | -| NotifySlowEvent(std::string tag) : void | 通知发生事件分发超时或执行超时。 | -| NotifyAbilityConnectionLeak(Caution caution) : void | 通知发生AbilityConnection泄露。 | +|| uint_64_t RULE_CAUTION_TRIGGER_CRASH = 1<<62; | 告警规则,当有告警时让应用退出。 | +|| uint_64_t RULE_THREAD_CHECK_SLOW_PROCESS = 1; | 检测规则,检测是否有耗时函数被调用。 | +|| uint_64_t RULE_CHECK_SLOW_EVENT = 1<<32; | 检测规则,检测有事件分发或处理超过规定的时间阈值。 | +|| uint_64_t RULE_CHECK_ABILITY_CONNECTION_LEAK = 1<<33; | 检测规则,检测ability泄露。 | +|| AddRule(uint_64_t rule) : void | 添加一条或者多条规则到系统,系统根据添加的规则进行检测或反馈。 | +|| RemoveRule(uint_64_t rule) : void | 删除一组规则,删除的规则后续将不再生效。 | +|| GetRule() : uint_64_t | 获取当前线程规则、进程规则、告警规则的合集。 | +|| Contains(uint_64_t rule) : bool | 当前已添加的规则集中是否包含了某一个特定的规则, 如果传入的rule是线程级别的rule,仅查询当前线程中是否包含。 | +|| NotifySlowProcess(std::string tag) : void | 通知有慢处理,通知系统当前代码调用了耗时较长的慢处理流程,以告知应用重要线程中尽量避开直接调用。 | +|| NotifySlowEvent(std::string tag) : void | 通知发生事件分发超时或执行超时。 | +|| NotifyAbilityConnectionLeak(Caution caution) : void | 通知发生AbilityConnection泄露。 | | Caution | GetTriggerRule() : uint_64_t | 获取触发当前告警的检测规则。 | -| GetCautionMsg() : std::string | 获取更多辅助信息。 | -| GetStackTrace() : std::string | 获取告警触发时的堆栈信息。 | +|| GetCautionMsg() : std::string | 获取更多辅助信息。 | +|| GetStackTrace() : std::string | 获取告警触发时的堆栈信息。 | ### 开发实例 diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md b/zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md index c546225c98bce2cb6cdde07786a0595abe7cdb54..8f2b186f0c46260d58b7e7f5ddcd05e7eac349e9 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md @@ -16,7 +16,7 @@ HiDumper是OpenHarmony为开发、测试人员、IDE工具提供的系统信息 /base/hiviewdfx/hidumper ├── frameworks # 框架代码 │ ├── native # 导出功能核心代码 -│ │ │── inlude # 头文件目录 +│ │ │── include # 头文件目录 │ │ │── src # 源文件目录 │ │ │── common # 通用功能代码 │ │ │── executor # 导出过程执行器代码 diff --git a/zh-cn/device-dev/website.md b/zh-cn/device-dev/website.md index f4db60a166f302bad43de01420835518c51f93fa..0f5763f9f45676ba3bead254135e048f55f2e9e4 100644 --- a/zh-cn/device-dev/website.md +++ b/zh-cn/device-dev/website.md @@ -15,7 +15,7 @@ - [烧录](quick-start/quickstart-ide-lite-steps-hi3861-burn.md) - [联网](quick-start/quickstart-ide-lite-steps-hi3861-netconfig.md) - [调试验证](quick-start/quickstart-ide-lite-steps-hi3861-debug.md) - - [运行](quick-start/quickstart-ide-lite-steps-hi3861-running.md) + - [运行](quick-start/quickstart-ide-lite-steps-hi3816-running.md) - Hi3516开发板 - [编写“Hello World”程序](quick-start/quickstart-ide-lite-steps-hi3516-application-framework.md) - [编译](quick-start/quickstart-ide-lite-steps-hi3516-building.md)