Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

cyrillic-latin-search

pavle-doby35MIT0.8.5TypeScript support: included

Cyrillic Latin Search is convenient for Cyrillic Latin search engines because you can write 'Celavica' ('Bald letters') 'c' for 'č', 's' for 'š', 'и' for 'й',...

cyrillic-latin-search, cyrillic-search, cyrillic, latin-search, latin, celavica-search, celavica, word, slav-search, slav, iso 9, iso9, find, contains, search, includes, indexOf, russian, serbian, ukrainian, русский, српски, українська, кириллица, ћирилица, кирилиця, латинский, латиница, латинська, поиск, петрага, пошук, ћелавица

readme

cyrillic-latin-search 🔤

Cyrillic Latin Search is convenient for Cyrillic Latin search engines because you can write "Celavica" ("Bald letters") "c" for "č", "s" for "š", "и" for "й",...

Supports ISO 9 standard

Examples

Latin Celavica includes
Niš Nis true
Ćao Cao true
Šišmiš Sismis true
čeljavo Celjavo false

Cyrillic Celavica includes
Нӣш Ниш true
үй үи true
Хороший Хорошии true
Добрий добрии false

The last ones are false because functions are Case Sensitive.

Installation

npm install cyrillic-latin-search
# or
yarn add cyrillic-latin-search

Usage

import { includes, indexOf, setDefaultAlphabet } from "cyrillic-latin-search";

// latin search
includes("Lep je grad, Niš", "Nis"); // => true
indexOf("Lep je grad, Niš", "Nis"); // => 13

// cyrillic search
includes("Привет мой друг", "мои", "cyrillic"); // => true
setDefaultAlphabet("cyrillic"); // you can set 'latin' or 'cyrillic'
indexOf("Привет мой друг", "мои"); // => 7

Documentation

Default alphabet is latin. But you can change that with function setDefaultAlphabet

Types

type Alphabet = "cyrillic" | "latin";

Functions

<summary>Description</summary>

Returns true if searchString appears as a substring in string str.

includes(str: string, searchString: string, alphabet?: Alphabet): boolean
<summary>Description</summary>

Returns the position of the first occurrence of a searchString or -1 if searchString is not occurring in string str.

indexOf(
  str: string,
  searchString: string,
  alphabet?: Alphabet,
  position?: number // start of the search (by default 0)
): number;
<summary>Description</summary>

Finding all the occurrences of an searchString in str and returning array of positions or empty array if it is not present.

allIndexOf(
  str: string,
  searchString: string,
  alphabet?: Alphabet,
  position?: number // start of the search (by default 0)
): number[]
<summary>Description</summary>

Sets defaultAlphabet witch is used by other functions. Valid values are: "cyrillic" or "latin".

setDefaultAlphabet(alphabet: Alphabet): void
<summary>Description</summary>

Gets defaultAlphabet witch is used by other functions. By default this will return "latin"

getDefaultAlphabet(): string
<summary>Description</summary>

Converts string str to Celavica depending on defaultAlphabet or passed argument alphabet.
(eg.)
// for alphabet = "latin"
Niš -> Nis,
// for alphabet = "cyrillic"
Хороший -> Хорошии

convertToCelavica(str: string, alphabet?: Alphabet): string
<summary>Description</summary>

Gets dictionary that is used for conversion from Cyrillic/Latin to Celavica based on alphabet.

getDict(alphabet?: Alphabet): Record<string, string>