MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / byteSumAPI

Function byteSumAPI

javascript/lib.c:793–815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

791}
792
793napi_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
817napi_value Init(napi_env env, napi_value exports) {
818

Callers

nothing calls this directly

Calls 1

sz_bytesumFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…