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

zip-file-server

v0.4.1

Published

ZipFileServer is a lightweight library that serves as an intermediary between the web client and the server

Downloads

11

Readme

ZipFileServer is a lightweight library that serves as an intermediary between the web client and the server.

It provides an efficient way to package and download numerous fragmented files as required.

The Core zip inflate feature is based on zip.js.

Table of Contents

Overview

When ZipFileServer receives a file request, it prioritizes searching and delivering from the corresponding remote zip package.

This process is seamless for both the client and the server.

Installation

To install ZipFileServer, run the following command:

npm install zip-file-server

Usage

Please refer to the provided example for detailed usage.

  import {ZipFileServer} from '../dist/main.js';

  const server = new ZipFileServer({
    remotes: [
      {
        name: 'bundle',
        prefix: 'bundle/',
        zipUrl: 'bundle.zip'
      },
      {
        name: 'res',
        prefix: 'res/',
        zipUrl: 'res.zip'
      }
    ],
    fallbackUrl: '/example/',
    fetch: (opt) => fetch(opt)
  });

  window.server = server;

  function showImg(url) {
    return new Promise(resolve => {
      const img = new Image();
      server.getUrl(url).then(({url, onComplete}) => {
        img.src = url;
        img.onload = () => {
          onComplete();
          resolve();
        };
      });
      document.body.appendChild(img);
    })
  }

  server.preload('res').then(() => {
    console.log('preload res.zip done');

    // no need to load res.zip again
    showImg('res/img.png').then(() => {
      console.log('load res/img.png done');

      // unload res.zip
      server.unload('res');

      // this time will load res.zip again
      showImg('res/img2.png').then(() => {
        console.log('load res/img2.png done');
      });
    });
  });

  server.getData('bundle/data.json')
    .then(data => data.json())
    .then(data => console.log('data.json', data));

  showImg('bundle/img.png');

  server.getData('bundle/info.txt').then(res => res.text()).then(data => {
    console.log('info.txt', data);
  });

License

ZipFileServer is BSD-3-Clause licensed