| 815 | } |
| 816 | |
| 817 | napi_value Init(napi_env env, napi_value exports) { |
| 818 | |
| 819 | // Create Hasher class constructor |
| 820 | napi_value hasherClass; |
| 821 | napi_property_descriptor hasherProps[] = { |
| 822 | {"update", 0, hasherUpdate, 0, 0, 0, napi_default, 0}, |
| 823 | {"digest", 0, hasherDigest, 0, 0, 0, napi_default, 0}, |
| 824 | {"reset", 0, hasherReset, 0, 0, 0, napi_default, 0}, |
| 825 | }; |
| 826 | napi_define_class(env, "Hasher", NAPI_AUTO_LENGTH, hasherConstructor, NULL, |
| 827 | sizeof(hasherProps) / sizeof(hasherProps[0]), hasherProps, &hasherClass); |
| 828 | |
| 829 | // Create Sha256 class constructor |
| 830 | napi_value sha256HasherClass; |
| 831 | napi_property_descriptor sha256HasherProps[] = { |
| 832 | {"update", 0, sha256HasherUpdate, 0, 0, 0, napi_default, 0}, |
| 833 | {"digest", 0, sha256HasherDigest, 0, 0, 0, napi_default, 0}, |
| 834 | {"hexdigest", 0, sha256HasherHexdigest, 0, 0, 0, napi_default, 0}, |
| 835 | {"reset", 0, sha256HasherReset, 0, 0, 0, napi_default, 0}, |
| 836 | }; |
| 837 | napi_define_class(env, "Sha256", NAPI_AUTO_LENGTH, sha256HasherConstructor, NULL, |
| 838 | sizeof(sha256HasherProps) / sizeof(sha256HasherProps[0]), sha256HasherProps, &sha256HasherClass); |
| 839 | |
| 840 | // Create Utf8CaseInsensitiveNeedle class constructor |
| 841 | napi_value utf8NeedleClass; |
| 842 | napi_property_descriptor utf8NeedleProps[] = { |
| 843 | {"findIn", 0, utf8CaseInsensitiveNeedleFindIn, 0, 0, 0, napi_default, 0}, |
| 844 | }; |
| 845 | napi_define_class(env, "Utf8CaseInsensitiveNeedle", NAPI_AUTO_LENGTH, utf8CaseInsensitiveNeedleConstructor, NULL, |
| 846 | sizeof(utf8NeedleProps) / sizeof(utf8NeedleProps[0]), utf8NeedleProps, &utf8NeedleClass); |
| 847 | |
| 848 | // Define function exports |
| 849 | napi_property_descriptor findDesc = {"indexOf", 0, indexOfAPI, 0, 0, 0, napi_default, 0}; |
| 850 | napi_property_descriptor findLastDesc = {"lastIndexOf", 0, findLastAPI, 0, 0, 0, napi_default, 0}; |
| 851 | napi_property_descriptor findByteDesc = {"findByte", 0, findByteAPI, 0, 0, 0, napi_default, 0}; |
| 852 | napi_property_descriptor findLastByteDesc = {"findLastByte", 0, findLastByteAPI, 0, 0, 0, napi_default, 0}; |
| 853 | napi_property_descriptor findByteFromDesc = {"findByteFrom", 0, findByteFromAPI, 0, 0, 0, napi_default, 0}; |
| 854 | napi_property_descriptor findLastByteFromDesc = {"findLastByteFrom", 0, findLastByteFromAPI, 0, 0, 0, |
| 855 | napi_default, 0}; |
| 856 | napi_property_descriptor countDesc = {"count", 0, countAPI, 0, 0, 0, napi_default, 0}; |
| 857 | napi_property_descriptor hashDesc = {"hash", 0, hashAPI, 0, 0, 0, napi_default, 0}; |
| 858 | napi_property_descriptor sha256Desc = {"sha256", 0, sha256API, 0, 0, 0, napi_default, 0}; |
| 859 | napi_property_descriptor equalDesc = {"equal", 0, equalAPI, 0, 0, 0, napi_default, 0}; |
| 860 | napi_property_descriptor compareDesc = {"compare", 0, compareAPI, 0, 0, 0, napi_default, 0}; |
| 861 | napi_property_descriptor byteSumDesc = {"byteSum", 0, byteSumAPI, 0, 0, 0, napi_default, 0}; |
| 862 | napi_property_descriptor utf8CaseFoldDesc = {"utf8CaseFold", 0, utf8CaseFoldAPI, 0, 0, 0, napi_default, 0}; |
| 863 | napi_property_descriptor utf8CaseInsensitiveFindDesc = { |
| 864 | "utf8CaseInsensitiveFind", 0, utf8CaseInsensitiveFindAPI, 0, 0, 0, napi_default, 0}; |
| 865 | napi_property_descriptor hasherDesc = {"Hasher", 0, 0, 0, 0, hasherClass, napi_default, 0}; |
| 866 | napi_property_descriptor sha256HasherDesc = {"Sha256", 0, 0, 0, 0, sha256HasherClass, napi_default, 0}; |
| 867 | napi_property_descriptor utf8NeedleDesc = { |
| 868 | "Utf8CaseInsensitiveNeedle", 0, 0, 0, 0, utf8NeedleClass, napi_default, 0}; |
| 869 | |
| 870 | // Export the `capabilities` string for debugging |
| 871 | napi_value caps_str_value; |
| 872 | const char *caps_cstr = (const char *)sz_capabilities_to_string(sz_capabilities()); |
| 873 | napi_create_string_utf8(env, caps_cstr, NAPI_AUTO_LENGTH, &caps_str_value); |
| 874 | napi_property_descriptor capabilitiesDesc = {"capabilities", 0, 0, 0, 0, caps_str_value, napi_default, 0}; |
nothing calls this directly
no test coverage detected
searching dependent graphs…