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

siar

v1.0.1

Published

A simple random-access archive format.

Downloads

10

Readme

Siar

A simple random-access archive format.

A siar archive is a single binary file, containing a sha256 hash of the rest of the archive, followed by the length of the header, followed by the UTF8-encoded JSON header, followed by the concatenated contents of all the files.

Paths inside the archive are always stored using / as the separator, with no prefix (e.g. / or ./), and are case sensitive.

Features

  • The siar archive format is super simple.
  • A file can be extracted from a siar archive efficiently, with random access.
  • A siar archive can be pretty compact, for lots of small files it's significantly smaller than a tarball.
  • A siar archive can be created and read in the browser too.

Install

npm install --save siar

Usage

You would use the CLI commands like this:

# Pack a folder into an archive
siar pack my-folder my-archive.siar

# Unpack an archive into a folder
siar unpack my-archive.siar my-folder

# List the content of an archive
siar ls my-archive.siar

# Extract a single file from an archive
siar extract my-archive.siar path/to/file.txt path/to/output_file.txt

# View a single file from an archive, without extracting it
siar view my-archive.siar path/to/file.txt

You would use the programmatic API like this:

import {extract, get, ls, make, pack, read, unpack, visit} from 'siar';

// Pack a folder into an archive -- just like with the "pack" command

await pack ( 'my-folder', 'my-archive.siar' );

// Unpack an archive into a folder -- just like with the "unpack" command

unpack ( 'my-archive.siar', 'my-folder' );

// List the content of an archive -- just like with the "ls" command

ls ( 'my-archive.siar' );

// Extract a single file from an archive -- just like with the "extract" command

extract ( 'my-archive.siar', 'path/to/file.txt', 'path/to/output_file.txt' );

// View a single file from an archive, without extracting it -- just like with the "view" command

view ( 'my-archive.siar', 'path/to/file.txt' );

// Read a single file from an archive -- like "extract" but it just gives you the file

const file = read ( 'my-archive.siar', 'path/to/file.txt' );

// Make an archive from a map of files -- this function works in the browser too

const archive = await make ({
  'path/to/file.txt': {
    content: new Uint8Array (),
    mode: 0o644, // Optional
    mtime: 123456789 // Optional
  },
  'path/to/another-file.txt': {
    content: new Uint8Array ()
  }
});

// Get a single file from an archive -- this function works in the browser too

const file = get ( archive, 'path/to/file.txt' );

// Visit files or folders in an archive -- this function works in the browser too

visit ( archive, file => { // Files only
  file.name; // => 'file.txt'
  file.path; // => 'path/to/file.txt'
  file.content; // => Uint8Array ()
  file.mode; // => 0o644
  file.mtime; // => 123456789
});

visit ( archive, folder => { // Folders only
  folder.name; // => 'folder'
  folder.path; // => 'path/to/folder'
}, 'folder' );

visit ( archive, entry => { // Files and folders
  if ( 'content' in entry ) {
    console.log ( 'It is a file', entry );
  } else {
    console.log ( 'It is a folder', entry );
  }
}, '*' );

License

MIT © Fabio Spampinato