Skip to content

Commit b04f7ef

Browse files
committed
feat(languagecode): ensure unknown identifier match
1 parent e65b7a9 commit b04f7ef

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/cldLoader.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export const cldLoader = (asmModule: CldAsmModule, _environment?: ENVIRONMENT):
4949
languageResultStructSize
5050
});
5151

52+
// both identifier should match all time, check when initialize binary
53+
if (unknownIdentifier !== LanguageCode.UNKNOWN) {
54+
throw new Error(`cld3 binary unknownIdentifier constant does not match to LanguageCode enum`);
55+
}
56+
5257
/**
5358
* Wrapper function to read LanguageResult struct from pointer.
5459
* After interop, pointer will be freed.
@@ -80,7 +85,6 @@ export const cldLoader = (asmModule: CldAsmModule, _environment?: ENVIRONMENT):
8085
const cldPtr = cldInterface.create(minBytes, maxBytes);
8186

8287
return {
83-
unknownIdentifier,
8488
findLanguage: (text: string) => {
8589
// `findLanguage` requires caller must allocate memory for return value.
8690
const resultPtr = _malloc(languageResultStructSize);

0 commit comments

Comments
 (0)