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

@basisai/remote-zip

v0.2.7

Published

[API documentation](https://basisai.github.io/remote-zip)

Downloads

76

Readme

remote-zip

API documentation

Fetch file listings and individual files from a remote ZIP file.

Features

Without downloading the entire ZIP:

  • Fetch individual files in a remote ZIP
  • Fetch file listings

The gist of what the library does is:

  1. Get the content size of the ZIP file using a HTTP HEAD request.
  2. Get the last 100 bytes using HTTP Range queries (hoping it's enough) to read the end-of-central-directory (EOCD) section.
  3. Using the EOCD, read the central directory (CD) section with a Range request. This section contains a complete file listing and file byte offsets in the ZIP.
  4. To get individual files, use another Range request with an offset to get the local file header + compressed data.

Limitations

  • No ZIP64 support
  • No encrypted ZIP support
  • No stream support via ReadableStream due to testing/dev difficulties
  • Long comments in a ZIP file might cause populate() to fail

Install

yarn add @basisai/remote-zip
npm install --save @basisai/remote-zip

Usage

See the generated API documentation.

If using in the browser, the server will need to whitelist CORS for GET, HEAD, and the Range header.

Basic

const url = new URL("http://www.example.com/test.zip");
const remoteZip = await new RemoteZipPointer({ url }).populate();
const fileListing = remoteZip.files(); // RemoteZipFile[]
const uncompressedBytes = await remoteZip.fetch("test.txt"); // ArrayBuffer

With more features

const method = "POST";
const additonalHeaders = new Headers();
additonalHeaders.append("X-Example", "foobar");
const url = new URL("http://www.example.com/test.zip");
const remoteZip = await new RemoteZipPointer({
  url,
  additionalHeaders,
  method,
  credentials: "include",
}).populate();
const uncompressedBytes = await remoteZip.fetch("test.txt", additionalHeaders);

Dev

  • yarn d watch and build
  • yarn t:watch watch and test
  • yarn lint
  • yarn build

Run tests and checks with Docker

docker-compose -f docker-compose.test.yml up --build

Publish

Setup

  1. Get an automation token from npm under settings

    https://www.npmjs.com/settings/aicadium/tokens/
  2. Add the token to your repository secrets.

    https://github.com/$YOUR_USERNAME/$YOUR_REPO_NAME/settings/secrets/actions/new
    • Name: NPM_TOKEN
    • Value: The automation token you got from the previous step

Run

  1. Create a new release.

    https://github.com/$YOUR_USERNAME/$YOUR_REPO_NAME/releases

    The workflow at ./github/workflows/publish.yml should run and publish your packages to both NPM and GitHub Packages.

    Don't forget to bump your version number in package.json before this.