npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

libzim

v1.0.0

Published

Bindings to zimlib (read/write OpenZIM files)

Downloads

26

Readme

libzim

NPM

Build Status dependency status dev dependency status

The node libzim package binds to the zimlib library from OpenZIM to allow read/write access to ZIM files.

USAGE

var zim = require('libzim');

class TestArticle extends zim.writer.Article {
  constructor(id) {
    super();
    this._id = id;
    this._data = new Buffer("this is article " + id);
  }
  getAid() { return this._id; }
  getNamespace() { return 'A'; }
  getUrl() { return this._id; }
  getTitle() { return this._id; }
  isRedirect() { return false; }
  getMimeType() { return "text/plain"; }
  getRedirectAid() { return ""; }
  getData() {
    return new zim.Blob(this._data);
  }
}

class TestArticleSource extends zim.writer.ArticleSource {
  constructor(max = 16, szfunc) {
    super();
    this._next = 0;
    this._articles = [];
    this.getCurrentSize = szfunc;
    for (var n = 0; n < max ; n++) {
      this._articles[n] = new TestArticle("" + (n+1));
    }
  }
  getNextArticle() {
    console.log('After ' + this._next + ' articles:',
                this.getCurrentSize(), 'bytes');
    return this._articles[this._next++];
  }
}

c = new zim.writer.ZimCreator();
src = new TestArticleSource(8, () => c.getCurrentSize());
c.create("foo.zim", src);

INSTALLING

You can use npm to download and install:

  • The latest libzim package: npm install libzim

  • GitHub's master branch: npm install https://github.com/cscott/node-libzim/tarball/master

In both cases the module is automatically built with npm's internal version of node-gyp, and thus your system must meet node-gyp's requirements.

It is also possible to make your own build of libzim from its source instead of its npm package (see below).

BUILDING FROM THE SOURCE

Unless building via npm install (which uses its own node-gyp) you will need node-gyp installed globally:

npm install node-gyp -g

The libzim module depends only on the zimlib library from OpenZIM. By default, an internal/bundled copy of OpenZIM's zimlib will be built and statically linked, so an externally installed zimlib is not required.

If you wish to install against an external zimlib then you need to pass the --libzim argument to node-gyp, npm install or the configure wrapper.

./configure --libzim=external
make

Or, using the node-gyp directly:

 node-gyp --libzim=external rebuild

Or, using npm:

 npm install --libzim=external

If building against an external zimlib make sure to have the development headers available. Mac OS X ships with these by default. If you don't have them installed, install the -dev package with your package manager, e.g. apt-get install libzim-dev for Debian/Ubuntu.

TESTING

mocha is required to run unit tests.

npm install mocha
npm test

API

We follow the zimlib API closely where possible.

new zim.Blob(Buffer data)

Creates an object representing the data in the supplied node [Buffer][].

zim.Blob#data → [Buffer][]

Returns a buffer object containing the data represented by this blob. This buffer is live: changing the values in the buffer will change the data in the blob.

zim.Blob#sizenumber

Returns the (uncompressed) number of bytes of data in this blob.

number zim.Dirent.redirectMimeType

Integer index used as the mime type for redirect articles.

number zim.Dirent.linktargetMimeType

Integer index used as the mime type for link target articles.

number zim.Dirent.deletedMimeType

Integer index used as the mime type for deleted articles.

CONTRIBUTORS

RELATED PROJECTS

LICENSE

Copyright (c) 2016 C. Scott Ananian.

libzim is licensed using the same license as the zimlib library in OpenZIM: GPLv2.