typos

1.0.1 • Public • Published

Typos License NPM version Dependency Status Build Status Coverage Status

Calculate typos count on text writing.

npm i typos --save

How to use?

  • text - text to work with
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.

<script src="node_modules/typos/dist/typos.min.js></script>

License

MIT

Package Sidebar

Install

npm i typos

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • coderaiser