New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

alfred-polyglot

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alfred-polyglot - npm Package Compare versions

Comparing version 1.1.5 to 1.2.0

20

lib/cmd/translate.js

@@ -6,4 +6,7 @@ const alfy = require('alfy')

const outputLanguages = require('../output/languages')
const {CachedList} = require('../util')
module.exports = async input => {
const history = new CachedList('to-lang-history')
const translateCommand = async input => {
const originalWords = input.trim().split(' ')

@@ -82,5 +85,16 @@ const words = originalWords.slice(0)

if (res.from.language.iso.toLowerCase() === to) {
const lastUniqueToLanguage = history.all.reverse()
.find(l => l !== to)
const newToLanguage = lastUniqueToLanguage || 'en'
return translateCommand(`to ${newToLanguage} ` + input)
}
history.append(to)
const messages = []
let fromLangMsg = languages[res.from.language.iso]
let fromLangMsg = languages[res.from.language.iso.toLowerCase()]
const toLangMsg = languages[to]

@@ -138,2 +152,4 @@

module.exports = translateCommand
module.exports.meta = {

@@ -140,0 +156,0 @@ name: 'Translate text',

@@ -0,1 +1,2 @@

const alfy = require('alfy')
const languages = require('google-translate-api/languages')

@@ -14,1 +15,22 @@

.map(x => x.toLowerCase())
module.exports.CachedList = class CachedList {
constructor(key) {
this.key = key
if (!alfy.cache.has(this.key)) {
alfy.cache.set(this.key, [])
}
}
get all() {
return alfy.cache.get(this.key)
}
append(item) {
const old = alfy.cache.get(this.key)
alfy.cache.set(this.key, old.concat(item))
return this
}
}

2

package.json
{
"name": "alfred-polyglot",
"version": "1.1.5",
"version": "1.2.0",
"description": "Translate text with ease using Google Translate",

@@ -5,0 +5,0 @@ "license": "MIT",

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