Comparing version 2.9.1 to 2.10.0
@@ -19,2 +19,3 @@ interface Language { | ||
readonly httpHint?: string; | ||
readonly bestEffort?: boolean; | ||
} | ||
@@ -21,0 +22,0 @@ interface DetectLanguage { |
@@ -30,3 +30,4 @@ const _ = require('underscore'); | ||
tldHint : '', | ||
httpHint : '' | ||
httpHint : '', | ||
bestEffort : false | ||
}; | ||
@@ -38,2 +39,5 @@ options = _.defaults({}, options, defaults); | ||
} | ||
if (!_.isBoolean(options.bestEffort)) { | ||
throw new Error('Invalid bestEffort value'); | ||
} | ||
if (!_.isString(options.languageHint)) { | ||
@@ -69,3 +73,4 @@ throw new Error('Invalid languageHint'); | ||
options.tldHint, | ||
options.httpHint | ||
options.httpHint, | ||
options.bestEffort | ||
); | ||
@@ -72,0 +77,0 @@ |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "2.9.1", | ||
"version": "2.10.0", | ||
"main": "./index.js", | ||
@@ -14,0 +14,0 @@ "types": "./index.d.ts", |
@@ -94,2 +94,7 @@ # node-cld | ||
#### bestEffort | ||
Set to true to give best-effort answer, instead of UNKNOWN_LANGUAGE. May be useful for | ||
short text if the caller prefers an approximate answer over none. | ||
## Warning | ||
@@ -96,0 +101,0 @@ Once the module has been installed, the underlying C sources will remain in the ```deps/cld``` folder and continue to occupy considerable space. This is because they will be required if you ever need to run `npm rebuild`. If you are under severe constraints you can delete this folder and reclam >100M |
@@ -14,3 +14,3 @@ #!/usr/bin/env node | ||
const result = await cld.detct(val.sample); | ||
const result = await cld.detect(val.sample); | ||
assert.equal(_.isArray(result.languages), true); | ||
@@ -24,2 +24,16 @@ assert.equal(result.languages.length > 0, true); | ||
async function runBestEffortTests() { | ||
for (const val of data.all) { | ||
if (!val.testOnWindows) { | ||
return; | ||
} | ||
const result = await cld.detect(val.sample, {bestEffort: true}); | ||
assert.equal(_.isArray(result.languages), true); | ||
assert.equal(result.languages.length > 0, true); | ||
assert.equal(val.name, result.languages[0].name); | ||
} | ||
} | ||
async function runChunkTests() { | ||
@@ -170,2 +184,3 @@ for (const val of data.all) { | ||
await runCoreTests(detected); | ||
await runBestEffortTests(); | ||
await runChunkTests(); | ||
@@ -172,0 +187,0 @@ await runEncodingHintTests(); |
Sorry, the diff of this file is not supported yet
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
108740085
581
107