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

Function hasherConstructor

javascript/lib.c:357–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355} hasher_t;
356
357napi_value hasherConstructor(napi_env env, napi_callback_info info) {
358 size_t argc = 1;
359 napi_value args[1];
360 napi_value js_this;
361 napi_get_cb_info(env, info, &argc, args, &js_this, NULL);
362
363 sz_u64_t seed = 0;
364 if (argc > 0) {
365 bool lossless;
366 napi_get_value_bigint_uint64(env, args[0], &seed, &lossless);
367 if (!lossless) {
368 double seed_double;
369 if (napi_get_value_double(env, args[0], &seed_double) == napi_ok) { seed = (sz_u64_t)seed_double; }
370 }
371 }
372
373 hasher_t *hasher = malloc(sizeof(hasher_t));
374 hasher->seed = seed;
375 sz_hash_state_init(&hasher->state, seed);
376 napi_wrap(env, js_this, hasher, hasher_cleanup, NULL, NULL);
377
378 return js_this;
379}
380
381napi_value hasherUpdate(napi_env env, napi_callback_info info) {
382 size_t argc = 1;

Callers

nothing calls this directly

Calls 1

sz_hash_state_initFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…