Skip to content
Merged

v3 #55

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

15 changes: 0 additions & 15 deletions .eslintrc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
node-version: [24.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/
coverage/
.nyc_output/
npm-debug.log
dist/
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## v3.0.0
Переработано API для возможности использовать в браузере.

## v2.5.6
В небезопасный словарь перенесены слова #22, #26:
- протёкший;
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2023 Denis Seleznev
Copyright (c) 2025 Denis Seleznev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
40 changes: 30 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,28 @@
Отсутствуют.

## Использование

### Node.js
```js
const Eyo = require('eyo-kernel');
import { Eyo } from 'eyo-kernel';
import { loadSafeDictionary, loadNotSafeDictionary } from 'eyo-kernel/load';

const text = 'Мой текст...';

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

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

// Загрузка собственного словаря.
const eyo = new Eyo();
// Также поддерживаются словари, сжатые с помощью gzip, *.txt.gz
eyo.dictionary.loadSync('./my_eyo_dict.txt');
console.log(eyo.restore(text));
console.log(eyo.lint(text));

// Создание собственного словаря.
const eyo = new Eyo();
// Добавить слово в свой словарь.
Expand All @@ -50,6 +49,27 @@ eyo.dictionary.removeWord('словоСБуквойЁ');
eyo.dictionary.clear();
```

### Браузер
```js
import { Eyo } from 'eyo-kernel';

const text = 'Мой текст...';

// Работа с безопасным встроенным словарём.
const safeEyo = new Eyo();
const safeDictionary = await fetch('./dictionary/safe.txt').then(response => response.text());
safeEyo.dictionary.set(safeDictionary);
console.log(safeEyo.restore(text));
console.log(safeEyo.lint(text));

// Работа с небезопасным встроенным словарём.
const notSafeEyo = new Eyo();
const notSafeDictionary = await fetch('./dictionary/not_safe.txt').then(response => response.text());
notSafeEyo.dictionary.set(notSafeDictionary);
console.log(notSafeEyo.restore(text));
console.log(notSafeEyo.lint(text));
```

## Словарь
Первоначально словарь взят из проекта [php-yoficator](https://github.com/rin-nas/php-yoficator/tree/master/Text). По доработкам словаря см. [CHANGELOG.md](./CHANGELOG.md).

Expand Down
22 changes: 22 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';

export default [
{
ignores: [
'.*',
'dist/**',
'node_modules/**',
'*.config.js'
]
},
{
files: ['**/*.{js,mjs,cjs,ts}']
},
{
languageOptions: { globals: globals.browser }
},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
];
14 changes: 14 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
preset: 'ts-jest/presets/default-esm',
extensionsToTreatAsEsm: ['.ts'],
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
useESM: true,
tsconfig: 'tsconfig.json'
},
],
},
testEnvironment: 'jsdom',
};
182 changes: 0 additions & 182 deletions lib/dictionary.js

This file was deleted.

Loading