An open API service indexing awesome lists of open source software.

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

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