Skip to content

Commit aa8edbc

Browse files
committed
v3
1 parent 3ff1e9d commit aa8edbc

25 files changed

Lines changed: 3946 additions & 2351 deletions

.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
node-version: [20.x]
10+
node-version: [24.x]
1111
steps:
1212
- uses: actions/checkout@v1
1313
- name: Use Node.js ${{ matrix.node-version }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules/
33
coverage/
44
.nyc_output/
55
npm-debug.log
6+
dist/

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry=https://registry.npmjs.org/

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## v3.0.0
4+
Переработано API для возможности использовать в браузере.
5+
36
## v2.5.6
47
В небезопасный словарь перенесены слова #22, #26:
58
- протёкший;

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2023 Denis Seleznev
3+
Copyright (c) 2025 Denis Seleznev
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,28 @@
1717
Отсутствуют.
1818

1919
## Использование
20+
21+
### Node.js
2022
```js
21-
const Eyo = require('eyo-kernel');
23+
import { Eyo } from 'eyo-kernel';
24+
import { loadSafeDictionary, loadNotSafeDictionary } from 'eyo-kernel/load';
25+
2226
const text = 'Мой текст...';
2327

2428
// Работа с безопасным встроенным словарём.
2529
const safeEyo = new Eyo();
26-
safeEyo.dictionary.loadSafeSync(); // ./dict/safe.txt.gz
30+
const safeDictionary = await loadSafeDictionary() // ./dict/safe.txt
31+
safeEyo.dictionary.set(safeDictionary);
2732
console.log(safeEyo.restore(text));
2833
console.log(safeEyo.lint(text));
2934

3035
// Работа с небезопасным встроенным словарём.
3136
const notSafeEyo = new Eyo();
32-
notSafeEyo.dictionary.loadNotSafeSync(); // ./dict/not_safe.txt.gz
37+
const notSafeDictionary = loadNotSafeDictionary(); // ./dict/not_safe.txt
38+
notSafeEyo.dictionary.set(notSafeDictionary);
3339
console.log(notSafeEyo.restore(text));
3440
console.log(notSafeEyo.lint(text));
3541

36-
// Загрузка собственного словаря.
37-
const eyo = new Eyo();
38-
// Также поддерживаются словари, сжатые с помощью gzip, *.txt.gz
39-
eyo.dictionary.loadSync('./my_eyo_dict.txt');
40-
console.log(eyo.restore(text));
41-
console.log(eyo.lint(text));
42-
4342
// Создание собственного словаря.
4443
const eyo = new Eyo();
4544
// Добавить слово в свой словарь.
@@ -50,6 +49,27 @@ eyo.dictionary.removeWord('словоСБуквойЁ');
5049
eyo.dictionary.clear();
5150
```
5251

52+
### Браузер
53+
```js
54+
import { Eyo } from 'eyo-kernel';
55+
56+
const text = 'Мой текст...';
57+
58+
// Работа с безопасным встроенным словарём.
59+
const safeEyo = new Eyo();
60+
const safeDictionary = await fetch('./dictionary/safe.txt').then(response => response.text());
61+
safeEyo.dictionary.set(safeDictionary);
62+
console.log(safeEyo.restore(text));
63+
console.log(safeEyo.lint(text));
64+
65+
// Работа с небезопасным встроенным словарём.
66+
const notSafeEyo = new Eyo();
67+
const notSafeDictionary = await fetch('./dictionary/not_safe.txt').then(response => response.text());
68+
notSafeEyo.dictionary.set(notSafeDictionary);
69+
console.log(notSafeEyo.restore(text));
70+
console.log(notSafeEyo.lint(text));
71+
```
72+
5373
## Словарь
5474
Первоначально словарь взят из проекта [php-yoficator](https://github.com/rin-nas/php-yoficator/tree/master/Text). По доработкам словаря см. [CHANGELOG.md](./CHANGELOG.md).
5575

eslint.config.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import globals from 'globals';
2+
import pluginJs from '@eslint/js';
3+
import tseslint from 'typescript-eslint';
4+
5+
export default [
6+
{
7+
ignores: [
8+
'.*',
9+
'dist/**',
10+
'node_modules/**',
11+
'*.config.js'
12+
]
13+
},
14+
{
15+
files: ['**/*.{js,mjs,cjs,ts}']
16+
},
17+
{
18+
languageOptions: { globals: globals.browser }
19+
},
20+
pluginJs.configs.recommended,
21+
...tseslint.configs.recommended,
22+
];

jest.config.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export default {
2+
preset: 'ts-jest/presets/default-esm',
3+
extensionsToTreatAsEsm: ['.ts'],
4+
transform: {
5+
'^.+\\.tsx?$': [
6+
'ts-jest',
7+
{
8+
useESM: true,
9+
tsconfig: 'tsconfig.json'
10+
},
11+
],
12+
},
13+
testEnvironment: 'jsdom',
14+
};

0 commit comments

Comments
 (0)