From b04f7ef8ef785dd81e6b8509b34accf5eb2e419a Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Thu, 31 Jan 2019 10:38:17 -0800 Subject: [PATCH] feat(languagecode): ensure unknown identifier match --- src/cldLoader.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cldLoader.ts b/src/cldLoader.ts index 6be75ca..07946ae 100644 --- a/src/cldLoader.ts +++ b/src/cldLoader.ts @@ -49,6 +49,11 @@ export const cldLoader = (asmModule: CldAsmModule, _environment?: ENVIRONMENT): languageResultStructSize }); + // both identifier should match all time, check when initialize binary + if (unknownIdentifier !== LanguageCode.UNKNOWN) { + throw new Error(`cld3 binary unknownIdentifier constant does not match to LanguageCode enum`); + } + /** * Wrapper function to read LanguageResult struct from pointer. * After interop, pointer will be freed. @@ -80,7 +85,6 @@ export const cldLoader = (asmModule: CldAsmModule, _environment?: ENVIRONMENT): const cldPtr = cldInterface.create(minBytes, maxBytes); return { - unknownIdentifier, findLanguage: (text: string) => { // `findLanguage` requires caller must allocate memory for return value. const resultPtr = _malloc(languageResultStructSize);