https://github.com/coderaiser/typos
calculate typos count on text writing
https://github.com/coderaiser/typos
count javascript nodejs typos
Last synced: 6 months ago
JSON representation
calculate typos count on text writing
- Host: GitHub
- URL: https://github.com/coderaiser/typos
- Owner: coderaiser
- License: mit
- Created: 2017-04-27T09:05:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-10T08:45:09.000Z (over 7 years ago)
- Last Synced: 2025-06-11T22:04:56.657Z (7 months ago)
- Topics: count, javascript, nodejs, typos
- Language: JavaScript
- Size: 10.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog
- License: LICENSE
Awesome Lists containing this project
README
# Typos [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
Calculate typos count on text writing.
```
npm i typos --save
```
### How to use?
- `text` - text to work with
```js
const typos = require('typos');
const text = 'hello world';
const type = typos(text);
type.on('add', ({symbol, cursor}) => {
console.log(`added ${symbol} number ${cursor}`);
});
type.on('error', (error) => {
const {
message,
current,
symbol,
count,
} = error;
console.error(`${message}`);
console.error(`Errors count: ${count}`);
console.error(`Expected ${current}`);
console.error(`Received ${symbol}`);
});
type.on('end', (result) => {
const {
length,
errorsCount,
} = result;
console.log(`text length: ${length}`);
console.log(`errors count : ${errorsCount}`);
});
const add = type.add.bind(type);
text.split('')
.forEach(add);
```
## Usage in Browser
Add script tag to use minified version of `typos`.
```html