| 724 | } |
| 725 | |
| 726 | napi_value equalAPI(napi_env env, napi_callback_info info) { |
| 727 | size_t argc = 2; |
| 728 | napi_value args[2]; |
| 729 | napi_get_cb_info(env, info, &argc, args, NULL, NULL); |
| 730 | |
| 731 | // Get buffer info for first buffer (zero-copy) |
| 732 | void *first_data; |
| 733 | size_t first_length; |
| 734 | napi_status status = napi_get_buffer_info(env, args[0], &first_data, &first_length); |
| 735 | if (status != napi_ok) { |
| 736 | napi_throw_error(env, NULL, "First argument must be a Buffer"); |
| 737 | return NULL; |
| 738 | } |
| 739 | |
| 740 | // Get buffer info for second buffer (zero-copy) |
| 741 | void *second_data; |
| 742 | size_t second_length; |
| 743 | status = napi_get_buffer_info(env, args[1], &second_data, &second_length); |
| 744 | if (status != napi_ok) { |
| 745 | napi_throw_error(env, NULL, "Second argument must be a Buffer"); |
| 746 | return NULL; |
| 747 | } |
| 748 | |
| 749 | // Compare for equality - need to check length first, then content |
| 750 | sz_bool_t equal = (first_length == second_length) && |
| 751 | (first_length == 0 || sz_equal((sz_cptr_t)first_data, (sz_cptr_t)second_data, first_length)); |
| 752 | |
| 753 | // Convert to JavaScript boolean and return |
| 754 | napi_value js_result; |
| 755 | napi_get_boolean(env, equal, &js_result); |
| 756 | |
| 757 | return js_result; |
| 758 | } |
| 759 | |
| 760 | napi_value compareAPI(napi_env env, napi_callback_info info) { |
| 761 | size_t argc = 2; |
nothing calls this directly
no test coverage detected
searching dependent graphs…