Skip to content
/ uklatn Public

Commit 7f92ffc

Browse files
committed
add js types
1 parent 3f8cef2 commit 7f92ffc

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

js/uklatn.d.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
* Transliterates a string of Ukrainian Cyrillic to Latin script.
33
*
44
* @param {string} text - the text to transliterate
5-
* @param {string} table - transliteration system, one of:
5+
* @param {string} [table] - transliteration system, one of:
66
* - "DSTU_9112_A": DSTU 9112:2021 System A
77
* - "DSTU_9112_B": DSTU 9112:2021 System B
88
* - "KMU_55": KMU 55:2010
9+
* @returns {string} transliterated text
910
*/
10-
export function encode(text: string, table: string): string;
11+
export function encode(text: string, table?: string): string;
1112
/**
1213
* Re-transliterates a string of Ukrainian Latin to Cyrillic script.
1314
*
1415
* @param {string} text - the text to transliterate
15-
* @param {string} table - transliteration system, one of:
16+
* @param {string} [table] - transliteration system, one of:
1617
* - "DSTU_9112_A": DSTU 9112:2021 System A
1718
* - "DSTU_9112_B": DSTU 9112:2021 System B
19+
* @returns {string} transliterated text
1820
*/
19-
export function decode(text: string, table: string): string;
21+
export function decode(text: string, table?: string): string;
2022
declare namespace _default {
2123
export { encode };
2224
export { decode };

js/uklatn.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,11 @@ const _UklatnTables = new Map([
221221
* Transliterates a string of Ukrainian Cyrillic to Latin script.
222222
*
223223
* @param {string} text - the text to transliterate
224-
* @param {string} table - transliteration system, one of:
224+
* @param {string} [table] - transliteration system, one of:
225225
* - "DSTU_9112_A": DSTU 9112:2021 System A
226226
* - "DSTU_9112_B": DSTU 9112:2021 System B
227227
* - "KMU_55": KMU 55:2010
228+
* @returns {string} transliterated text
228229
*/
229230
export function encode(text, table) {
230231
if (table === undefined) { table = 'DSTU_9112_A'; }
@@ -240,9 +241,10 @@ export function encode(text, table) {
240241
* Re-transliterates a string of Ukrainian Latin to Cyrillic script.
241242
*
242243
* @param {string} text - the text to transliterate
243-
* @param {string} table - transliteration system, one of:
244+
* @param {string} [table] - transliteration system, one of:
244245
* - "DSTU_9112_A": DSTU 9112:2021 System A
245246
* - "DSTU_9112_B": DSTU 9112:2021 System B
247+
* @returns {string} transliterated text
246248
*/
247249
export function decode(text, table) {
248250
if (table === undefined) { table = 'DSTU_9112_A'; }

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"type": "module",
2828
"main": "js/uklatn.js",
2929
"bin": "js/cli.js",
30-
"files": [],
30+
"files": ["js/*.ts"],
3131
"scripts": {
3232
"postpack": "git checkout readme.md",
3333
"prepack": "cp js/readme.md readme.md",

tools/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ js:
4747
@$(PYTHON) gentables.py js >> "$(PROJECT_ROOT)/js/uklatn.js"
4848
@echo "/* Generated by gentests.py, do not edit. */\n" > "$(PROJECT_ROOT)/js/testuklatn.js"
4949
@$(PYTHON) gentests.py js >> "$(PROJECT_ROOT)/js/testuklatn.js"
50+
# tsc --declaration "$(PROJECT_ROOT)/js/uklatn.js" --allowJs --emitDeclarationOnly
5051

5152
php:
5253
@$(PYTHON) gentables.py php > "$(PROJECT_ROOT)/php/src/UkrainianLatin.php"

tools/gen/gen_js.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,11 @@ def _entries():
259259
* Transliterates a string of Ukrainian Cyrillic to Latin script.
260260
*
261261
* @param {string} text - the text to transliterate
262-
* @param {string} table - transliteration system, one of:
262+
* @param {string} [table] - transliteration system, one of:
263263
* - "DSTU_9112_A": DSTU 9112:2021 System A
264264
* - "DSTU_9112_B": DSTU 9112:2021 System B
265265
* - "KMU_55": KMU 55:2010
266+
* @returns {string} transliterated text
266267
*/
267268
export function encode(text, table) {
268269
if (table === undefined) { table = &{default_table}; }
@@ -278,9 +279,10 @@ def _entries():
278279
* Re-transliterates a string of Ukrainian Latin to Cyrillic script.
279280
*
280281
* @param {string} text - the text to transliterate
281-
* @param {string} table - transliteration system, one of:
282+
* @param {string} [table] - transliteration system, one of:
282283
* - "DSTU_9112_A": DSTU 9112:2021 System A
283284
* - "DSTU_9112_B": DSTU 9112:2021 System B
285+
* @returns {string} transliterated text
284286
*/
285287
export function decode(text, table) {
286288
if (table === undefined) { table = &{default_table}; }

0 commit comments

Comments
 (0)