Browse Source

chore: updates readme

e22m4u 1 year ago
parent
commit
51f236d31d
2 changed files with 32 additions and 6 deletions
  1. 16 3
      README-ru.md
  2. 16 3
      README.md

+ 16 - 3
README-ru.md

@@ -14,8 +14,19 @@
 npm install @e22m4u/js-path-trie
 ```
 
-Для загрузки ES-модуля требуется установить `"type": "module"` в файле
-`package.json`, или использовать `.mjs` расширение.
+Модуль поддерживает ESM и CommonJS стандарты.
+
+*ESM*
+
+```js
+import {PathTrie} from '@e22m4u/js-path-trie';
+```
+
+*CommonJS*
+
+```js
+const {PathTrie} = require('@e22m4u/js-path-trie');
+```
 
 ## Пример
 
@@ -23,6 +34,8 @@ npm install @e22m4u/js-path-trie
 - `match(path: string)` - поиск значения по заданному маршруту
 
 ```js
+import {PathTrie} from '@e22m4u/js-path-trie';
+
 const trie = new PathTrie();
 
 // добавление маршрутов выполняется
@@ -57,7 +70,7 @@ trie.match('/foo/bar/baz');
 
 ## Отладка
 
-Установка переменной `DEBUG` перед командой запуска включает вывод логов.
+Установка переменной `DEBUG` включает вывод логов.
 
 ```bash
 DEBUG=jsPathTrie* npm run test

+ 16 - 3
README.md

@@ -14,8 +14,19 @@ a [prefix tree](https://en.wikipedia.org/wiki/Trie) (trie).
 npm install @e22m4u/js-path-trie
 ```
 
-To load the ES-module, you need to set `"type": "module"`
-in the `package.json` file, or use the `.mjs` extension.
+The module supports ESM and CommonJS standards.
+
+*ESM*
+
+```js
+import {PathTrie} from '@e22m4u/js-path-trie';
+```
+
+*CommonJS*
+
+```js
+const {PathTrie} = require('@e22m4u/js-path-trie');
+```
 
 ## Example
 
@@ -23,6 +34,8 @@ in the `package.json` file, or use the `.mjs` extension.
 - `match(path: string)` returns a value by a given path
 
 ```js
+import {PathTrie} from '@e22m4u/js-path-trie';
+
 const trie = new PathTrie();
 
 // route registration is performed using
@@ -57,7 +70,7 @@ trie.match('/foo/bar/baz');
 
 ## Debugging
 
-Set the `DEBUG` variable before the run command to enable log output.
+Set the `DEBUG` variable to enable log output.
 
 ```bash
 DEBUG=jsPathTrie* npm run test