shevchenkoartem / t-literator-js Goto Github PK
View Code? Open in Web Editor NEW(DEVELOPMENT IN PROGRESS)
License: MIT License
(DEVELOPMENT IN PROGRESS)
License: MIT License
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
Use a more efficient data structure for storing the mapping of source alphabet letters to their transliterated alphabet letters. For example, you can use a Map object instead of a plain object to improve the performance of lookups. Here's an example:
const result = new Map();
result.set('Є є', 'Je je, ie');
let json = '{"key1":"value1","key2":"value2"}'; // your JSON string
let obj = JSON.parse(json); // convert JSON string to JavaScript object
let map = new Map(Object.entries(obj)); // convert object to Map
Use a more efficient algorithm for generating the mapping of source alphabet letters to their transliterated alphabet letters. For example, you can use a trie data structure to store the mapping and perform lookups more efficiently. Here's an example:
class TrieNode {
constructor() {
this.children = new Map();
this.value = null;
}
}
const root = new TrieNode();
root.children.set('Є', new TrieNode());
root.children.get('Є').value = 'Je je, ie';
Also, transform cache into map
const cache = new Map();
function getConfigTransliterationInfo(ignorePositionalCases, ignoreSofteningCases) {
const key = `${ignorePositionalCases}-${ignoreSofteningCases}`;
if (cache.has(key)) {
return cache.get(key);
}
// compute the result
const result = {};
// ...
cache.set(key, result);
return result;
}
JavaScript and Node.js actually operate in a single-threaded mode, which means they don't support traditional multithreading like languages such as Java or C++. However, there are various ways to work around this limitation.
Asynchrony: JavaScript utilizes asynchronous programming to achieve multitasking. Components like Promises, async/await, or callback functions allow you to perform tasks "in the background" while the main thread continues executing other tasks.
Web Workers (for browsers): Web Workers enable you to execute JavaScript code in a separate thread, independent of the main execution thread. This can be useful for performing heavy computations without blocking the UI.
Worker Threads (for Node.js): Starting from Node.js version 10.5.0, Worker Threads are introduced as an experimental feature that allows you to execute code in separate threads.
Child Processes (for Node.js): Node.js allows you to create child processes, enabling you to execute code in parallel, though it comes with some overhead in creating a new process.
These solutions address the issue of multithreading at the application level, but they do not provide traditional multithreaded programming at the language level. Note that asynchronous programming may have its own challenges and complexities, and you should understand how it works before using these techniques.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.