0.3.0 • Published 6 years ago

diacritics-transliterator v0.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

node-diacritics-transliterator

Build Status Test Coverage Greenkeeper

Diacritic transliteration tool using the diacritics.io API

Installation

$ npm install diacritics-transliterator

Module

The module exports an object with the following functions:

replace()

This function replaces a placeholder inside a string with an array of equivalent diacritics and their mappings. You can use it e.g. to create a regular expression.

Parameters:

input

Type: string

A string of JavaScript code.

options

Type: object
Optional: true

An object of options:

NameTypeDefaultDescription
placeholderstring'// <% diacritics %>'The placeholder that will be replaced with an array of equivalent diacritics and their mappings
typestring'const'The variable type
namestring'diacritics'The variable name

Example:

const Diacritic = require('diacritics-transliterator');

const testString = `
const x = "Diacritics will be inserted below";
// <% diacritics %>
`;

Diacritic.replace(testString).then(response => {
  console.log(response);
}, msg => {
  throw new Error(`Failed: ${msg}`);
});