{"id":29012193,"url":"https://github.com/liblouis/liblouis-js","last_synced_at":"2025-06-25T18:15:22.404Z","repository":{"id":58230694,"uuid":"66817049","full_name":"liblouis/liblouis-js","owner":"liblouis","description":"Port/cross-compiled version of liblouis to Javascript","archived":false,"fork":false,"pushed_at":"2020-12-11T11:05:42.000Z","size":6977,"stargazers_count":12,"open_issues_count":22,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-09T03:27:08.620Z","etag":null,"topics":["emscripten","javascript","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liblouis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-29T06:21:23.000Z","updated_at":"2025-04-03T13:53:37.000Z","dependencies_parsed_at":"2022-08-30T20:01:39.594Z","dependency_job_id":null,"html_url":"https://github.com/liblouis/liblouis-js","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/liblouis/liblouis-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liblouis%2Fliblouis-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liblouis%2Fliblouis-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liblouis%2Fliblouis-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liblouis%2Fliblouis-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liblouis","download_url":"https://codeload.github.com/liblouis/liblouis-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liblouis%2Fliblouis-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261927691,"owners_count":23231383,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emscripten","javascript","nodejs"],"created_at":"2025-06-25T18:15:20.721Z","updated_at":"2025-06-25T18:15:22.383Z","avatar_url":"https://github.com/liblouis.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"These are \"javascript bindings\" to liblouis created by cross\ncompiling [liblouis](https://github.com/liblouis/liblouis) using\n[emscripten](http://emscripten.org/). The Liblouis API written in C can be directly called\nusing the [`ccall`](https://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html#ccall) and \n[`cwrap`](https://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html#cwrap)\nfunctions provided by emscripten. As directly calling the C API is cumbersome,\nan additional API — called Easy API — is provided for most functions. This package\nsupports NodeJS and browser environments.\n\n[![npm version](https://img.shields.io/npm/v/liblouis.svg?colorB=44cc11\u0026label=Easy-API%20@npm)](https://www.npmjs.com/package/liblouis)\n[![Bower version](https://img.shields.io/bower/v/liblouis.svg?colorB=44cc11\u0026label=Easy-API%20@bower)](https://bower.io/search/?q=liblouis)\n[![latest build in the npm registry](https://img.shields.io/npm/v/liblouis-build.svg?colorB=44cc11\u0026label=Latest%20C-API%20Build%20@npm)](https://www.npmjs.com/package/liblouis-build)\n[![latest build in the bower registry](https://img.shields.io/bower/v/liblouis-build.svg?colorB=44cc11\u0026label=Latest%20C-API%20Build%20@bower)](https://bower.io/search/?q=liblouis-build)\n\n[![build status of latest Easy-Api](https://img.shields.io/travis/liblouis/liblouis-js/master.svg?label=Build%20of%20Easy-API)](https://travis-ci.org/liblouis/liblouis-js)\n[![build status of latest C-Api](https://img.shields.io/travis/liblouis/js-build.svg?branch=master\u0026label=Build%20of%20C-API)](https://travis-ci.org/liblouis/liblouis-js)\n\n---\n\n\u003cp align=center\u003e\u003cstrong\u003eTable of Contents\u003c/strong\u003e\u003c/p\u003e\n\n1. [API Overview](#api-overview)\n\t1. [Installation](#installation)\n\t2. [List of Available Liblouis Functions](#list-of-available-liblouis-functions)\n\t3. [List of Additional Easy-API Methods](#list-of-additional-easy-api-methods)\n\t3. [Compiling the Latest Version of Liblouis](#compiling-the-latest-version-of-liblouis)\n\t4. [Testing a Liblouis Build](#testing-a-liblouis-build)\n2. [Usage Examples](#usage-examples)\n\t1. [Printing the Version Number Using the Easy API in the Browser](#printing-the-version-number-using-the-easy-api-in-the-browser)\n\t2. [Printing the Version Number By Directly Calling Liblouis in the Browser](#printing-the-version-number-by-directly-calling-liblouis-in-the-browser)\n\t3. [Printing the Version Number Using the Easy API in NodeJS](#printing-the-version-number-using-the-easy-api-in-nodejs)\n\t4. [Translating and Back-Translating a String Using the Easy API](#translating-and-back-translating-a-string-using-the-easy-api)\n\t5. [Altering a Table Definition on Run-Time](#altering-a-table-definition-on-run-time)\n\t6. [Downloading Table Files on Demand in the Browser](#downloading-table-files-on-demand-in-the-browser)\n\t7. [Loading Table Files From Disk in NodeJS](#loading-table-files-from-disk-in-nodejs)\n\t8. [Debugging and Adjusting the Log Level](#debugging-and-adjusting-the-log-level)\n\t9. [Persisting Log Files in NodeJS using Deprecated Liblouis Log Functions](#persisting-log-files-in-nodejs-using-deprecated-liblouis-log-functions)\n\t10. [Dropping the Path Prefix of Bundled Tables](#dropping-the-path-prefix-of-bundled-tables)\n\t11. [Usage with Typescript](#usage-with-typescript)\n\t12. [Usage with Webpack](#usage-with-webpack)\n\t13. [Switching or Running Multiple C-API Builds in Parallel](#switching-or-running-multiple-c-api-builds-in-parallel)\n3. [Changelog](#changelog)\n4. [Licensing](#licensing)\n\n---\n\n# API Overview\n\n### Installation\n\n#### With NPM\n\n```\nnpm install liblouis\n```\n\nThis will *install the latest available stable release version* of liblouis' C-API and is \nequivalent to an installation with:\n\n```\nnpm install liblouis-build@latest\nnpm install liblouis\n```\n\n*If you want to fetch a specific version of the C-API*, for example version\n`3.2.0`, you can use the following commands:\n\n```\nnpm install liblouis-build@3.2.0\nnpm install liblouis\n```\n\nBuilds of release versions are available within minutes of the C-API release.\nThey are however initially published as release candidates using a `-rc*`\nsuffix. You can use `npm view liblouis-build versions` to list all release\nversions and all release candidates available.\n\n*If you want to install the latest available development version* of liblouis'\nC-API execute:\n\n```\nnpm install liblouis/js-build\nnpm install liblouis\n```\n\n*If you want to install a specific development version* of liblouis' C-API, you can\nspecify the commit hash:\n\n```\nnpm install liblouis/js-build#commit-4b4c02\nnpm install liblouis\n```\n\nYou have to specify *exactly* 6 digits of the commit hash. Some commits won't\nhave a prebuilt binary available. In this case [you can build liblouis yourself](#compiling-the-latest-version-of-liblouis).\n\n⚠ **Warning:** While the programatic interface of `liblouis-build` adheres to the\nsemantic versioning specification, table files do not. You should refrain from\nadding `liblouis-build` as dependency with a version range if you are using\nliblouis with custom table files.\n\n### List of Available Liblouis Functions\n\nAll liblouis C-API functions listed in the [official liblouis\ndocumentation](liblouis.org/documentation/liblouis.html) can be directly called\nusing the\n[`ccall`](https://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html#ccall)\nand\n[`cwrap`](https://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html#cwrap)\nfunctions. However, you have to explicitly copy all arguments to the heap and\nspecify the type of the argument as described in the emscripten documentation.\n\nMost functions in the C-API have an identically named method in the Easy-API that correctly\ninvokes the C-API for you. The table below lists all functions that were implemented:\n\n| Method           | Easy API | Direct Call API |\n|------------------|--------------|-------------|\n| `lou_version` | ✔ | ✔ |\n| `lou_translateString` | ✔\\* | ✔ |\n| `lou_translate` | ✖ | ✔ |\n| `lou_backTranslateString` | ✔\\* | ✔ |\n| `lou_backTranslate` | ✖ | ✔ |\n| `lou_hyphenate` | ✖ | ✔ |\n| `lou_compileString` | ✔ | ✔ |\n| `lou_getTypeformForEmphClass` | ✖ | ✔ |\n| `lou_dotsToChar` | ✖ | ✔ |\n| `lou_charToDots` | ✖ | ✔ |\n| `lou_registerLogCallback` | ✔ | ✔ |\n| `lou_setLogLevel` | ✔ | ✔ |\n| `lou_logFile` | ✖\\*\\* | ✔ |\n| `lou_logPrint` | ✖\\*\\* | ✔ |\n| `lou_logEnd` | ✖\\*\\* | ✔ |\n| `lou_setDataPath` | ✔ | ✔ |\n| `lou_getDataPath` | ✔ | ✔ |\n| `lou_getTable` | ✔ | ✔ |\n| `lou_checkTable` | ✔ | ✔ |\n| `lou_readCharFromFile` | ✖ | ✔ |\n| `lou_free` | ✔ | ✔ |\n| `lou_charSize` | ✔ | ✔ |\n\n\\* only [BMP](https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane) tested\n\n\\*\\* `lou_logPrint`, `lou_logFile` and `lou_logEnd` will not be implemented as\nthey are deprecated.\n\n### List of Additional Easy-API Methods\n\nThe following methods do not have a corresponding C-API function, but are part of the Easy-API.\n\n#### enableOnDemandTableLoading(url)\n\nAllows you to make lightweight liblouis builds that do not include any or all required table files.\nInstead table files not embedded in the liblouis C-API build are downloaded from the specified\nurl on first access. For usage examples, see [*Downloading Table Files on Demand in the Browser*](#downloading-table-files-on-demand-in-the-browser) and [*Loading Table Files from Disk in NodeJS*](#loading-table-files-from-disk-in-nodejs).\n\n#### LiblouisEasyApi#constructor(build)\n\n```js\nnew LiblouisEasyApi(build :EmscriptenModule|string);\n```\nCreate an additional instance of the Easy-API running in the same thread as the caller.\nTakes either a liblouis C-API build or a liblouis release version number as\nargument. Also see [*Switching or Running Multiple C-API Builds in Parallel*]().\n\n#### LiblouisAsyncEasyApi#constructor(options)\n\n\n```js\nnew LiblouisAsyncEasyApi({\n\tcapi: string,\n\teasyapi: string\n});\n```\n\nUse this constructor to instantiate additional instances of the Easy-API. `capi` and `easyapi`\nare urls of both script files.\n\n⚠ **Warning:** *These scripts at the specified URLs are downloaded and executed in a worker thread.\nIt is your responsibility to sanatize these URLs to prevent execution of malicous code.*\n\n### Compiling the Latest Version of Liblouis\n\n```shell\n# obtain the latest version\ngit clone https://github.com/liblouis/liblouis.git\ncd liblouis\n\n# build\n./autogen.sh\nemconfigure ./configure --disable-shared\nemmake make\n\nemcc ./liblouis/.libs/liblouis.a -s RESERVED_FUNCTION_POINTERS=1 -s MODULARIZE=1\\\n\t -s EXPORT_NAME=\"'liblouisBuild'\" -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['FS',\\\n\t'Runtime', 'stringToUTF16', 'Pointer_Stringify']\" --pre-js ./liblouis-js/inc/pre.js\\\n\t --post-js ./liblouis-js/inc/post.js -o build-no-tables.js\n\ncat ./inc/append.js \u003e\u003e build-no-tables.js\n```\n\nIn liblouis versions prior to release 3.2.0, you have to list all exported API\nfunctions:\n\n```shell\nemcc ./liblouis/.libs/liblouis.a -s RESERVED_FUNCTION_POINTERS=1 -s MODULARIZE=1\\\n\t -s EXPORTED_FUNCTIONS=\"['_lou_version', '_lou_translateString', '_lou_translate',\\\n\t'_lou_backTranslateString', '_lou_backTranslate', '_lou_hyphenate',\\\n\t'_lou_compileString', '_lou_getTypeformForEmphClass', '_lou_dotsToChar',\\\n\t'_lou_charToDots', '_lou_registerLogCallback', '_lou_setLogLevel',\\\n\t'_lou_logFile', '_lou_logPrint', '_lou_logEnd', '_lou_setDataPath',\\\n\t'_lou_getDataPath', '_lou_getTable', '_lou_checkTable',\\\n\t'_lou_readCharFromFile', '_lou_free', '_lou_charSize']\"\\\n\t -s EXPORT_NAME=\"'liblouisBuild'\" -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['FS',\\\n\t'Runtime', 'stringToUTF16', 'Pointer_Stringify']\" --pre-js ./liblouis-js/inc/pre.js\\\n\t --post-js ./liblouis-js/inc/post.js -o build-no-tables.js\n```\n\nTo include a list of table files or a directory containing table files use the [`--embed-file`\nflag](https://kripken.github.io/emscripten-site/docs/porting/files/packaging_files.html#packaging-using-emcc).\nFor example, to embed all tables in a subfolder called `tables` add `--embed-file tables`, to embed\nall tables in the virtual filesystem root add `--embed-file tables@/`.\n\nIf you build liblouis for 32-bit Unicode, execute configure with\n`--enable-ucs4` and subsitute `stringToUTF16` with `stringToUTF32`.\n\n### Testing a Liblouis Build\n\nYou have to make your build available as the node module `liblouis-build`. If you just\nbuilt a binary on your system, you can execute the following command in the `liblouis-js`\npackage folder. The path `../js-build` should point to the builds folder:\n\n```\nnpm link ../js-build --production\n```\n\nTo test all builds in NodeJS and the browser, run:\n\n```shell\nnpm test\n```\n\nTo only run tests in NodeJS, run:\n\n```shell\nnpm run test-node\n```\n\nTo only run tests in the browser, run:\n\n```shell\nnpm run test-browser\n```\n\nNote that browser tests require PhantomJS to be installed. You can pass a list of\nbuild names to only test a subset of the available builds. The command will fail\nif a build cannot be found. A few examples:\n\n```shell\nnpm test -- build-no-tables-utf16.js build-no-tables-utf32.js\nnpm run test-node -- build-no-tables-utf16.js build-no-tables-utf32.js\nnpm run test-browser -- build-no-tables-utf16.js build-no-tables-utf32.js\n```\n\n\n# Usage Examples\n\nA lot more examples can be found in the folder `tests/`.\n\n### Printing the Version Number Using the Easy API in the Browser\n\nInclude a liblouis build first and the Easy-API second.\n\n```js\n\u003c!doctype html\u003e\n\n\u003c!-- use your package manager to obtain these files: `build-no-tables.js`\n     is part of the package `liblouis-build`, `easy-api.js` is the main\n     file of the `liblouis-js` package. --\u003e\n\n\u003cscript src=\"build-no-tables.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"easy-api.js\"\u003e\u003c/script\u003e\n\n\u003cscript\u003e\nconsole.info(\"Liblouis Version:\", liblouis.version());\n// Should print:\n// Liblouis Version: 3.2.0\n\u003c/script\u003e\n```\n\n### Printing the Version Number By Directly Calling Liblouis in the Browser\n\nYou can include any liblouis build for this example.\n\n```js\n\u003c!doctype html\u003e\n\n\u003cscript src=\"build-no-tables.js\"\u003e\u003c/script\u003e\n\n\u003cscript\u003e\nconsole.info(\"Liblouis Version:\", liblouisBuild.ccall(\"lou_version\", \"string\"));\n// Should print:\n// Liblouis Version: 3.2.0\n\u003c/script\u003e\n```\n\n### Printing the Version Number Using the Easy API in NodeJS\n\nUsing `require` includes the Easy API, liblouis without tables and mounts the\n`tables` folder as `tables`.\n\n```js\nconst liblouis = require(\"liblouis\");\n\nconsole.info(\"Liblouis Version using Easy API:\", liblouis.version());\n// Should print:\n// Liblouis Version using Easy API: 3.2.0\n\u003c/script\u003e\n```\n\n### Translating and Back-Translating a String Using the Easy API\n\n```js\nvar unicode_braille = liblouis.translateString(\"tables/unicode.dis,tables/de-de-g0.utb\", \"10 Ziegen\")\n// Variable should contain:\n// ⠼⠁⠚ ⠵⠊⠑⠛⠑⠝\nconsole.log(liblouis.backTranslateString(\"tables/unicode.dis,tables/de-de-g0.utb\", unicode_braille))\n// Should print:\n// 10 ziegen\n```\n\n### Altering a Table Definition on Run-Time\n\n```js\nconsole.log(liblouis.translateString(\"tables/unicode.dis,tables/de-de-g0.utb\", \"1\"));\n// Logs: ⠼⠁\nliblouis.compileString(\"tables/unicode.dis,tables/de-de-g0.utb\", \"numsign 123456\");\nconsole.log(liblouis.translateString(\"tables/unicode.dis,tables/de-de-g0.utb\", \"1\"));\n// Logs: ⠿⠁\n```\n\n### Downloading Table Files on Demand in the Browser\n\nAfter including a build without a bundled table folder, use the Easy-API call\n`enableOnDemandTableLoading` with an absolute or relative URL to the table\ndirectory:\n\n```js\n// enable and set base url for tables\nliblouis.enableOnDemandTableLoading(\"tables/\");\n\n// call any API (direct call API or easy API) method:\nvar unicode_braille = liblouis.translateString(\"tables/unicode.dis,tables/de-de-g0.utb\", \"10 Ziegen\")\n// Makes 12 XHR-Requests for table files. The variable should contain the same\n// content as above:\n// ⠼⠁⠚ ⠵⠊⠑⠛⠑⠝\n```\n\nNote that you have to run liblouis in a worker thread for\n`enableOnDemandTableLoading` to work [1].\n\nYou should call `enableOnDemandTableLoading` only once on initialization.\nChanging the table folder location during execution causes the filesystem to be\ninconsistent. If you have to change the folder location, reload the whole\nliblouis/emscripten instance.\n\n### Loading Table Files from Disk in NodeJS\n\nIn NodeJS environments, `liblouis-js` automatically tries to load the `tables/`\nfolder from disk if your built does not already bundle table files.\n\nIf you do not want to load tables from disk, you can disable this feature\nby calling:\n\n```js\nliblouis.disableOnDemandTableLoading();\n```\n\nOr if you want to change the location of the table folder, simply call:\n\n```js\nliblouis.enableOnDemandTableLoading(tableFolderPath);\n```\n\nProviding `null` will reset the path to the original folder location.\n`enableOnDemandTableLoading` file not free tables that were already compiled by\nliblouis automatically. You have to call `liblouis.free` yourself if you\nwant liblouis to reload table files.\n\n\n### Debugging and Adjusting the Log Level\n\nThe available log levels are [listed in the liblouis\ndocumentation](http://liblouis.org/documentation/liblouis.html#lou_005fsetLogLevel).\nThe log level constants can be accessed using `liblouis.LOG[levelname]`. The\ndefault log level of liblouis is `liblouis.LOG.INFO`. The log messages of enabled\nlog levels are shown in the javascript console by default [2].\n\n```js\n// log everything including debug messages\nliblouis.setLogLevel(liblouis.LOG.ALL);\n\n// replace the default message handler\nliblouis.registerLogCallback(function(logLevel, msg){\n\t// logLevel is the constant associated with the log level.\n\t// you may obtain a string representation of the log level as follows:\n\tvar logLevelName = liblouis.LOG[logLevel];\n\n\t// you may check for a specific log level:\n\tif(logLevel === liblouis.LOG.DEBUG) {\n\t\tconsole.info(\"just recieved a debug message\");\n\t}\n\n\t// or alternatively using a string comparison:\n\tif(logLevelName === \"DEBUG\") {\n\t\tconsole.info(\"just recieved a debug message\");\n\t}\n\n\tconsole.log(logLevel, logLevelName, msg);\n\t// Example output:\n\t// 10000 \"DEBUG\" \"found table tables/de-de-g1.ctb\"\n});\n\n// remove the custom message handler and use the default message handler\nliblouis.registerLogCallback(null);\n```\n### Persisting Log Files in NodeJS using Deprecated Liblouis Log Functions\n\nThe following example creates a log file, that is persisted on the hard drive.\nNote that the functions of liblouis called below (`lou_logFile`, `lou_logPrint`\nand `lou_logEnd`) are all deprecated. The example only demonstrates how\nliblouis can be called directly from nodeJS. In production systems, you should\nconsider implementing your own log functionality using `registerLogCallback`.\n\n```js\nconst path = require('path');\nconst capi = require('liblouis-build');\nconst easyapi = require('liblouis');\neasyapi.setLiblouisBuild(capi);\n\n// map a directory on the machine to a virtual directory of emscripten:\nvar hdd_directory = path.resolve(__dirname, 'logs/');\n\nFS.mkdir('/logs');\nliblouis.getFilesystem().mount(NODEFS, { root: hdd_directory }, '/logs');\n\n// log all messages:\neasyapi.setLogLevel(easyapi.LOG.ALL);\n\n// enable liblouis' deprecated \"log to file\"-functionality:\ncapi.ccall('lou_logFile', 'void', ['string'], ['/logs/liblouis.txt']); \n\n// map the new log functionality of liblouis to the deprecated log\n// functionality:\neasyapi.registerLogCallback(function(i, str) {\n\tcapi.ccall('lou_logPrint', 'void', ['string'], [str]);\n});\n\n// do something that logs messages:\neasyapi.translateString(\"tables/unicode.dis,tables/de-de-g0.utb\", \"10 Ziegen\");\n\n// Example log file contents are now:\n// ----------------------------------\n\n// Performing translation: tableList=tables/unicode.dis,tables/de-de-g0.utb, inlen=38\n// Inbuf=0x0031 0x0030 0x0020 0x005A 0x0069 0x0065 0x0067 0x0065 0x006E 0x0000\n// 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000\n// 0x0000 0x0033 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000\n// 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 ~ 10 Ziegen\n// Cannot resolve table 'tables/unicode.dis'\n// 1 errors found.\n// tables/unicode.dis,tables/de-de-g0.utb could not be found\n```\n\nThe log file is created if it does not exist. If it exists, new log messages\nare appended to the end of the file.\n\n### Dropping the Path Prefix of Bundled Tables\n\n`liblouis.enableOnDemandTableLoading` lets you set the location of the table\nfolder if you are not bundling tables in the build's binary. If you want to\nchange the folder location inside the bundled virtual filesystem, you can use\nliblouis' `lou_setDataPath` as follows:\n\n```js\nconst PREFIX = \"/tables\";\n\nconst capi = require('liblouis-build');\nconst easyapi = require('liblouis');\nliblouis.setLiblouisBuild(capi);\n\ncapi.FS.mkdir(\"/liblouis\");\ncapi.FS.symlink(\"/tables\", \"/liblouis/tables\");\nliblouis.setDataPath(\"/\");\n```\n\n### Usage with Typescript\n\nThe easy api is typed and plays well with\n[typescript](https://www.typescriptlang.org) and [npm](https://www.npmjs.com/).\n\nAdd the library as dependency to your `package.json` using\n\n```\n$ npm install --save liblouis\n```\n\nand add the following line to each file that uses liblouis\n\n```js\n/// \u003creference types=\"liblouis\"/\u003e\n```\n\n### Usage with Webpack\n\nThe following code example demonstrates how you can use the asynchronous\nEasy-API in a project using webpack.\n\nIn your module file:\n\n```js\nvar liblouis = require(\"liblouis/easy-api\");\n\nvar capi_url = require(\"file-loader!liblouis-build\");\nvar easyapi_url = require(\"file-loader!liblouis/easy-api\");\n\nrequire.context(\"liblouis-build/tables/\", false);\nvar table_url  = \"tables/\";\n\nvar asyncLiblouis = new liblouis.EasyApiAsync({\n\tcapi: capi_url,\n\teasyapi: easyapi_url\n});\n\nasyncLiblouis.enableOnDemandTableLoading(table_url);\n\nasyncLiblouis.version(function(version) {\n     console.info(\"Running liblouis version \", version, \"through asynchronous API.\");\n});\n```\n\nThe [file loader plugin](https://github.com/webpack-contrib/file-loader) is\nused to copy the Easy-API and C-API files into the destination directory.\n\nIn your webpack configuration file add the following line:\n\n```js\n/* ... */\nexternals: { 'liblouis-build': 'commonjs liblouis-build'}\n\nmodule: {\n\tloaders: [\n\t\t{\n\t\t\ttest: /(\\.cti|\\.ctb|\\.utb|\\.dis|\\.uti|\\.tbl|\\.dic)$/,\n\t\t\tloader: 'file-loader?name=tables/[name].[ext]',\n\t\t},\n\t\t/* ... your other loaders ... */\n\t]\n}\n/* ... */\n```\n\nThe `externals` property prevents webpack from unnecessarily embedding\n`liblouis-build` in the bundle. The loader setting instructs webpack to copy\nall table files that are required in your source file to be copied to a folder\ncalled `tables/` in your output directory. In combination with the\n`require.context` call in your module file, this will copy all tables to the\noutput directory.\n\n### Switching or Running Multiple C-API Builds in Parallel\n\nIn browser environments, each C-API build registers itself in the global\nvariable\n\n```js\nliblouisBuilds : { [version]: EmscriptenModule[] };\n```\n\nwhich is an object mapping liblouis release version numbers to arrays of C-API\nbuilds. The C-API build loaded first additionally registers the global variable\n`liblouisBuild`.\n\nYou can wrap each build in a `LiblouisEasyApi` or `LiblouisAsyncEasyApi`\ninstance.\n\n# Changelog\n\n__Release 0.5.0 (*upcoming*):__ Support for new table indexing feature.\n\n__Release 0.4.0:__ Removal of build switching `liblouis.setLiblouisBuild` in\nfavor of multiple concurrent instances of the Easy-API `LiblouisEasyApi`;\nIntroduction of async Easy-API `LiblouisAsyncEasyApi` that automatically\ncreates a worker thread. this allows you to use on demand table loading\neffortlessly; support for UTF-32 builds of liblouis.\n\n*This release is backward compatible:* Liblouis builds for previous versions\ncan be used with liblouis-js `0.4.0`.\n\n__Release 0.3.0:__ `liblouis-js` no longer bundles a build of the liblouis\nC-API [3]. Builds were moved to their own npm and bower packages - this makes\nbuild switching and liblouis C-API selection easier; Adds support for on demand\ntable file loading in NodeJS; implements `lou_setDataPath` and `lou_getDataPath`.\n\n*This release is backward compatible:* Liblouis builds for version `0.2.x` can\nbe used with liblouis-js `0.3.0`.\n\n\n__Release 0.2.1:__ `liblouis-js` is now an official part of liblouis. The npm\nand bower packages were renamed to `liblouis`. This release updates package\nURLs from `reiner-dolp/liblouis-js` to `liblouis/liblouis-js`.\n\n__Release 0.2.0:__ Adding support for nodeJS (Issue #10, #11) and commonJS;\nAdding type definitions for Typescript; Updates liblouis to version `2c849bc`;\nRenaming easy api file to `easy-api.js`; Implements `lou_compileString`; Support\nfor build switching; Emscripten methods are no longer leaked to global scope.\n\n\n*This release is backward compatible:* Liblouis builds for version `0.1.0` can be\nused with liblouis-js `0.2.0`.\n\n\n__Release 0.1.0:__ Adding `libouis.setLogLevel` and `liblouis.registerLogCallback`;\nupdating liblouis builds to commit `db2a361`.\n\n__Release 0.0.3:__ Initial public release\n\n# Licensing\n\n[Emscripten is available under 2\nlicenses](https://github.com/kripken/emscripten/blob/master/LICENSE), the MIT\nlicense and the University of Illinois/NCSA Open Source License. [Liblouis is\nlicensed under\nLGPLv2.1+](https://raw.githubusercontent.com/liblouis/liblouis/master/README).\nNote that table files may have a different license. Licensing information can\nbe found in the header of the individual table files.\n\nCode that is not part of liblouis and not part of emscripten is licensed under\nGPL-3.0. The text of the license can be found in the file `LICENSE` of this\nrepository.\n\n\u003chr\u003e\n\n__Footnotes__\n\n[1] Emscripten requires the files to be loaded synchroniously. Synchronous XHR,\nused to fetch the files, is deprecated in the main thread as it blocks all\nuser interaction.\n \n[2] Liblouis writes messages to stdout and stderr by default. Emscripten\nredirects these to `Module.print` and `Module.printErr`, which are implemented\nas: `function print(x) { console.log(x); }` and `function printErr(x) {\nconsole.warn(x); }`. There is no need to overwrite these functions. You can use\n`liblouis#registerLogCallback(int logLevel, string msg)`, which additionally\nexposes the log level. The Easy API registers a log callback by default, which\nmaps each message level to the correct `console` method, e.g. liblouis warning\nmessages to `console.warn` and liblouis fatal errors to `console.error`.\n\n[3] Before this change, liblouis and liblouis-js versions correspond as follows:\n`0.1.0 = 3.0.0 (db2a361)`, `0.2.0 = 3.1.0 (2c849bc)`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliblouis%2Fliblouis-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliblouis%2Fliblouis-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliblouis%2Fliblouis-js/lists"}