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

google-translate-api-nodejs-client

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-translate-api-nodejs-client - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

23

google-translate-api-nodejs-client.js
var request = require('request'),
Logger = require('logb').getLogger(module.filename),
Entities = require('html-entities').AllHtmlEntities,
entities = new Entities();
entities = new Entities(),
RateLimiter = require('limiter').RateLimiter;

@@ -11,6 +12,19 @@

var GoogleTranslateApi = module.exports = function GoogleTranslateApi(options) {
// credentials
this.API_KEY = options.API_KEY;
this.URL = 'https://www.googleapis.com/language/translate/v2';
// throttling
this.limiter = new RateLimiter(100, 'second');
Logger.info('Using API_KEY', this.API_KEY);
};
GoogleTranslateApi.prototype.translate = function(opts, cb) {
var self = this;
self.limiter.removeTokens(1, function() {
self._translate(opts, cb);
});
}
GoogleTranslateApi.prototype.translate = function translate(opts, cb) {
GoogleTranslateApi.prototype._translate = function translate(opts, cb) {
var self = this;

@@ -41,2 +55,7 @@

if (!body.data || !body.data.translations) {
Logger.warn('response from Google Translate API returned weird body', body);
return cb(new Error('Weird response from Google Translate API'));
}
translation = body.data.translations[0].translatedText;

@@ -43,0 +62,0 @@ translation = entities.decode(translation);

9

package.json
{
"name": "google-translate-api-nodejs-client",
"version": "1.0.2",
"version": "1.0.3",
"description": "",

@@ -13,2 +13,3 @@ "main": "google-translate-api-nodejs-client.js",

"html-entities": "^1.1.2",
"limiter": "^1.0.5",
"logb": "0.0.2",

@@ -20,6 +21,6 @@ "request": "^2.53.0"

},
"repository":{
"type":"git",
"url":"git@github.com:bitliner/google-translate-api-nodejs-client.git"
"repository": {
"type": "git",
"url": "git@github.com:bitliner/google-translate-api-nodejs-client.git"
}
}
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