Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
preslovljivac
Advanced tools
A very simple package for changing characters from latin to cyrillic (Serbian) and vice versa, depending on which one is more abundant in text (it changes to the less abundant one).
example:
const preslovljivac = require("preslovljivac"); //loading the package
console.log(preslovljivac.preslovi("text",'','n')); /*using it to write "text" to console in cyrillic, the output will be "текст" */
console.log(preslovljivac.preslovi("текст",'','Cyrl')); //output will be "text"
You can also give it a second parameter, in case you want something to remain unchanged.
For example, i want 'Microsoft' and 'Google' to remain the same:
const preslovljivac = require("preslovljivac");
console.log(preslovljivac.preslovi("some text, Google Microsoft", "Google, Microsoft",'a'));
//the expected output is "соме текст, Google Microsoft"
Do note though that you need to write it as a string, with each entry divided by commas (,).
You can also pass a third parameter.
If the third parameter is a 'falsy' value, it will use the built-in auto-detector.
It only counts through the first 512 characters, so if you have some massive strings it won't count through the entire string, so it may not be 100% accurate if both are abundant throughout the text. It will convert every character no matter the length of the string, though.
If you want to avoid this, you can give it a parameter 'Cyrl' for cyrillic, a non-empty string for latin.
For example:
const preslovljivac = require("preslovljivac");
console.log(preslovljivac.preslovi("text in latin",'','t')); //i passed t as the third parameter so that it isn't a 'falsy' value
//expected output is "текст ин латин"
console.log(preslovljivac.preslovi("текст на ћирилици",'','Cyrl')); /*i passed 'Cyrl' as the third parameter, so now it will treat it as cyrillic text and the output will be "tekst na ćirilici"*/
//alternatively you can just let it use the auto-detect
console.log(preslovljivac.preslovi("text text and more text")); //the output here will be "текст текст анд море текст"
./tests/main.js is a test file used with ava. Feel free to configure it as you wish.
Note: A few letters that exist in English latin don't exist in Serbian cyrillic, those are:
Q (translated as "ку"),
X (translated as "кс"),
Y (translated as "иј"),
W (translated as "в").
If you have any suggestions, feel free to send them to me. I'm always open for improvement.
FAQs
latin to cyrillic
The npm package preslovljivac receives a total of 9 weekly downloads. As such, preslovljivac popularity was classified as not popular.
We found that preslovljivac demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.