typos
v1.0.1
Published
calculate typos count on text writing
Downloads
28
Readme
Typos
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