libzim-binding
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.3 • Public • Published

    libzim-binding

    Build Status

    This package was build using nbind

    Dependencies

    You will need a copy of Libzim installed on your machine. Libzim be be included in this library at some point in the future, but for now install it (see here).

    Usage

    npm i libzim-binding
    

    Building a Zim file

    // write.ts
    import { ZimArticle, ZimCreator } from "libzim-binding";
    
    (async () => {
    
        console.info('Starting');
        const creator = new ZimCreator('test.zim', { welcome: 'index.html', favicon: './favicon.png' });
    
        for (let i = 100; i > 0; i--) {
            const a = new ZimArticle(`file${i}`, `Content ${i}`);
            await creator.addArticle(a);
        }
    
        const welcome = new ZimArticle(`index.html`, `<h1>Welcome!</h1>`);
        await creator.addArticle(a);
    
        await creator.finalise();
    
        console.log('Done Writing');
    
    })();

    Reading a Zim file

    // read.ts
    
    import { ZimArticle, ZimReader } from "libzim-binding";
    
    (async () => {
    
        const zimFile = new ZimReader('test.zim');
    
        const suggestResults = await zimFile.suggest('Content');
        console.info(`Suggest Results:`, suggestResults);
    
        const searchResults = await zimFile.search('Content');
        console.info(`Search Results:`, searchResults);
    
        const article3Content = await zimFile.getArticleByUrl('./file3');
        console.info(`Article by url (./file3):`, article3Content);
    
    })();

    License

    MIT - ./LICENSE

    Keywords

    none

    Install

    npm i libzim-binding

    DownloadsWeekly Downloads

    1

    Version

    0.2.3

    License

    MIT

    Unpacked Size

    34.5 kB

    Total Files

    27

    Last publish

    Collaborators

    • isnit