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

web-bundle

v1.1.4

Published

Tool to pack binary files into a PNG image.

Downloads

23

Readme

Web Bundle

  • Tool to pack binary files into a PNG image.
  • Users can load a bundle.wp file and extract its data indexed by the original file's path.
    • A file in the folder root/img/logo.png can be accessed by bundle.read("img/logo.png") == Uint8Array
    • Helper methods allow users to read the desired data format.
      • var d = bundle.readJSON("data/file.json") == object
      • var s = bundle.readText("data/file.txt") == string
      • var img = bundle.readImg("img/logo.jpg") == ImageElement

Example Bundle

This PNG contains the following files:

  • xml.dae
  • data.json
  • portrait.png

packed bundle

Why Bundle stuff ?

  • Significantly reduce the number of HTTP requests allowing fast page loads
  • Text data can be at least 40% compressed
  • Browsers decompression routines are native and fast
  • Games can greatly benefit of the compression and data packing
  • No need to create and manage your own pack data type

Compression [CLI]

  • Install the wb tool with $ npm install web-bundle, or find it in tool/wb.js
  • In the command line, run $ wb encode -o my-bundle.wb foo.json bar.png
  • After running, foo.json and bar.png will be stored in my-bundle.png
  • Use --output or -o to choose the output location for the bundle
  • Use --add or a to add files to an existing bundle instead of creating a new one
  • See wb --help for more

Compression [Node.JS]

  • Install web-bundle with npm install --save web-bundle
var wb = require('web-bundle');

var bundle = new wb.Bundle();
bundle.addFile('foo.png', function(err) {
  // some/dir/foo.png has been added to the bundle
  
  bundle.write('bundle.wb', function(err) {
    // Bundle written
  });
});

Decompression [JavaScript, browser]

  • Add the scripts deploy/js/wb.js or deploy/js/wb.min.js to your page.
var b = new Bundle();
b.load("data/output.wb",function(bundle,progress)
{
	if(progress >= 1.0)
	{
		if(bundle != null)
		{
			bundle.read[Text|JSON|Img|...]("data-id");
		}
	}
},[password]);

Decompression [Haxe]

  • Make sure <script src='js/wb.js'/> exists in your page.
  • Make sure the web-bundle library is installed and linked in your project.
    • Use haxelib to install the library.
    • haxelib git web-bundle https://github.com/haxorplatform/web-bundle.git 1.0
import js.Bundle;

var b : Bundle = new Bundle();
b.load("data/output.wb",function(bundle:Bundle,progress:Float)
{
	if(progress >= 1.0)
	{
		if(bundle != null)
		{
			bundle.read[Text|JSON|Img|...]("data-id");
		}
	}
},[password]);

Decompression [Node.JS]

  • Install with $ npm install --save web-bundle
var wb = require('web-bundle');

var bundle = new wb.Bundle();
bundle.load('my-bundle.wb', function(err) {
  // Bundle loaded
  bundle.read('foo.json') // -> Buffer
  bundle.readString('foo.json') // -> string
  bundle.readJSON('foo.json') // -> Object
});

Decompression [CLI]

  • Install the wb tool with $ npm install web-bundle, or find it in tool/wb.js
  • To see the contents of a bundle, run $ wb ls my-bundle.wb
  • To extract all files, use $ wb decode my-bundle.wb
  • Specify an output location with --output or -o: $ wb decode my-bundle.wb --output some/dir
  • Extract a single file with --extract or -e: $ wb decode my-bundle.wb --extract foo.png
  • See $ wb --help for more