| 791 | } |
| 792 | |
| 793 | napi_value byteSumAPI(napi_env env, napi_callback_info info) { |
| 794 | size_t argc = 1; |
| 795 | napi_value args[1]; |
| 796 | napi_get_cb_info(env, info, &argc, args, NULL, NULL); |
| 797 | |
| 798 | // Get buffer info for data (zero-copy) |
| 799 | void *buffer_data; |
| 800 | size_t buffer_length; |
| 801 | napi_status status = napi_get_buffer_info(env, args[0], &buffer_data, &buffer_length); |
| 802 | if (status != napi_ok) { |
| 803 | napi_throw_error(env, NULL, "Argument must be a Buffer"); |
| 804 | return NULL; |
| 805 | } |
| 806 | |
| 807 | // Compute byte sum using sz_bytesum |
| 808 | sz_u64_t sum = sz_bytesum((sz_cptr_t)buffer_data, buffer_length); |
| 809 | |
| 810 | // Convert to JavaScript BigInt and return |
| 811 | napi_value js_result; |
| 812 | napi_create_bigint_uint64(env, sum, &js_result); |
| 813 | |
| 814 | return js_result; |
| 815 | } |
| 816 | |
| 817 | napi_value Init(napi_env env, napi_value exports) { |
| 818 |
nothing calls this directly
no test coverage detected
searching dependent graphs…