1e41f4b71Sopenharmony_ci# Working with Other Node-API Utilities 
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## Introduction
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ciNode-API also provides some useful APIs to improve development experience.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci## Basic Concepts
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci- Module loading: A module is an ArkTS file that contains specific functionalities. You can import a module to the shared library. Understanding the loading mechanism and dependencies between Node-API modules is helpful for using **node_api_get_module_file_name** correctly.
10e41f4b71Sopenharmony_ci- File path and URL: The return value of **node_api_get_module_file_name** is the absolute path of the module to be loaded.
11e41f4b71Sopenharmony_ci- Strict equality check: The strict equality check is used to check whether two ArkTS values are equal in type and value. When type conversion is considered, if the values being compared are of different types, **false** will be returned even if the values are the same.
12e41f4b71Sopenharmony_ci- Asynchronous operation processing: libuv can be used to implement asynchronous operations to avoid blocking the main thread.
13e41f4b71Sopenharmony_ci- Event loop: The Node-API module leverages libuv to implement the event-driven programming model. libuv provides an event loop mechanism to process events, trigger callbacks, and manage event queues.
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci## Available APIs
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci| API| Description|
18e41f4b71Sopenharmony_ci| -------- | -------- |
19e41f4b71Sopenharmony_ci| node_api_get_module_file_name | Obtains the absolute path of the module to be loaded.|
20e41f4b71Sopenharmony_ci| napi_strict_equals | Checks whether two values are strictly equal, that is, equal in both the value and type. For example, you can use **napi_strict_equals** to ensure data consistency when working on data structs or algorithms of the specific type. |
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci## Example
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ciIf you are just starting out with Node-API, see [Node-API Development Process](use-napi-process.md). The following demonstrates only the C++ and ArkTS code involved in the APIs mentioned in this topic.
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci### node_api_get_module_file_name
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ciUse **node_api_get_module_file_name** to obtain the absolute path of the module to be loaded.
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ciCPP code:
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci```cpp
33e41f4b71Sopenharmony_ci#include "napi/native_api.h"
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_cistatic napi_value GetModuleFileName(napi_env env, napi_callback_info info)
36e41f4b71Sopenharmony_ci{
37e41f4b71Sopenharmony_ci    // Declare file, a pointer variable of the const char type, to store the absolute path of the module.
38e41f4b71Sopenharmony_ci    const char *file = nullptr;
39e41f4b71Sopenharmony_ci    napi_value value = nullptr;
40e41f4b71Sopenharmony_ci    // Obtain the absolute path of the module and store it in the file variable.
41e41f4b71Sopenharmony_ci    napi_status status = node_api_get_module_file_name(env, &file);
42e41f4b71Sopenharmony_ci    if (status != napi_ok) {
43e41f4b71Sopenharmony_ci        napi_throw_error(env, nullptr, "Failed to get module file name");
44e41f4b71Sopenharmony_ci        return nullptr;
45e41f4b71Sopenharmony_ci    }
46e41f4b71Sopenharmony_ci    // Create a string of the napi_value type that contains the absolute path.
47e41f4b71Sopenharmony_ci    napi_create_string_utf8(env, file, NAPI_AUTO_LENGTH, &value);
48e41f4b71Sopenharmony_ci    return value;
49e41f4b71Sopenharmony_ci}
50e41f4b71Sopenharmony_ci```
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ciAPI declaration:
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci```ts
55e41f4b71Sopenharmony_ci// index.d.ts
56e41f4b71Sopenharmony_ciexport const getModuleFileName: () => string | void;
57e41f4b71Sopenharmony_ci```
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ciArkTS code:
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci```ts
62e41f4b71Sopenharmony_ciimport hilog from '@ohos.hilog'
63e41f4b71Sopenharmony_ciimport testNapi from 'libentry.so'
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_cilet filename = testNapi.getModuleFileName();
66e41f4b71Sopenharmony_cihilog.info(0x0000, 'testTag', 'Test Node-API node_api_get_module_file_name:%{public}s', filename);
67e41f4b71Sopenharmony_ci```
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci### napi_strict_equals
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ciUse **napi_strict_equals** to check whether two ArkTS values are strictly equal.
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ciCPP code:
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci```cpp
76e41f4b71Sopenharmony_ci#include "napi/native_api.h"
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_cistatic napi_value StrictEquals(napi_env env, napi_callback_info info)
79e41f4b71Sopenharmony_ci{
80e41f4b71Sopenharmony_ci    // Obtain the two parameters passed from ArkTS.
81e41f4b71Sopenharmony_ci    size_t argc = 2;
82e41f4b71Sopenharmony_ci    napi_value args[2] = {nullptr};
83e41f4b71Sopenharmony_ci    napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
84e41f4b71Sopenharmony_ci    // Call napi_strict_equals to check whether two ArkTS values are strictly equal.
85e41f4b71Sopenharmony_ci    bool result = true;
86e41f4b71Sopenharmony_ci    napi_status status = napi_strict_equals(env, args[0], args[1], &result);
87e41f4b71Sopenharmony_ci    if (status != napi_ok) {
88e41f4b71Sopenharmony_ci        napi_throw_error(env, nullptr, "Node-API napi_get_cb_info fail");
89e41f4b71Sopenharmony_ci        return nullptr;
90e41f4b71Sopenharmony_ci    }
91e41f4b71Sopenharmony_ci    // Convert the result to napi_value and return napi_value.
92e41f4b71Sopenharmony_ci    napi_value returnValue = nullptr;
93e41f4b71Sopenharmony_ci    napi_get_boolean(env, result, &returnValue);
94e41f4b71Sopenharmony_ci    return returnValue;
95e41f4b71Sopenharmony_ci}
96e41f4b71Sopenharmony_ci```
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ciAPI declaration:
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci```ts
101e41f4b71Sopenharmony_ci// index.d.ts
102e41f4b71Sopenharmony_ciexport const strictEquals : (lhs: string, rhs: string | number) => boolean | void;
103e41f4b71Sopenharmony_ci```
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ciArkTS code:
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci```ts
108e41f4b71Sopenharmony_ciimport hilog from '@ohos.hilog'
109e41f4b71Sopenharmony_ciimport testNapi from 'libentry.so'
110e41f4b71Sopenharmony_citry {
111e41f4b71Sopenharmony_ci  let lhs = "123";
112e41f4b71Sopenharmony_ci  let rhs = "123";
113e41f4b71Sopenharmony_ci  let str = "456";
114e41f4b71Sopenharmony_ci  let num = 123;
115e41f4b71Sopenharmony_ci  hilog.info(0x0000, 'testTag', 'Test Node-API napi_strict_equals: %{public}s', testNapi.strictEquals(lhs, rhs));
116e41f4b71Sopenharmony_ci  hilog.info(0x0000, 'testTag', 'Test Node-API napi_strict_equals: %{public}s', testNapi.strictEquals(lhs, str));
117e41f4b71Sopenharmony_ci  hilog.info(0x0000, 'testTag', 'Test Node-API napi_strict_equals: %{public}s', testNapi.strictEquals(lhs, num));
118e41f4b71Sopenharmony_ci} catch (error) {
119e41f4b71Sopenharmony_ci  hilog.error(0x0000, 'testTag', 'Test Node-API napi_strict_equals error: %{public}s', error.message);
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ci}
122e41f4b71Sopenharmony_ci```
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ciTo print logs in the native CPP, add the following information to the **CMakeLists.txt** file and add the header file by using **#include "hilog/log.h"**.
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci```text
127e41f4b71Sopenharmony_ci// CMakeLists.txt
128e41f4b71Sopenharmony_ciadd_definitions( "-DLOG_DOMAIN=0xd0d0" )
129e41f4b71Sopenharmony_ciadd_definitions( "-DLOG_TAG=\"testTag\"" )
130e41f4b71Sopenharmony_citarget_link_libraries(entry PUBLIC libhilog_ndk.z.so)
131e41f4b71Sopenharmony_ci```
132