Skip to content

Commit

Permalink
release: v4.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
plainheart committed May 23, 2024
1 parent 615d09a commit 5849e65
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ export interface TranslationResult {
/**
* The detected language code of original text
*/
from: string;
from?: string;
/**
* The language code of translated text
*/
to: string;
/**
* The score of language detection
*/
score: number;
score?: number;
};
/**
* The original response from Bing translator
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bing-translate-api",
"version": "4.0.1",
"version": "4.0.2",
"description": "A simple and free API for Bing & Microsoft Translator for Node.js",
"main": "src/index.js",
"typings": "index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions scripts/index.tpl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ export interface TranslationResult {
/**
* The detected language code of original text
*/
from: string;
from?: string;
/**
* The language code of translated text
*/
to: string;
/**
* The score of language detection
*/
score: number;
score?: number;
};
/**
* The original response from Bing translator
Expand Down
10 changes: 10 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
const { translate } = require('../src/index')
const { maxTextLen, maxCorrectableTextLen, maxEPTTextLen, maxTextLenCN } = require('../src/config.json')

/**
* @param {import('..').TranslationResult} res
*/
function printRes(res) {
console.log(res.text, '---->', res.translation, 'fromLang', res.language.from)
console.log()
}

/**
* @param {import('..').TranslationResult} res
*/
function printCorrectRes(res) {
console.log(res.text, '---->', res.correctedText)
console.log()
}

/**
* @param {Error} e
* @param {boolean} [notExit]
*/
function onErr(e, notExit) {
console.error(e)
console.log()
Expand Down

0 comments on commit 5849e65

Please sign in to comment.