npm.io
1.0.1 • Published 3d ago

spellcore-worker

Licence
MIT
Version
1.0.1
Deps
2
Size
39 kB
Vulns
0
Weekly
0

spellcore-worker

Web Worker bindings for the SpellCore ecosystem.

Running spell checking synchronously on the main thread can cause frame drops, especially if analyzing massive text blocks. This package provides lightweight wrappers that run your ISpellChecker instance inside a background Web Worker, returning promises for asynchronous results without locking the UI.

Installation

npm install spellcore-worker spellcore-core

Usage

You can use the worker in vanilla JS or pair it seamlessly with the spellcore-react package hooks.

// Define your spell worker (e.g. spell.worker.ts)
import { SpellCheckerWorker } from 'spellcore-worker';
import { createSpellChecker } from 'spellcore-core';
import { englishDictionary } from 'spellcore-dictionaries';

const checker = createSpellChecker({}, englishDictionary);

// Listen and reply to messages
new SpellCheckerWorker(checker).listen();

Keywords