Coder Social home page Coder Social logo

t-literator-js's People

Contributors

actions-user avatar shevchenkoartem avatar

Watchers

 avatar

Forkers

kokokostya

t-literator-js's Issues

Use Map() instead of common objects for configs and alphabet results

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';

Move everything config-related to config and add cashing for each function

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;
}

Try to multithread transliteration process

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.