source
stringlengths
14
113
code
stringlengths
10
21.3k
application-dev\napi\use-napi-about-array.md
// index.d.ts export const isArray: <T>(data: Array<T> | T) => boolean | void;
application-dev\napi\use-napi-about-array.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { let value = new Array<number>(1); let data = "123"; hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_array: %{public}s', testNapi.isArray<number>(value)); hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_array: %{public}s', testN...
application-dev\napi\use-napi-about-array.md
export const napiSetElement: <T>(arr: Array<T>, index: number, value: T) => void;
application-dev\napi\use-napi-about-array.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; let arr = [10, 20, 30]; testNapi.napiSetElement<number | string>(arr, 1, 'newElement'); testNapi.napiSetElement<number | string>(arr, 2, 50); hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_element arr: %{public}s', arr.toString()); hilog.info(0...
application-dev\napi\use-napi-about-array.md
// index.d.ts export const napiGetElement: <T>(arr: Array<T>, index: number) => number | string | Object | boolean | undefined;
application-dev\napi\use-napi-about-array.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; interface MyObject { first: number; second: number; } let obj: MyObject = { first: 1, second: 2 }; let arr = [10, 'hello', null, obj]; hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_element arr[0]: %{public}d', testNapi.napiGetElement<...
application-dev\napi\use-napi-about-array.md
// index.d.ts export const napiHasElement: <T>(arr: Array<T>, index: number) => boolean;
application-dev\napi\use-napi-about-array.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; let arr = [10, 'hello', null, 'world']; hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_element arr[0]: %{public}s', testNapi.napiHasElement<number | string | null>(arr, 0)); hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_element arr[7]:...
application-dev\napi\use-napi-about-array.md
// index.d.ts export const napiDeleteElement: <T>(arr: Array<T>, index: number) => boolean;
application-dev\napi\use-napi-about-array.md
// Import napiHasElement and napiGetElement. import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; let arr = [10, 'hello', null, 'world']; hilog.info(0x0000, 'testTag', 'Test Node-API napi_has_element arr[0]: %{public}s', testNapi.napiHasElement<number | string | null>(arr, 0)); hilog.info(0x0000, 'test...
application-dev\napi\use-napi-about-array.md
// index.d.ts export const enum TypedArrayTypes { INT8_ARRAY = 0, UINT8_ARRAY, UINT8_CLAMPED_ARRAY, INT16_ARRAY, UINT16_ARRAY, INT32_ARRAY, UINT32_ARRAY, FLOAT32_ARRAY, FLOAT64_ARRAY, BIGINT64_ARRAY, BIGuINT64_ARRAY, } export const createTypedArray: <T>(type: TypedArrayTypes) => T;
application-dev\napi\use-napi-about-array.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; // Pass the type of the array to create. let typedArray = testNapi.createTypedArray<Int8Array>(testNapi.TypedArrayTypes["INT8_ARRAY"]); if (typedArray instanceof Int8Array) { hilog.info(0x0000, 'testTag', ' Node-API napi_create_typedarray: Int8Ar...
application-dev\napi\use-napi-about-array.md
// index.d.ts export const isTypedarray: (data: Object) => boolean | void;
application-dev\napi\use-napi-about-array.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { let value = new Uint8Array([1, 2, 3, 4]); let data = "123"; hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_typedarray: %{public}s', testNapi.isTypedarray(value)); hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_typedarray: %{p...
application-dev\napi\use-napi-about-array.md
// index.d.ts export const getTypedarrayInfo: <T>(typeArray: T, infoType: number) => ArrayBuffer | number | boolean;
application-dev\napi\use-napi-about-array.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; // Pass in the TypedArray type. TypedArray is a class array data view used to describe binary data. It does not have a constructor and can be constructed from its child class. // The child classes of TypedArray include Int8Array, Uint8Array, Uint8Cla...
application-dev\napi\use-napi-about-array.md
// index.d.ts export const createDataView: (arraybuffer:ArrayBuffer) => DataView | void;
application-dev\napi\use-napi-about-array.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; const arrayBuffer = new ArrayBuffer(16); const dataView = testNapi.createDataView(arrayBuffer) as DataView; hilog.info(0x0000, 'testTag', 'Test Node-API dataView: %{public}d', dataView.byteLength); hilog.info(0x0000, 'testTag','Test Node-API dataView...
application-dev\napi\use-napi-about-array.md
// index.d.ts export const isDataView: (date: DataView | string) => boolean | void;
application-dev\napi\use-napi-about-array.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { let buffer = new ArrayBuffer(16); let dataView = new DataView(buffer); let data = "123"; hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_dataview: %{public}s', testNapi.isDataView(dataView)); hilog.info(0x0000, 'testTag', 'Test No...
application-dev\napi\use-napi-about-array.md
// index.d.ts export const getDataViewInfo: (dataView: DataView, infoType: number) => ArrayBuffer | number;
application-dev\napi\use-napi-about-array.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; // Create an ArrayBuffer object. let arrayBuffer = new Int8Array([2, 5]).buffer; // Use arrayBuffer to create a DataView object. let dataView = new DataView(arrayBuffer); // Define an enum type. enum InfoType { BYTE_LENGTH = 0, ARRAY_BUFFER =...
application-dev\napi\use-napi-about-arraybuffer.md
// index.d.ts export const isArrayBuffer: <T>(arrayBuffer: T) => boolean | void;
application-dev\napi\use-napi-about-arraybuffer.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { let value = new ArrayBuffer(1); let data = "123"; hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_arraybuffer: %{public}s', testNapi.isArrayBuffer(value)); hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_arraybuffer: %{public}s...
application-dev\napi\use-napi-about-arraybuffer.md
// index.d.ts export class ArrayBufferInfo { byteLength: number; buffer: ArrayBuffer; } export const getArrayBufferInfo: (data: ArrayBuffer) => ArrayBufferInfo | void;
application-dev\napi\use-napi-about-arraybuffer.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; const buffer = new ArrayBuffer(10); hilog.info(0x0000, 'testTag', 'Test Node-API get_arrayBuffer_info:%{public}s ', JSON.stringify(testNapi.getArrayBufferInfo(buffer)));
application-dev\napi\use-napi-about-arraybuffer.md
// index.d.ts export const detachedArrayBuffer: (buffer:ArrayBuffer) => ArrayBuffer; export const isDetachedArrayBuffer: (arrayBuffer: ArrayBuffer) => boolean;
application-dev\napi\use-napi-about-arraybuffer.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { const bufferArray = new ArrayBuffer(8); hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_detached_arraybuffer one: %{public}s', testNapi.isDetachedArrayBuffer(bufferArray)); hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_detached...
application-dev\napi\use-napi-about-arraybuffer.md
// index.d.ts export const createArrayBuffer: (size: number) => ArrayBuffer;
application-dev\napi\use-napi-about-arraybuffer.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_arraybuffer:%{public}s', testNapi.createArrayBuffer(10).toString());
application-dev\napi\use-napi-about-bigint.md
// index.d.ts export const createBigintInt64t: () => bigint;
application-dev\napi\use-napi-about-bigint.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_bigint_int64: %{public}d', testNapi.createBigintInt64t());
application-dev\napi\use-napi-about-bigint.md
// index.d.ts export const createBigintUint64t: () => bigint;
application-dev\napi\use-napi-about-bigint.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_bigint_uint64: %{public}d', testNapi.createBigintUint64t());
application-dev\napi\use-napi-about-bigint.md
// index.d.ts export const createBigintWords: () => bigint | void;
application-dev\napi\use-napi-about-bigint.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_bigint_words: %{public}d', testNapi.createBigintWords()); } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API NapiGetValueBigint: %{public}s', error.message); }
application-dev\napi\use-napi-about-bigint.md
// index.d.ts export const getValueBigintInt64t: (bigInt64: bigint) => boolean | void;
application-dev\napi\use-napi-about-bigint.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; let bigInt = BigInt(-5555555555555555); try { hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_value_bigint_int64: %{public}s', JSON.stringify(testNapi.getValueBigintInt64t(bigInt))); } catch (error) { hilog.error(0x0000, 'testTa...
application-dev\napi\use-napi-about-bigint.md
// index.d.ts export const getValueBigintUint64t: (bigUint64: bigint) => boolean | void;
application-dev\napi\use-napi-about-bigint.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; let bigUint = BigInt(5555555555555555); try { hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_value_bigint_uint64: %{public}s', JSON.stringify(testNapi.getValueBigintUint64t(bigUint))); } catch (error) { hilog.error(0x0000, 'tes...
application-dev\napi\use-napi-about-bigint.md
// index.d.ts export const getValueBigintWords: (bigIntWords: bigint) => bigint | void;
application-dev\napi\use-napi-about-bigint.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; let bigInt = BigInt(-5555555555555555); let bigUint = BigInt(5555555555555555); try { hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_value_bigint_words signBit is: %{public}d', testNapi.getValueBigintWords(bigInt)); hilog.info(0x0000, 'test...
application-dev\napi\use-napi-about-buffer.md
// index.d.ts export const createBuffer: () => string;
application-dev\napi\use-napi-about-buffer.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_buffer: %{public}s', testNapi.createBuffer().toString()); } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API napi_create_buffer error'); }
application-dev\napi\use-napi-about-buffer.md
// index.d.ts export const createBufferCopy: () => string;
application-dev\napi\use-napi-about-buffer.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_buffer_copy: %{public}s', testNapi.createBufferCopy().toString()); } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API napi_create_buffer_copy error'); }
application-dev\napi\use-napi-about-buffer.md
// index.d.ts export const createExternalBuffer: () => string;
application-dev\napi\use-napi-about-buffer.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_external_buffer: %{public}s', testNapi.createExternalBuffer() .toString()); } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API napi_create_external_buffer error'); }
application-dev\napi\use-napi-about-buffer.md
// index.d.ts export const getBufferInfo: () => string;
application-dev\napi\use-napi-about-buffer.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_buffer_info: %{public}s', testNapi.getBufferInfo().toString()); } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API napi_get_buffer_info error'); }
application-dev\napi\use-napi-about-buffer.md
// index.d.ts export const isBuffer: () => boolean;
application-dev\napi\use-napi-about-buffer.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_buffer: %{public}s', JSON.stringify(testNapi.isBuffer())); } catch (error) { hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_buffer error'); }
application-dev\napi\use-napi-about-buffer.md
// index.d.ts export const createExternalArraybuffer: () => ArrayBuffer | void;
application-dev\napi\use-napi-about-buffer.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; hilog.info(0x0000, 'testTag', 'Node-API createExternalArraybuffer: %{public}s', JSON.stringify(testNapi.createExternalArraybuffer()));
application-dev\napi\use-napi-about-class.md
// index.d.ts export const newInstance: (obj: Object, param: string) => Object;
application-dev\napi\use-napi-about-class.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; class Fruit { name: string; constructor(name: string) { this.name = name; } } // Call the function and use the variable obj to hold the instance created. let obj = testNapi.newInstance(Fruit, 'test'); // Print the information about the objec...
application-dev\napi\use-napi-about-class.md
// index.d.ts export const wrap: (obj: Object) => Object; export const unWrap: (obj: Object) => void; export const removeWrap: (obj: Object) => void;
application-dev\napi\use-napi-about-class.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { class Obj {} let obj: Obj = {}; testNapi.wrap(obj) testNapi.unWrap(obj) testNapi.removeWrap(obj) } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API error: %{public}s', error.message); }
application-dev\napi\use-napi-about-cleanuphook.md
// index.d.ts export const napiEnvCleanUpHook: () => Object | void;
application-dev\napi\use-napi-about-cleanuphook.md
// index.ets import hilog from '@ohos.hilog'; import worker from '@ohos.worker'; let wk = new worker.ThreadWorker("entry/ets/workers/worker.ts"); // Send a message to the worker thread. wk.postMessage("test NapiEnvCleanUpHook"); // Process the message from the worker thread. wk.onmessage = (message) => { hilog.info(...
application-dev\napi\use-napi-about-cleanuphook.md
// worker.ts import hilog from '@ohos.hilog'; import worker from '@ohos.worker'; import testNapi from 'libentry.so'; let parent = worker.workerPort; // Process messages from the main thread. parent.onmessage = (message) => { hilog.info(0x0000, 'testTag', 'Test Node-API message from main thread: %{public}s', JSON.str...
application-dev\napi\use-napi-about-cleanuphook.md
// index.d.ts export const napiAsyncCleanUpHook: () => boolean | void;
application-dev\napi\use-napi-about-cleanuphook.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { hilog.info(0x0000, 'testTag', 'Test Node-API napi_add_async_cleanup_hook: %{public}s', testNapi.napiAsyncCleanUpHook()); } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API napi_add_async_cleanup_hook error.message: %{public}s', ...
application-dev\napi\use-napi-about-custom-asynchronous-operations.md
// index.d.ts export const asynchronousWork: (object: Object, obj: Object, fun: Function, num: number) => number | void;
application-dev\napi\use-napi-about-custom-asynchronous-operations.md
import hilog from '@ohos.hilog' import testNapi from 'libentry.so' import process from '@ohos.process' try { hilog.info(0x0000, 'testTag', 'Test Node-API asynchronousWork: %{public}d', testNapi.asynchronousWork({}, process.ProcessManager, (num: number)=>{return num;}, 123)); } catch (error) { hilog.error(0x0000, 't...
application-dev\napi\use-napi-about-date.md
// index.d.ts export const createDate: () => Date;
application-dev\napi\use-napi-about-date.md
import hilog from '@ohos.hilog' import testNapi from 'libentry.so' hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_date: %{public}s', testNapi.createDate().toString());
application-dev\napi\use-napi-about-date.md
// index.d.ts export const getDateValue: (date: Date) => number | void;
application-dev\napi\use-napi-about-date.md
import hilog from '@ohos.hilog' import testNapi from 'libentry.so' try { const date = new Date(); hilog.info(0x0000, 'testTag', 'Node-API: output the Unix Time Stamp: %{public}d', date.getTime()); hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_date_value: %{public}d', testNapi.getDateValue(date)); } catch ...
application-dev\napi\use-napi-about-date.md
// index.d.ts export const isDate: <T>(date: T) => boolean | void;
application-dev\napi\use-napi-about-date.md
import hilog from '@ohos.hilog' import testNapi from 'libentry.so' try { let now: Date = new Date(); let date = "123"; hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_date: %{public}s', testNapi.isDate(now)); hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_date: %{public}s', testNapi.isDate(date)); } ...
application-dev\napi\use-napi-about-environmental-life-cycle.md
// index.d.ts export const setInstanceData: (data: number) => boolean;
application-dev\napi\use-napi-about-environmental-life-cycle.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; let data = 5; let value = testNapi.setInstanceData(data); hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_instance_data:%{public}s', value);
application-dev\napi\use-napi-about-environmental-life-cycle.md
// index.d.ts export const getInstanceData: () => number;
application-dev\napi\use-napi-about-environmental-life-cycle.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; let data = 5; testNapi.setInstanceData(data); let value = testNapi.getInstanceData(); hilog.info(0x0000, 'testTag', 'Test Node-API napi_set_instance_data:%{public}d', value);
application-dev\napi\use-napi-about-error.md
// index.d.ts export const getLastErrorInfo: (str: string) => string;
application-dev\napi\use-napi-about-error.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_last_error_info: %{public}s', testNapi.getLastErrorInfo('message')); } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API napi_get_last_error_info error: %{public}s', error); }
application-dev\napi\use-napi-about-error.md
// index.d.ts export const createTypeError: () => Error;
application-dev\napi\use-napi-about-error.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { throw testNapi.createTypeError(); } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API napi_create_type_error errorCode: %{public}s, errorMessage %{public}s', error.code, error.message); }
application-dev\napi\use-napi-about-error.md
// index.d.ts export const createRangeError: () => Error;
application-dev\napi\use-napi-about-error.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { throw testNapi.createRangeError(); } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API napi_create_range_error errorCode: %{public}s, errorMessage: %{public}s', error.code, error.message); }
application-dev\napi\use-napi-about-error.md
// index.d.ts export const napiThrow: () => void;
application-dev\napi\use-napi-about-error.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { testNapi.napiThrow(); } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API napi_throw errorCode: %{public}s, errorMessage: %{public}s', error.code, error.message); }
application-dev\napi\use-napi-about-error.md
// index.d.ts export const napiThrowErrorMessage: () => void; export const napiThrowError: (dividend: number, divisor: number) => void;
application-dev\napi\use-napi-about-error.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { testNapi.napiThrowErrorMessage(); } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API napi_throw_error error code: %{public}s , message: %{public}s', error.code, error.message); } try { testNapi.napiThrowError(5, 0); } catch (e...
application-dev\napi\use-napi-about-error.md
// index.d.ts export const throwTypeErrorMessage: () => void; export const throwTypeError: (message: string) => void;
application-dev\napi\use-napi-about-error.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { testNapi.throwTypeErrorMessage(); } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API napi_throw_type_error errorCode: %{public}s, errorMessage: %{public}s', error.code, error.message); } try { testNapi.throwTypeError('str'); }...
application-dev\napi\use-napi-about-error.md
// index.d.ts export const throwRangeErrorMessage: () => void; export const throwRangeError: (num: number) => number | void;
application-dev\napi\use-napi-about-error.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { testNapi.throwRangeErrorMessage(); } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API napi_throw_range_error errorCode: %{public}s, errorMessage: %{public}s', error.code, error.message); } try { testNapi.throwRangeError(1); }...
application-dev\napi\use-napi-about-error.md
// index.d.ts export const napiIsError: <T>(obj: T) => boolean;
application-dev\napi\use-napi-about-error.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { throw new Error("throwing an error"); } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_error error: %{public}s', testNapi.napiIsError(error) .toString()); hilog.error(0x0000, 'testTag', 'Test Node-API napi_is_err...
application-dev\napi\use-napi-about-error.md
// index.d.ts export const getAndClearLastException: () => Error | void;
application-dev\napi\use-napi-about-error.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; // Obtain the last unprocessed exception. hilog.info(0x0000, 'testTag', 'Test Node-API napi_get_and_clear_last_exception, error.message: %{public}s', testNapi.getAndClearLastException());
application-dev\napi\use-napi-about-error.md
// index.d.ts export const isExceptionPending: () => Object | void;
application-dev\napi\use-napi-about-error.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; interface MyObject { code: string; message: string; } try { let result = testNapi.isExceptionPending() as MyObject; hilog.info(0x0000, 'testTag', 'Test Node-API napi_is_exception_pending, error.Code: %{public}s, error.message: %{public}s', ...
application-dev\napi\use-napi-about-error.md
// index.d.ts export const fatalError: () => void;
application-dev\napi\use-napi-about-error.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; try { testNapi.fatalError(); } catch (error) { hilog.error(0x0000, 'testTag', 'Test Node-API napi_fatal_error error'); }
application-dev\napi\use-napi-about-error.md
// index.d.ts export const fatalException: (err: Error) => void;
application-dev\napi\use-napi-about-error.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; const err = new Error("a fatal exception occurred"); testNapi.fatalException(err);
application-dev\napi\use-napi-about-extension.md
// index.d.ts export const add: (a: number, b: number) => number;