fixnow 1.0.1 β 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -9
- package/dist/ar.cjs +6152 -0
- package/dist/ar.d.cts +10 -0
- package/dist/ar.d.ts +10 -0
- package/dist/ar.js +20 -0
- package/dist/chunk-FX7T7BEL.js +6118 -0
- package/dist/de.cjs +6152 -0
- package/dist/de.d.cts +10 -0
- package/dist/de.d.ts +10 -0
- package/dist/de.js +20 -0
- package/dist/en.cjs +6152 -0
- package/dist/en.d.cts +10 -0
- package/dist/en.d.ts +10 -0
- package/dist/en.js +20 -0
- package/dist/es.cjs +6152 -0
- package/dist/es.d.cts +10 -0
- package/dist/es.d.ts +10 -0
- package/dist/es.js +20 -0
- package/dist/fr.cjs +6152 -0
- package/dist/fr.d.cts +10 -0
- package/dist/fr.d.ts +10 -0
- package/dist/fr.js +20 -0
- package/dist/index.cjs +59 -33
- package/dist/index.d.cts +47 -12
- package/dist/index.d.ts +47 -12
- package/dist/index.js +14 -6080
- package/dist/pt.cjs +6152 -0
- package/dist/pt.d.cts +10 -0
- package/dist/pt.d.ts +10 -0
- package/dist/pt.js +20 -0
- package/dist/ru.cjs +6152 -0
- package/dist/ru.d.cts +10 -0
- package/dist/ru.d.ts +10 -0
- package/dist/ru.js +20 -0
- package/dist/vi.cjs +6152 -0
- package/dist/vi.d.cts +10 -0
- package/dist/vi.d.ts +10 -0
- package/dist/vi.js +20 -0
- package/package.json +81 -1
package/README.md
CHANGED
|
@@ -5,14 +5,16 @@
|
|
|
5
5
|
|
|
6
6
|
<br>
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
<h1></h1>
|
|
9
|
+
|
|
10
|
+
<br>
|
|
9
11
|
|
|
10
12
|
<a href="https://www.npmjs.com/package/fixnow"><img alt="NPM version" src="https://img.shields.io/npm/v/fixnow.svg?style=for-the-badge&labelColor=000000"></a>
|
|
11
13
|
<a href="https://www.npmjs.com/package/fixnow"><img alt="NPM Downloads" src="https://img.shields.io/npm/dm/fixnow.svg?style=for-the-badge&labelColor=000000"></a>
|
|
12
14
|
<a href="https://github.com/bastndev/fixnow/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/npm/l/fixnow.svg?style=for-the-badge&labelColor=000000"></a>
|
|
13
15
|
<a href="https://github.com/bastndev/fixnow/stargazers"><img alt="GitHub Stars" src="https://img.shields.io/github/stars/bastndev/fixnow.svg?style=for-the-badge&labelColor=000000"></a>
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
<h1></h1>
|
|
16
18
|
|
|
17
19
|
<p align="center">
|
|
18
20
|
<a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_ES.md">EspaΓ±ol πͺπΈ</a> |
|
|
@@ -57,10 +59,18 @@ npm i fixnow
|
|
|
57
59
|
```ts
|
|
58
60
|
import { checkText, suggest, createChecker } from "fixnow";
|
|
59
61
|
|
|
60
|
-
//
|
|
61
|
-
const
|
|
62
|
+
// English
|
|
63
|
+
const enIssues = await checkText("This sentance has a typo", {
|
|
64
|
+
language: "en",
|
|
65
|
+
suggestions: true,
|
|
66
|
+
});
|
|
67
|
+
// -> [{ offset: 5, length: 8, word: 'sentance', suggestions: [...] }]
|
|
68
|
+
|
|
69
|
+
// Spanish β opt in to accent leniency if you don't want "codigo" flagged.
|
|
70
|
+
const esIssues = await checkText("Esto es un herror", {
|
|
62
71
|
language: "es",
|
|
63
72
|
suggestions: true,
|
|
73
|
+
acceptAccentOmissions: true,
|
|
64
74
|
});
|
|
65
75
|
// -> [{ offset: 11, length: 6, word: 'herror', suggestions: [...] }]
|
|
66
76
|
|
|
@@ -80,15 +90,89 @@ const { checkText } = require("fixnow");
|
|
|
80
90
|
|
|
81
91
|
### API
|
|
82
92
|
|
|
83
|
-
- `checkText(text, options
|
|
84
|
-
- `isCorrect(word, language
|
|
85
|
-
- `suggest(word, { language
|
|
93
|
+
- `checkText(text, options)` β `Promise<SpellIssue[]>`
|
|
94
|
+
- `isCorrect(word, language, options?)` β `Promise<boolean>`
|
|
95
|
+
- `suggest(word, { language, max? })` β `Promise<string[]>`
|
|
86
96
|
- `createChecker(language)` β bound `{ check, suggest, isCorrect, warmup }`
|
|
87
97
|
- `warmup(language?)` β preload dictionaries (skip first-call decode cost)
|
|
98
|
+
- `tokenize(text, protectedSegments?)`, `DEFAULT_PROTECTED_PATTERN`
|
|
88
99
|
- `SUPPORTED_LANGUAGES`, `LANGUAGES`, `isSupportedLanguage`
|
|
89
100
|
|
|
90
|
-
**`CheckOptions`:** `language` (
|
|
91
|
-
`suggestions`, `maxSuggestions` (5), `minWordLength` (3),
|
|
101
|
+
**`CheckOptions`:** `language` (required), `caseSensitive` (false), `acceptAccentOmissions`
|
|
102
|
+
(false; Spanish only), `suggestions`, `maxSuggestions` (5), `minWordLength` (3),
|
|
103
|
+
`ignoreWords`, `flagWords`, `isProtectedWord`, `protectedSegments`.
|
|
104
|
+
|
|
105
|
+
### Tokenization
|
|
106
|
+
|
|
107
|
+
`checkText` skips anything inside a "protected segment" (code spans, URLs, emails, paths,
|
|
108
|
+
CLI flags, hex colors, ACRONYMS, file names and dotted identifiers). Override the
|
|
109
|
+
patterns with `protectedSegments`:
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import { checkText, DEFAULT_PROTECTED_PATTERN } from "fixnow";
|
|
113
|
+
|
|
114
|
+
// Use only your own pattern
|
|
115
|
+
await checkText(text, { language: "en", protectedSegments: /\{\{[^}]+\}\}/g });
|
|
116
|
+
|
|
117
|
+
// Compose with the default
|
|
118
|
+
await checkText(text, {
|
|
119
|
+
language: "en",
|
|
120
|
+
protectedSegments: [DEFAULT_PROTECTED_PATTERN, /\{\{[^}]+\}\}/g],
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Disable protection entirely
|
|
124
|
+
await checkText(text, { language: "en", protectedSegments: false });
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The same option is exposed on `tokenize(text, protectedSegments)`.
|
|
128
|
+
|
|
129
|
+
### Slim builds
|
|
130
|
+
|
|
131
|
+
If you only need one language, import it via the language subpath. Your bundler only
|
|
132
|
+
copies the dictionary you actually use:
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
import { check, suggest } from "fixnow/es";
|
|
136
|
+
|
|
137
|
+
const issues = await check("Esto es un herror", { suggestions: true });
|
|
138
|
+
await suggest("bonjoor", 3); // bound suggest is (word, max?)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The slim entries (`fixnow/ar`, `fixnow/de`, `fixnow/en`, `fixnow/es`, `fixnow/fr`,
|
|
142
|
+
`fixnow/pt`, `fixnow/ru`, `fixnow/vi`) re-export a checker pre-bound to that language.
|
|
143
|
+
|
|
144
|
+
## Migrating from 1.x
|
|
145
|
+
|
|
146
|
+
`2.0.0` cleans up three rough edges from the extraction-from-F1 release. Each is a
|
|
147
|
+
breaking change:
|
|
148
|
+
|
|
149
|
+
- **`language` is now required.** There is no default language anymore.
|
|
150
|
+
```ts
|
|
151
|
+
// before
|
|
152
|
+
await checkText("hola"); // implicitly Spanish
|
|
153
|
+
// after
|
|
154
|
+
await checkText("hola", { language: "es" });
|
|
155
|
+
```
|
|
156
|
+
- **`strict` is split into `caseSensitive` and `acceptAccentOmissions`.** The new
|
|
157
|
+
default is strict (the old `strict: true`). If you relied on `strict: false` to
|
|
158
|
+
tolerate Spanish accent omissions, opt in explicitly:
|
|
159
|
+
```ts
|
|
160
|
+
// before
|
|
161
|
+
await checkText("codigo", { language: "es" }); // accepted
|
|
162
|
+
// after
|
|
163
|
+
await checkText("codigo", { language: "es", acceptAccentOmissions: true });
|
|
164
|
+
```
|
|
165
|
+
The legacy `strict` key still works in 2.x with a `console.warn`; it is removed in `3.0.0`.
|
|
166
|
+
- **F1-specific markers are gone from the default tokenizer.** `[Image #1]`, `[Skills #β¦]`,
|
|
167
|
+
`/skills #N`, and `/skill` no longer auto-skip. If you need them, pass them via
|
|
168
|
+
`protectedSegments`:
|
|
169
|
+
```ts
|
|
170
|
+
const F1_MARKERS = /\[(?:Image|Code|Text) #\d+[^\]\n]*\]|\[Skills? #[^\]\n]+\]|\/skills #\d+|\/skill\b/g;
|
|
171
|
+
await checkText(text, {
|
|
172
|
+
language: "en",
|
|
173
|
+
protectedSegments: [DEFAULT_PROTECTED_PATTERN, F1_MARKERS],
|
|
174
|
+
});
|
|
175
|
+
```
|
|
92
176
|
|
|
93
177
|
## License
|
|
94
178
|
|