| 758 | } |
| 759 | |
| 760 | napi_value compareAPI(napi_env env, napi_callback_info info) { |
| 761 | size_t argc = 2; |
| 762 | napi_value args[2]; |
| 763 | napi_get_cb_info(env, info, &argc, args, NULL, NULL); |
| 764 | |
| 765 | // Get buffer info for first buffer (zero-copy) |
| 766 | void *first_data; |
| 767 | size_t first_length; |
| 768 | napi_status status = napi_get_buffer_info(env, args[0], &first_data, &first_length); |
| 769 | if (status != napi_ok) { |
| 770 | napi_throw_error(env, NULL, "First argument must be a Buffer"); |
| 771 | return NULL; |
| 772 | } |
| 773 | |
| 774 | // Get buffer info for second buffer (zero-copy) |
| 775 | void *second_data; |
| 776 | size_t second_length; |
| 777 | status = napi_get_buffer_info(env, args[1], &second_data, &second_length); |
| 778 | if (status != napi_ok) { |
| 779 | napi_throw_error(env, NULL, "Second argument must be a Buffer"); |
| 780 | return NULL; |
| 781 | } |
| 782 | |
| 783 | // Compare using sz_order |
| 784 | int order = sz_order((sz_cptr_t)first_data, first_length, (sz_cptr_t)second_data, second_length); |
| 785 | |
| 786 | // Convert to JavaScript number and return |
| 787 | napi_value js_result; |
| 788 | napi_create_int32(env, order, &js_result); |
| 789 | |
| 790 | return js_result; |
| 791 | } |
| 792 | |
| 793 | napi_value byteSumAPI(napi_env env, napi_callback_info info) { |
| 794 | size_t argc = 1; |
nothing calls this directly
no test coverage detected
searching dependent graphs…