Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fanyi.baidu.com

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fanyi.baidu.com - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

5

dist/fanyi.es.js

@@ -61,4 +61,5 @@ import axios from 'axios';

};
function setAuth(auth) {
store.auth = auth;
function setAuth(AppID, AppSecret) {
store.auth.AppID = AppID;
store.auth.AppSecret = AppSecret;
}

@@ -65,0 +66,0 @@ function generateSign(keyworld, salt) {

2

dist/fanyi.es.min.js

@@ -15,3 +15,3 @@ import t from"axios";import n from"md5";

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function r(t,n,r,e){return new(r||(r=Promise))((function(a,o){function i(t){try{c(e.next(t))}catch(t){o(t)}}function u(t){try{c(e.throw(t))}catch(t){o(t)}}function c(t){var n;t.done?a(t.value):(n=t.value,n instanceof r?n:new r((function(t){t(n)}))).then(i,u)}c((e=e.apply(t,n||[])).next())}))}function e(t,n){var r,e,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,e&&(a=2&o[0]?e.return:o[0]?e.throw||((a=e.return)&&a.call(e),0):e.next)&&!(a=a.call(e,o[1])).done)return a;switch(e=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,e=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=n.call(t,i)}catch(t){o=[6,t],e=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}var a={auth:{},URL:"https://api.fanyi.baidu.com/api/trans/vip/translate"};function o(t){a.auth=t}export default function(o,i){return void 0===i&&(i="en"),r(this,void 0,void 0,(function(){var r;return e(this,(function(e){return Array.isArray(o)&&(o=o.join("\n")),(r={q:o,from:"auto",to:i,appid:a.auth.AppID,salt:Date.now(),sign:""}).sign=function(t,r){if(!a.auth.AppID||!a.auth.AppSecret)throw new Error('Generate sign error, use "setAuth({ AppID, Secret })" to authorize.');return n(a.auth.AppID+t+r+a.auth.AppSecret)}(o,r.salt),[2,t.get(a.URL,{params:r}).then((function(t){return t.data.trans_result.map((function(t){return{original:t.src,translated:t.dst}}))}))]}))}))}export{o as setAuth};
***************************************************************************** */function r(t,n,r,e){return new(r||(r=Promise))((function(a,o){function u(t){try{c(e.next(t))}catch(t){o(t)}}function i(t){try{c(e.throw(t))}catch(t){o(t)}}function c(t){var n;t.done?a(t.value):(n=t.value,n instanceof r?n:new r((function(t){t(n)}))).then(u,i)}c((e=e.apply(t,n||[])).next())}))}function e(t,n){var r,e,a,o,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,e&&(a=2&o[0]?e.return:o[0]?e.throw||((a=e.return)&&a.call(e),0):e.next)&&!(a=a.call(e,o[1])).done)return a;switch(e=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,e=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(a=u.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){u.label=o[1];break}if(6===o[0]&&u.label<a[1]){u.label=a[1],a=o;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(o);break}a[2]&&u.ops.pop(),u.trys.pop();continue}o=n.call(t,u)}catch(t){o=[6,t],e=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}}var a={auth:{},URL:"https://api.fanyi.baidu.com/api/trans/vip/translate"};function o(t,n){a.auth.AppID=t,a.auth.AppSecret=n}export default function(o,u){return void 0===u&&(u="en"),r(this,void 0,void 0,(function(){var r;return e(this,(function(e){return Array.isArray(o)&&(o=o.join("\n")),(r={q:o,from:"auto",to:u,appid:a.auth.AppID,salt:Date.now(),sign:""}).sign=function(t,r){if(!a.auth.AppID||!a.auth.AppSecret)throw new Error('Generate sign error, use "setAuth({ AppID, Secret })" to authorize.');return n(a.auth.AppID+t+r+a.auth.AppSecret)}(o,r.salt),[2,t.get(a.URL,{params:r}).then((function(t){return t.data.trans_result.map((function(t){return{original:t.src,translated:t.dst}}))}))]}))}))}export{o as setAuth};
//# sourceMappingURL=fanyi.es.min.js.map

@@ -69,4 +69,5 @@ (function (global, factory) {

};
function setAuth(auth) {
store.auth = auth;
function setAuth(AppID, AppSecret) {
store.auth.AppID = AppID;
store.auth.AppSecret = AppSecret;
}

@@ -73,0 +74,0 @@ function generateSign(keyworld, salt) {

@@ -16,3 +16,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("axios"),require("md5")):"function"==typeof define&&define.amd?define(["exports","axios","md5"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).translate={},t.Axios,t.MD5)}(this,(function(t,e,n){"use strict";function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=r(e),a=r(n);

***************************************************************************** */
function u(t,e,n,r){return new(n||(n=Promise))((function(o,a){function u(t){try{f(r.next(t))}catch(t){a(t)}}function i(t){try{f(r.throw(t))}catch(t){a(t)}}function f(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,i)}f((r=r.apply(t,e||[])).next())}))}function i(t,e){var n,r,o,a,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=e.call(t,u)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}var f={auth:{},URL:"https://api.fanyi.baidu.com/api/trans/vip/translate"};t.default=function(t,e){return void 0===e&&(e="en"),u(this,void 0,void 0,(function(){var n;return i(this,(function(r){return Array.isArray(t)&&(t=t.join("\n")),(n={q:t,from:"auto",to:e,appid:f.auth.AppID,salt:Date.now(),sign:""}).sign=function(t,e){if(!f.auth.AppID||!f.auth.AppSecret)throw new Error('Generate sign error, use "setAuth({ AppID, Secret })" to authorize.');return a.default(f.auth.AppID+t+e+f.auth.AppSecret)}(t,n.salt),[2,o.default.get(f.URL,{params:n}).then((function(t){return t.data.trans_result.map((function(t){return{original:t.src,translated:t.dst}}))}))]}))}))},t.setAuth=function(t){f.auth=t},Object.defineProperty(t,"__esModule",{value:!0})}));
function u(t,e,n,r){return new(n||(n=Promise))((function(o,a){function u(t){try{f(r.next(t))}catch(t){a(t)}}function i(t){try{f(r.throw(t))}catch(t){a(t)}}function f(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,i)}f((r=r.apply(t,e||[])).next())}))}function i(t,e){var n,r,o,a,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=e.call(t,u)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}var f={auth:{},URL:"https://api.fanyi.baidu.com/api/trans/vip/translate"};t.default=function(t,e){return void 0===e&&(e="en"),u(this,void 0,void 0,(function(){var n;return i(this,(function(r){return Array.isArray(t)&&(t=t.join("\n")),(n={q:t,from:"auto",to:e,appid:f.auth.AppID,salt:Date.now(),sign:""}).sign=function(t,e){if(!f.auth.AppID||!f.auth.AppSecret)throw new Error('Generate sign error, use "setAuth({ AppID, Secret })" to authorize.');return a.default(f.auth.AppID+t+e+f.auth.AppSecret)}(t,n.salt),[2,o.default.get(f.URL,{params:n}).then((function(t){return t.data.trans_result.map((function(t){return{original:t.src,translated:t.dst}}))}))]}))}))},t.setAuth=function(t,e){f.auth.AppID=t,f.auth.AppSecret=e},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=fanyi.min.js.map
{
"name": "fanyi.baidu.com",
"moduleName": "translate",
"version": "1.1.0",
"version": "1.1.1",
"description": "fanyi.baidu.com api",
"main": "dist/translate.js",
"module": "dist/translate.es.js",
"main": "dist/fanyi.js",
"module": "dist/fanyi.es.js",
"types": "types/index.d.ts",

@@ -23,2 +23,7 @@ "scripts": {

"license": "MIT",
"keywords": [
"translate",
"fanyi",
"fayi.baidu.com"
],
"devDependencies": {

@@ -25,0 +30,0 @@ "@babel/core": "^7.12.10",

@@ -33,2 +33,6 @@ # fanyi.baidu.com

translate(keyworld: string | string[], to = 'en'): Promise<TRANSLATE.Result[]>
```
```
## Language List
[Language List](http://api.fanyi.baidu.com/doc/21)

@@ -11,4 +11,5 @@ import md5 from 'md5'

export function setAuth(auth: TRANSLATE.Auth) {
store.auth = auth
export function setAuth(AppID: string, AppSecret: string) {
store.auth.AppID = AppID
store.auth.AppSecret = AppSecret
}

@@ -15,0 +16,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc