has-cyr

Module that searches for cyrillic characters in the text. It can highlight each cyrillic character or group of characters, or just transliterate them.

Usage no npm install needed!

<script type="module">
  import hasCyr from 'https://cdn.skypack.dev/has-cyr';
</script>

README

Has Cyr

Module that searches for cyrillic characters in the text. It can highlight each cyrillic character or group of characters, or just transliterate them.

preview

Installation

npm install has-cyr

API

hasCyr(text[, preprocessor, translit])

text

Type: String

preprocessor

Type: Function
Function helps modify matches

translit

Type: Boolean
Default: false
Auto transliteration of cyrillic characters

Usage

const chalk = require('chalk');
const hasCyr = require('has-cyr');

function chalkHighlighter(str){
   return chalk.red.bold(str);
}

let text = 'Lогем iрsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod темроr incididunt ut labоге et dolore magna aliqua. Ut хуй ad minim veniam, quis nostrud ехегсitation ullamco laboris nisi ut aliquip eх ea соммоdo сопsequat. Duis aute irure dolor в reprehenderit in voluptate velit esse cillum dоlоre eu fugiat nulla pariatur. Ехсерtеr sint occaecat cupidatat поп proident, sunt in сиlра qui officia deserunt mollit anim id est laborum.';

let cyr = hasCyr(text, chalkHighlighter);
if(cyr){
   console.log(cyr);
}

As an additional feature it can transliterate matches.

let cyr = hasCyr(text, chalkHighlighter, true);

translit

Changelog

v1.0.4 (2018-11-20):

  • now consecutive cyrillic characters would be grouped together