Skip to content

Commit 5849e65

Browse files
committed
release: v4.0.2
1 parent 615d09a commit 5849e65

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ export interface TranslationResult {
2929
/**
3030
* The detected language code of original text
3131
*/
32-
from: string;
32+
from?: string;
3333
/**
3434
* The language code of translated text
3535
*/
3636
to: string;
3737
/**
3838
* The score of language detection
3939
*/
40-
score: number;
40+
score?: number;
4141
};
4242
/**
4343
* The original response from Bing translator

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bing-translate-api",
3-
"version": "4.0.1",
3+
"version": "4.0.2",
44
"description": "A simple and free API for Bing & Microsoft Translator for Node.js",
55
"main": "src/index.js",
66
"typings": "index.d.ts",

scripts/index.tpl.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ export interface TranslationResult {
2727
/**
2828
* The detected language code of original text
2929
*/
30-
from: string;
30+
from?: string;
3131
/**
3232
* The language code of translated text
3333
*/
3434
to: string;
3535
/**
3636
* The score of language detection
3737
*/
38-
score: number;
38+
score?: number;
3939
};
4040
/**
4141
* The original response from Bing translator

test/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
const { translate } = require('../src/index')
22
const { maxTextLen, maxCorrectableTextLen, maxEPTTextLen, maxTextLenCN } = require('../src/config.json')
33

4+
/**
5+
* @param {import('..').TranslationResult} res
6+
*/
47
function printRes(res) {
58
console.log(res.text, '---->', res.translation, 'fromLang', res.language.from)
69
console.log()
710
}
811

12+
/**
13+
* @param {import('..').TranslationResult} res
14+
*/
915
function printCorrectRes(res) {
1016
console.log(res.text, '---->', res.correctedText)
1117
console.log()
1218
}
1319

20+
/**
21+
* @param {Error} e
22+
* @param {boolean} [notExit]
23+
*/
1424
function onErr(e, notExit) {
1525
console.error(e)
1626
console.log()

0 commit comments

Comments
 (0)