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

@ewb/translate

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ewb/translate - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0

5

lib/Branch.d.ts

@@ -10,2 +10,6 @@ import Empty from './Empty';

}
export interface TranslationUsage {
file: string;
stack: string;
}
export default class Branch extends ApiBranch {

@@ -16,2 +20,3 @@ level: number;

isWord: boolean;
usageStack: TranslationUsage[];
constructor(level: number, word: string, sentence?: boolean, translations?: Translations, apiID?: string);

@@ -18,0 +23,0 @@ add(newWord: string, translations?: Translations, apiID?: string): boolean;

@@ -7,2 +7,4 @@ "use strict";

const ApiBranch_1 = require("./ApiBranch");
const FILTER_STACK_PATHS = /(Branch|Tree|Translate)\./;
const FILTER_STACK_TRANS = /Translate._branch/;
class Branch extends ApiBranch_1.default {

@@ -15,2 +17,3 @@ constructor(level, word, sentence = false, translations = {}, apiID = '') {

this.isWord = false;
this.usageStack = [];
const char = this.getNextCharacter(word);

@@ -50,2 +53,16 @@ if (char) {

if (this.matchWord(word)) {
const error = new Error();
if (error.stack) {
const pathArr = error.stack.split('\n');
const filterPaths = pathArr.filter(x => !x.match(FILTER_STACK_PATHS));
const paths = filterPaths.slice(1).map(x => x.split('at ')[1] || '');
const file = paths[0].split(' ')[0];
const isTranslations = !pathArr.some(x => x.match(FILTER_STACK_TRANS));
if (isTranslations && this.usageStack.every(x => x.file !== file)) {
this.usageStack.push({
file,
stack: filterPaths.join('\n')
});
}
}
return this.isWord ? this : new Empty_1.default(this, word, this.sentence);

@@ -52,0 +69,0 @@ }

5

lib/index.d.ts
import Tree, { WordTranslations, TreeOptions } from './Tree';
import Empty from './Empty';
import Branch, { Translations, BranchObject } from './Branch';
import Branch, { Translations, TranslationUsage, BranchObject } from './Branch';
import { ISO_639_1 } from './utils/iso_639_1';

@@ -40,2 +40,3 @@ import { TranslationApi } from './TranslationApi';

exportTexts(): WordTranslations;
exportBranches(): Branch[];
getWord(word: string): Branch | null;

@@ -49,2 +50,2 @@ getText(text: string): Branch | null;

}
export { Tree, Empty, Branch, Translate, TranslateOptions, WordTranslations, TreeOptions, Translations, BranchObject, Variables, TextOptions, ISO_639_1, TranslationApi };
export { Tree, Empty, Branch, Translate, TranslateOptions, WordTranslations, TreeOptions, Translations, BranchObject, Variables, TextOptions, ISO_639_1, TranslationApi, TranslationUsage };

6

lib/index.js

@@ -72,11 +72,11 @@ "use strict";

}
// todo: Create test
exportBranches() {
return [...this.tree.suggestions(false), ...this.tree.suggestions(true)];
}
getWord(word) {
return this.getBranch(word);
}
// todo: Create test
getText(text) {
return this.getBranch(text, true);
}
// todo: Create test
getBranch(wordOrText, isText = false) {

@@ -83,0 +83,0 @@ return this._branch(wordOrText, isText);

{
"name": "@ewb/translate",
"version": "1.4.1",
"version": "1.5.0",
"description": "Translate as you create your app. Saves the words and text in a tree structure for fast and easy lookup.",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -216,2 +216,3 @@ # Translate library

suggestions(): Branch[];
exportBranches(): Branch[];
exportWords(): WordTranslation[];

@@ -218,0 +219,0 @@ exportTexts(): WordTranslation[];

Sorry, the diff of this file is not supported yet

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