| 355 | } hasher_t; |
| 356 | |
| 357 | napi_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 | |
| 381 | napi_value hasherUpdate(napi_env env, napi_callback_info info) { |
| 382 | size_t argc = 1; |
nothing calls this directly
no test coverage detected
searching dependent graphs…