├── Archive └── Release.zip ├── .travis.yml ├── COPYRIGHT.md ├── package.json ├── test └── test.js ├── README.md ├── LICENSE └── translit.js /Archive/Release.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xguest/iso_9_js/HEAD/Archive/Release.zip -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '0.12' 4 | 5 | before_install: 6 | - '[ "${TRAVIS_NODE_VERSION}" != "0.8" ] || npm install -g npm@1.4.28' 7 | - npm install -g npm@2.12 8 | 9 | after_success: 10 | - ./node_modules/.bin/jscoverage translit.js translit-cov.js 11 | - NPM_COV=1 ./node_modules/.bin/mocha test -R mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js 12 | -------------------------------------------------------------------------------- /COPYRIGHT.md: -------------------------------------------------------------------------------- 1 | **iso_9** - Forward and reverse transliteration according to ISO 9 or ISO 9: 1995 or GOST 7.79-2000 system of A and B. 2 | 3 | Copyright (C) 2015 XGuest 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "iso_9", 3 | "version": "1.0.4", 4 | "description": "Forward and reverse transliteration according to ISO 9 or ISO 9: 1995 or GOST 7.79-2000 system of A and B", 5 | "homepage": "https://github.com/xguest/iso_9_js/", 6 | "main": "translit.js", 7 | "author": { 8 | "name": "xguest", 9 | "email": "xguest@list.ru" 10 | }, 11 | "keywords": [ 12 | "javascript", 13 | "translit", 14 | "iso9", 15 | "ISO 9:1995", 16 | "GOST 7.79-2000" 17 | ], 18 | "bugs": { 19 | "url": "https://github.com/xguest/iso_9_js/issues" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "https://github.com/xguest/iso_9_js.git" 24 | }, 25 | "devDependencies": { 26 | "coveralls": "^2.11.9", 27 | "jscoverage": "^0.6.0", 28 | "mocha": "^2.4.5", 29 | "mocha-lcov-reporter": "1.2.0" 30 | }, 31 | "license": "GPL-3.0", 32 | "readmeFilename": "README.md", 33 | "scripts": { 34 | "test": "mocha --reporter spec --bail test/*.js", 35 | "test-cov": "jscoverage translit.js translit-cov.js &&set NPM_COV=1 &&mocha -R html-cov > coverage.html&&set NPM_COV=" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node; 2 | /* globals describe, it */ 3 | 'use strict'; 4 | // Module dependencies. 5 | var translit = process.env.NPM_COV ? 6 | require('../translit-cov') : 7 | require('../translit'), 8 | // End of dependencies. 9 | assert = require('assert'), phrase = [[], 10 | ['Диакритика', 11 | 'Съешь ещё этих мягких французских булок, да выпей же чаю!', 12 | 'Sʺešʹ eŝë ètih mâgkih francuzskih bulok, da vypej že čaû!'], 13 | ['Беларускую', 14 | 'З’ясі яшчэ гэтых мяккіх французскіх булак, ды выпі ж чаю!', 15 | 'Z\'yasi yashche` ge`ty`x myakkix franczuzskix bulak, dy` vy`pi zh chayu!'], 16 | ['Български ', 17 | 'Яжте повече от тези меки кифлички, но също така се пие чай!', 18 | 'YAzhte poveche ot tezi meki kiflichki, no sa`stho taka se pie chaj!'], 19 | ['Македонски', 20 | 'Јадат повеќе од овие меки францускиот ролни, па пијат чај!', 21 | 'Jadat povek`e od ovie meki franczuskiot rolni, pa pijat chaj!'], 22 | ['Русский ', // 'мірь', 'mi`r`' 23 | 'Съешь ещё этих мягких французских булок, да выпей же чаю!', 24 | 'S``esh` eshhyo e`tix myagkix franczuzskix bulok, da vy`pej zhe chayu!'], 25 | ['Українська', 26 | 'З’їж ще цих м’яких французьких булок, та випий же чаю!', 27 | 'Z\'yizh shhe czy`x m\'yaky`x franczuz`ky`x bulok, ta vy`py`j zhe chayu!']]; 28 | describe('Проверка translit', 29 | function() { 30 | var a = phrase.length, b = 1, c, d, e, f; 31 | for (; a > b; b++) { 32 | c = phrase[b][1]; e = translit(c, b); 33 | d = phrase[b][2]; f = translit(d, -1 * b); 34 | it(phrase[b][0] + ' ==> ' + translit(phrase[b][0], b), 35 | function() {assert.ok((c === f && e === d));}); 36 | } 37 | } 38 | ); 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iso_9 2 | [![Home][home-img]][home-url][![License][lic-img]][lic-url][![Downlod][down-img]][down-url][![NPM][npm-img]][npm-url][![Build][travis-img]][travis-url][![Climate][climate-img]][climate-url][![Coverage][Coverage-img]][Coverage-url][![Inline docs][docs-img]][docs-url][![Dependency Status][depe-img]][depe-url] 3 | ### **Forward and reverse transliteration according to ISO 9 or ISO 9: 1995 or GOST 7.79-2000 system of A and B** 4 | 5 | Read translit.js file header 6 | 7 | ## Usage 8 | 9 | ```javascript 10 | var translit = require('../translit'); 11 | function example() { 12 | var a, b = [ 13 | [], 14 | ["Диакритика", "Съешь ещё этих мягких французских булок, да выпей же чаю!"], 15 | ["Беларускую", "З'ясі яшчэ гэтых мяккіх французскіх булак, ды выпі ж чаю!"], 16 | ["Български", "Яжте повече от тези меки кифлички, но също така се пие чай!"], 17 | ["Македонски", "Јадат повеќе од овие меки францускиот ролни, па пијат чај!"], 18 | ["Русский", "Съешь ещё этих мягких французских булок, да выпей же чаю!"], 19 | ["Українська", "З'їж ще цих м'яких французьких булок, та випий же чаю!"] 20 | ], c, d; 21 | for(a = 1; a < b.length - 1; a++) { 22 | c = b[a][0]; // Language 23 | d = b[a][1]; // Source 24 | e = translit(d, a); // Translit 25 | console.log( 26 | "%s - %s\nSource : %s\nTranslit: %s\nReverse : %s\n", 27 | c, // Language 28 | translit(c, a), // Transliterated language 29 | d, // Source 30 | e, // Forward 31 | translit(e, -1 * a) // Reverse 32 | ); 33 | } 34 | }; 35 | example() 36 | ``` 37 | [home-img]: https://img.shields.io/badge/Home-Habrahabr.ru-blue.svg?style=flat-square 38 | [home-url]: https://habrahabr.ru/post/250885/ 39 | 40 | [lic-img]: https://img.shields.io/badge/License-GPL-blue.svg?style=flat-square 41 | [lic-url]: COPYRIGHT.md 42 | 43 | [down-img]: https://img.shields.io/badge/GitHub-Latest-blue.svg?style=flat-square 44 | [down-url]: https://github.com/xguest/iso_9_js/archive/last.zip 45 | 46 | [npm-img]: https://img.shields.io/npm/v/iso_9.svg?style=flat-square 47 | [npm-url]: https://www.npmjs.com/package/iso_9 48 | 49 | [travis-img]: https://travis-ci.org/xguest/iso_9_js.svg?style=flat-square 50 | [travis-url]: https://travis-ci.org/xguest/iso_9_js 51 | 52 | [climate-img]: https://img.shields.io/badge/Climate-4.0-brightgreen.svg?style=flat-square 53 | [climate-url]: https://codeclimate.com/github/xguest/iso_9_js 54 | 55 | [Coverage-img]: https://coveralls.io/repos/github/xguest/iso_9_js/badge.svg?branch=master 56 | [Coverage-url]: https://coveralls.io/github/xguest/iso_9_js?branch=master 57 | 58 | [docs-img]: https://img.shields.io/badge/Docs-100%-brightgreen.svg?style=flat-square 59 | [docs-url]: http://inch-ci.org/github/xguest/iso_9_js 60 | 61 | [depe-img]: https://img.shields.io/badge/Deps-none-brightgreen.svg?style=flat-square 62 | [depe-url]: https://david-dm.org/xguest/iso_9_js 63 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /translit.js: -------------------------------------------------------------------------------- 1 | // /* #!/usr/bin/env node; */ 2 | /* jshint -W100 */ 3 | /** 4 | * @name translit.js 5 | * @author XGuest 6 | * @link https://github.com/xguest/iso_9_js 7 | * @version 1.0.4 8 | * @copyright GPL applies. 9 | * No warranties XGuest[28.03.2016/07:59:18] translit [ver.1.0.4] 10 | * #guid {E7088033-479F-47EF-A573-BBF3520F493C} 11 | * 12 | * @description Прямая и обратная транслитерация 13 | * Соответствует ISO 9:1995 и ГОСТ 7.79-2000 системы А и Б 14 | * 15 | * @param {String} str транслитерируемая строка 16 | * @param {Number} typ ± направление (тип) транслитерации 17 | * + прямая с латиницы в кирилицу 18 | * - обратная 19 | * system A = 1-диакритика; 20 | * system B = 2-Беларусь;3-Болгария;4-Македония;5-Россия;6-Украина; 21 | * @example 22 | * function example() { 23 | * var a, b = [ 24 | * [], 25 | * ["Диакритика", "Съешь ещё этих мягких французских булок, да выпей же чаю!"], 26 | * ["Беларускую", "З'ясі яшчэ гэтых мяккіх французскіх булак, ды выпі ж чаю!"], 27 | * ["Български", "Яжте повече от тези меки кифлички, но също така се пие чай!"], 28 | * ["Македонски", "Јадат повеќе од овие меки францускиот ролни, па пијат чај!"], 29 | * ["Русский", "Съешь ещё этих мягких французских булок, да выпей же чаю!"], 30 | * ["Українська", "З'їж ще цих м'яких французьких булок, та випий же чаю!"] 31 | * ], c, d; 32 | * for(a = 1; a < b.length - 1; a++) { 33 | * c = b[a][0]; // Language 34 | * d = b[a][1]; // Source 35 | * e = translit(d, a); // Forward 36 | * console.log( 37 | * "%s - %s\nSource : %s\nTranslit: %s\nReverse : %s\n", 38 | * c, // Language 39 | * translit(c, a), // Transliterated language 40 | * d, // Source 41 | * e, // Forward 42 | * translit(e, -1 * a) // Reverse 43 | * ); 44 | * } 45 | * }; 46 | **/ 47 | function translit(str, typ) { 48 | var func = (function(typ) { 49 | /** Function Expression 50 | * Вспомогательная функция. 51 | * 52 | * FINISHED TESTED! 53 | * В ней и хотелось навести порядок. 54 | * 55 | * Проверяет направление транслитерации. 56 | * Возвращает массив из 2 функций: 57 | * построения таблиц транслитерации. 58 | * и пост-обработки строки (правила из ГОСТ). 59 | * 60 | * @param {Number} typ 61 | * @return {Array} Массив функций пред и пост обработки. 62 | **/ 63 | function prep (a) { 64 | var write = [ 65 | function(chr, row) {trantab[row] = chr;regarr.push(row);}, 66 | function(row, chr) {trantab[row] = chr;regarr.push(row);} 67 | ][a]; 68 | return function(col, row) { // создаем таблицу и RegExp 69 | var chr = col[abs] || col[0]; // Символ 70 | if (chr) write(chr, row); // Если символ есть 71 | } 72 | } 73 | var abs = Math.abs(typ); // Абсолютное значение транслитерации 74 | if (typ === abs) { // Прямая транслитерация в латиницу 75 | str = str.replace(/(i(?=.[^аеиоуъ\s]+))/ig, '$1`'); // "i`" ГОСТ ст. рус. и болг. 76 | return [prep(0), // Возвращаем массив функций 77 | function(str) { // str - транслируемая строка. 78 | return str.replace(/i``/ig, 'i`'). // "i`" в ГОСТ ст. рус. и болг. 79 | replace(/((c)z)(?=[ieyj])/ig, '$1'); // "cz" в символ "c" 80 | }]; 81 | } else { // Обратная транслитерация в кириллицу 82 | str = str.replace(/(c)(?=[ieyj])/ig, '$1z'); // Правило сочетания "cz" 83 | return [prep(1),function(str) {return str;}];// nop - пустая функция. 84 | } 85 | }(typ)); 86 | var iso9 = { // Объект описания стандарта 87 | // Имя - кириллица 88 | // 0 - общие для всех 89 | // 1 - диакритика 4 - MK|MKD - Македония 90 | // 2 - BY|BLR - Беларусь 5 - RU|RUS - Россия 91 | // 3 - BG|BGR - Болгария 6 - UA|UKR - Украина 92 | /*-Имя---------0-,-------1-,---2-,---3-,---4-,----5-,---6-*/ 93 | '\u0449': [ '', '\u015D', '','sth', '', 'shh','shh'], // 'щ' 94 | '\u044F': [ '', '\u00E2', 'ya', 'ya', '', 'ya', 'ya'], // 'я' 95 | '\u0454': [ '', '\u00EA', '', '', '', '', 'ye'], // 'є' 96 | '\u0463': [ '', '\u011B', '', 'ye', '', 'ye', ''], // ять 97 | '\u0456': [ '', '\u00EC', 'i', 'i`', '', 'i`', 'i'], // 'і' йота 98 | '\u0457': [ '', '\u00EF', '', '', '', '', 'yi'], // 'ї' 99 | '\u0451': [ '', '\u00EB', 'yo', '', '', 'yo', ''], // 'ё' 100 | '\u044E': [ '', '\u00FB', 'yu', 'yu', '', 'yu', 'yu'], // 'ю' 101 | '\u0436': [ 'zh','\u017E'], // 'ж' 102 | '\u0447': [ 'ch','\u010D'], // 'ч' 103 | '\u0448': [ 'sh', '\u0161', '', '', '', '', ''], // 'ш' 104 | '\u0473': [ '','f\u0300', '', 'fh', '', 'fh', ''], // фита 105 | '\u045F': [ '','d\u0302', '', '', 'dh', '', ''], // 'џ' 106 | '\u0491': [ '','g\u0300', '', '', '', '', 'g`'], // 'ґ' 107 | '\u0453': [ '', '\u01F5', '', '', 'g`', '', ''], // 'ѓ' 108 | '\u0455': [ '', '\u1E91', '', '', 'z`', '', ''], // 'ѕ' 109 | '\u045C': [ '', '\u1E31', '', '', 'k`', '', ''], // 'ќ' 110 | '\u0459': [ '','l\u0302', '', '', 'l`', '', ''], // 'љ' 111 | '\u045A': [ '','n\u0302', '', '', 'n`', '', ''], // 'њ' 112 | '\u044D': [ '', '\u00E8', 'e`', '', '', 'e`', ''], // 'э' 113 | '\u044A': [ '', '\u02BA', '', 'a`', '', '``', ''], // 'ъ' 114 | '\u044B': [ '', 'y', 'y`', '', '', 'y`', ''], // 'ы' 115 | '\u045E': [ '', '\u01D4', 'u`', '', '', '', ''], // 'ў' 116 | '\u046B': [ '', '\u01CE', '', 'o`', '', '', ''], // юс 117 | '\u0475': [ '', '\u1EF3', '', 'yh', '', 'yh', ''], // ижица 118 | '\u0446': [ 'cz', 'c'], // 'ц' 119 | '\u0430': [ 'a'], // 'а' 120 | '\u0431': [ 'b'], // 'б' 121 | '\u0432': [ 'v'], // 'в' 122 | '\u0433': [ 'g'], // 'г' 123 | '\u0434': [ 'd'], // 'д' 124 | '\u0435': [ 'e'], // 'е' 125 | '\u0437': [ 'z'], // 'з' 126 | '\u0438': [ '', 'i', '', 'i', 'i', 'i', 'y`'], // 'и' 127 | '\u0439': [ '', 'j', 'j', 'j', '', 'j', 'j'], // 'й' 128 | '\u043A': [ 'k'], // 'к' 129 | '\u043B': [ 'l'], // 'л' 130 | '\u043C': [ 'm'], // 'м' 131 | '\u043D': [ 'n'], // 'н' 132 | '\u043E': [ 'o'], // 'о' 133 | '\u043F': [ 'p'], // 'п' 134 | '\u0440': [ 'r'], // 'р' 135 | '\u0441': [ 's'], // 'с' 136 | '\u0442': [ 't'], // 'т' 137 | '\u0443': [ 'u'], // 'у' 138 | '\u0444': [ 'f'], // 'ф' 139 | '\u0445': [ 'x', 'h'], // 'х' 140 | '\u044C': [ '', '\u02B9', '`', '`', '', '`', '`'], // 'ь' 141 | '\u0458': [ '','j\u030C', '', '', 'j', '', ''], // 'ј' 142 | '\u2019': [ '\'','\u02BC'], // '’' 143 | '\u2116': [ '#'] // '№' 144 | /*-Имя---------0-,-------1-,---2-,---3-,---4-,----5-,---6-*/ 145 | }, regarr = [], trantab = {}; 146 | /* jshint -W030 */ // Создание таблицы и массива RegExp 147 | for (var row in iso9) {if (Object.hasOwnProperty.call(iso9, row)) {func[0](iso9[row], row);}} 148 | /* jshint +W030 */ 149 | return func[1]( // функция пост-обработки строки (правила и т.д.) 150 | str.replace( // Транслитерация 151 | new RegExp(regarr.join('|'), 'gi'),// Создаем RegExp из массива 152 | function(R) { // CallBack Функция RegExp 153 | if (R.toLowerCase() === R) { // Обработка строки с учетом регистра 154 | return trantab[R]; 155 | } else { 156 | return trantab[R.toLowerCase()].toUpperCase(); 157 | } 158 | })); 159 | } 160 | module.exports = translit; 161 | --------------------------------------------------------------------------------