Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.
/ dict-js Public archive

JavaScript library for reading dictd and StarDict dictionaries

License

Notifications You must be signed in to change notification settings

johnfactotum/dict-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Moved to https://github.com/johnfactotum/foliate-js

dict-js

A small JavaScript library for reading dictd and StarDict dictionaries.

Usage

import { StarDict } from './dict.js'
import { inflate } from 'your inflate implementation'

const { ifo, dz, idx, syn } = { /* `File` (or `Blob`) objects */ }
const dict = new StarDict()
await dict.loadIfo(ifo)
await dict.loadDict(dz, inflate)
await dict.loadIdx(idx)
await dict.loadSyn(syn)

// look up words
const query = '...'
await dictionary.lookup(query)
await dictionary.synonyms(query)

Note that you must supply your own inflate function. Here is an example using fflate:

const inflate = data => new Promise(resolve => {
    const inflate = new fflate.Inflate()
    inflate.ondata = data => resolve(data)
    inflate.push(data)
})

License

MIT.

About

JavaScript library for reading dictd and StarDict dictionaries

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published