Comparing version 3.0.0 to 3.1.0
@@ -0,1 +1,11 @@ | ||
<a name="3.1.0"></a> | ||
# [3.1.0](https://github.com/kwonoj/cld3-asm/compare/v3.0.0...v3.1.0) (2019-07-11) | ||
### Features | ||
* **languageresult:** include spaninfo array ([d9f716c](https://github.com/kwonoj/cld3-asm/commit/d9f716c)) | ||
<a name="3.0.0"></a> | ||
@@ -2,0 +12,0 @@ # [3.0.0](https://github.com/kwonoj/cld3-asm/compare/v2.0.1...v3.0.0) (2019-06-13) |
@@ -49,2 +49,22 @@ "use strict"; | ||
/** | ||
* Wrapper function to read SpanInfo** array from pointer. | ||
* After interop, pointer will be freed. | ||
*/ | ||
const volatileReadSpanInfoArray = (arrayPtr, size) => { | ||
const ret = Array.from(new Array(size)).map((_, idx) => { | ||
const spanInfoPtr = getValue(arrayPtr + PTR_SIZE * idx, '*'); | ||
const range = { | ||
start_index: getValue(spanInfoPtr + PTR_SIZE * 0, 'i8'), | ||
end_index: getValue(spanInfoPtr + PTR_SIZE * 1, 'i8'), | ||
probability: getValue(spanInfoPtr + PTR_SIZE * 2, 'float') | ||
}; | ||
//free each individual SpanInfo* struct | ||
_free(spanInfoPtr); | ||
return range; | ||
}); | ||
//free SpanInfo** array | ||
_free(arrayPtr); | ||
return ret; | ||
}; | ||
/** | ||
* Wrapper function to read LanguageResult struct from pointer. | ||
@@ -58,2 +78,5 @@ * After interop, pointer will be freed. | ||
const languageStringPtr = getValue(structPtr + PTR_SIZE * 0, '*'); | ||
// get ptr to array of byte range with its size | ||
const byteRangesSize = getValue(structPtr + PTR_SIZE * 4, 'i8'); | ||
const byteRangesArrayPtr = getValue(structPtr + PTR_SIZE * 5, '*'); | ||
// be careful to match order of properties to match pointer to struct field. | ||
@@ -64,3 +87,4 @@ const ret = { | ||
is_reliable: !!getValue(structPtr + PTR_SIZE * 2, 'i8'), | ||
proportion: getValue(structPtr + PTR_SIZE * 3, 'float') | ||
proportion: getValue(structPtr + PTR_SIZE * 3, 'float'), | ||
byte_ranges: volatileReadSpanInfoArray(byteRangesArrayPtr, byteRangesSize) | ||
}; | ||
@@ -67,0 +91,0 @@ //free char* for language string |
@@ -47,2 +47,22 @@ import { log } from './util/logger'; | ||
/** | ||
* Wrapper function to read SpanInfo** array from pointer. | ||
* After interop, pointer will be freed. | ||
*/ | ||
const volatileReadSpanInfoArray = (arrayPtr, size) => { | ||
const ret = Array.from(new Array(size)).map((_, idx) => { | ||
const spanInfoPtr = getValue(arrayPtr + PTR_SIZE * idx, '*'); | ||
const range = { | ||
start_index: getValue(spanInfoPtr + PTR_SIZE * 0, 'i8'), | ||
end_index: getValue(spanInfoPtr + PTR_SIZE * 1, 'i8'), | ||
probability: getValue(spanInfoPtr + PTR_SIZE * 2, 'float') | ||
}; | ||
//free each individual SpanInfo* struct | ||
_free(spanInfoPtr); | ||
return range; | ||
}); | ||
//free SpanInfo** array | ||
_free(arrayPtr); | ||
return ret; | ||
}; | ||
/** | ||
* Wrapper function to read LanguageResult struct from pointer. | ||
@@ -56,2 +76,5 @@ * After interop, pointer will be freed. | ||
const languageStringPtr = getValue(structPtr + PTR_SIZE * 0, '*'); | ||
// get ptr to array of byte range with its size | ||
const byteRangesSize = getValue(structPtr + PTR_SIZE * 4, 'i8'); | ||
const byteRangesArrayPtr = getValue(structPtr + PTR_SIZE * 5, '*'); | ||
// be careful to match order of properties to match pointer to struct field. | ||
@@ -62,3 +85,4 @@ const ret = { | ||
is_reliable: !!getValue(structPtr + PTR_SIZE * 2, 'i8'), | ||
proportion: getValue(structPtr + PTR_SIZE * 3, 'float') | ||
proportion: getValue(structPtr + PTR_SIZE * 3, 'float'), | ||
byte_ranges: volatileReadSpanInfoArray(byteRangesArrayPtr, byteRangesSize) | ||
}; | ||
@@ -65,0 +89,0 @@ //free char* for language string |
import { BaseAsmModule } from 'emscripten-wasm-loader'; | ||
import { LanguageCode } from './languageCode'; | ||
/** | ||
* Holds probability that Span, specified by start/end indices, is a given | ||
* language. The langauge is not stored here; it can be found in Result, which | ||
* holds a vector of SpanInfo. | ||
*/ | ||
export interface SpanInfo { | ||
start_index: number; | ||
end_index: number; | ||
probability: number; | ||
} | ||
export interface LanguageResult { | ||
@@ -21,2 +31,6 @@ /** | ||
proportion: number; | ||
/** | ||
* Specifies the byte ranges that |language| applies to. | ||
*/ | ||
byte_ranges: Array<SpanInfo>; | ||
} | ||
@@ -23,0 +37,0 @@ /** |
export { loadModule } from './loadModule'; | ||
export { log, enableLogger } from './util/logger'; | ||
export { LanguageIdentifier, CldFactory } from './cldFactory'; | ||
export { LanguageResult } from './cldAsmModule'; | ||
export { LanguageResult, SpanInfo } from './cldAsmModule'; | ||
export { LanguageCode } from './languageCode'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "cld3-asm", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "WebAssembly based Javascript bindings for google compact language detector 3", | ||
@@ -19,3 +19,3 @@ "main": "./dist/cjs/index.js", | ||
}, | ||
"cld3-version": "ade8819-190613" | ||
"cld3-version": "1b9640d-190711" | ||
}, | ||
@@ -63,5 +63,5 @@ "lint-staged": { | ||
"@types/chai": "^4.1.7", | ||
"@types/jest": "^24.0.14", | ||
"@types/lodash": "^4.14.134", | ||
"@types/node": "^12.0.8", | ||
"@types/jest": "^24.0.15", | ||
"@types/lodash": "^4.14.136", | ||
"@types/node": "^12.6.2", | ||
"@types/shelljs": "^0.8.5", | ||
@@ -73,7 +73,7 @@ "@types/utf8": "^2.1.6", | ||
"cz-conventional-changelog": "2.1.0", | ||
"husky": "^2.4.1", | ||
"husky": "^3.0.0", | ||
"jest": "^24.8.0", | ||
"jest-spin-reporter": "^1.0.2", | ||
"lint-staged": "^8.2.0", | ||
"lodash": "^4.17.11", | ||
"lint-staged": "^9.2.0", | ||
"lodash": "^4.17.14", | ||
"npm-run-all": "^4.1.5", | ||
@@ -84,6 +84,6 @@ "prettier": "^1.18.2", | ||
"ts-jest": "^24.0.2", | ||
"ts-node": "^8.2.0", | ||
"tslint": "^5.17.0", | ||
"ts-node": "^8.3.0", | ||
"tslint": "^5.18.0", | ||
"tslint-no-unused-expression-chai": "^0.1.4", | ||
"typescript": "^3.5.1", | ||
"typescript": "^3.5.3", | ||
"utf8": "^3.0.0" | ||
@@ -90,0 +90,0 @@ }, |
import { BaseAsmModule } from 'emscripten-wasm-loader'; | ||
import { LanguageCode } from './languageCode'; | ||
/** | ||
* Holds probability that Span, specified by start/end indices, is a given | ||
* language. The langauge is not stored here; it can be found in Result, which | ||
* holds a vector of SpanInfo. | ||
*/ | ||
export interface SpanInfo { | ||
start_index: number; | ||
end_index: number; | ||
probability: number; | ||
} | ||
export interface LanguageResult { | ||
@@ -22,2 +33,6 @@ /** | ||
proportion: number; | ||
/** | ||
* Specifies the byte ranges that |language| applies to. | ||
*/ | ||
byte_ranges: Array<SpanInfo>; | ||
} | ||
@@ -24,0 +39,0 @@ |
@@ -57,2 +57,25 @@ import { CldAsmModule, LanguageResult } from './cldAsmModule'; | ||
/** | ||
* Wrapper function to read SpanInfo** array from pointer. | ||
* After interop, pointer will be freed. | ||
*/ | ||
const volatileReadSpanInfoArray = (arrayPtr: number, size: number) => { | ||
const ret = Array.from(new Array(size)).map((_, idx) => { | ||
const spanInfoPtr = getValue(arrayPtr + PTR_SIZE * idx, '*'); | ||
const range = { | ||
start_index: getValue(spanInfoPtr + PTR_SIZE * 0, 'i8'), | ||
end_index: getValue(spanInfoPtr + PTR_SIZE * 1, 'i8'), | ||
probability: getValue(spanInfoPtr + PTR_SIZE * 2, 'float') | ||
}; | ||
//free each individual SpanInfo* struct | ||
_free(spanInfoPtr); | ||
return range; | ||
}); | ||
//free SpanInfo** array | ||
_free(arrayPtr); | ||
return ret; | ||
}; | ||
/** | ||
* Wrapper function to read LanguageResult struct from pointer. | ||
@@ -67,2 +90,6 @@ * After interop, pointer will be freed. | ||
// get ptr to array of byte range with its size | ||
const byteRangesSize = getValue(structPtr + PTR_SIZE * 4, 'i8'); | ||
const byteRangesArrayPtr = getValue(structPtr + PTR_SIZE * 5, '*'); | ||
// be careful to match order of properties to match pointer to struct field. | ||
@@ -73,3 +100,4 @@ const ret: LanguageResult = { | ||
is_reliable: !!getValue(structPtr + PTR_SIZE * 2, 'i8'), | ||
proportion: getValue(structPtr + PTR_SIZE * 3, 'float') | ||
proportion: getValue(structPtr + PTR_SIZE * 3, 'float'), | ||
byte_ranges: volatileReadSpanInfoArray(byteRangesArrayPtr, byteRangesSize) | ||
}; | ||
@@ -76,0 +104,0 @@ |
export { loadModule } from './loadModule'; | ||
export { log, enableLogger } from './util/logger'; | ||
export { LanguageIdentifier, CldFactory } from './cldFactory'; | ||
export { LanguageResult } from './cldAsmModule'; | ||
export { LanguageResult, SpanInfo } from './cldAsmModule'; | ||
export { LanguageCode } from './languageCode'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
6611712
26310
0