1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
3 | typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.PhoneticAlphabetConverter = {}));
|
5 | }(this, (function (exports) { 'use strict';
|
6 |
|
7 | var NATO_PHONETIC_ALPHABET = {
|
8 | a: 'alpha',
|
9 | b: 'bravo',
|
10 | c: 'charlie',
|
11 | d: 'delta',
|
12 | e: 'echo',
|
13 | f: 'foxtrot',
|
14 | g: 'golf',
|
15 | h: 'hotel',
|
16 | i: 'india',
|
17 | j: 'juliet',
|
18 | k: 'kilo',
|
19 | l: 'lima',
|
20 | m: 'mike',
|
21 | n: 'november',
|
22 | o: 'oscar',
|
23 | p: 'papa',
|
24 | q: 'quebec',
|
25 | r: 'romeo',
|
26 | s: 'sierra',
|
27 | t: 'tango',
|
28 | u: 'uniform',
|
29 | v: 'victor',
|
30 | w: 'whiskey',
|
31 | x: 'x-ray',
|
32 | y: 'yankee',
|
33 | z: 'zulu'
|
34 | };
|
35 | function converter(text, alphabet) {
|
36 | if (alphabet === void 0) { alphabet = NATO_PHONETIC_ALPHABET; }
|
37 | if (typeof text !== 'string') {
|
38 | throw new TypeError('First argument must be a string');
|
39 | }
|
40 | if (!text) {
|
41 | return [];
|
42 | }
|
43 | var output = [];
|
44 | var letters = text.toLowerCase().split('');
|
45 | for (var index = 0, len = letters.length; index < len; index++) {
|
46 | var letter = letters[index];
|
47 | var word = alphabet[letter];
|
48 | if (word) {
|
49 | output.push(word);
|
50 | }
|
51 | }
|
52 | return output;
|
53 | }
|
54 |
|
55 | exports.NATO_PHONETIC_ALPHABET = NATO_PHONETIC_ALPHABET;
|
56 | exports.default = converter;
|
57 |
|
58 | Object.defineProperty(exports, '__esModule', { value: true });
|
59 |
|
60 | })));
|
61 |
|