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

lambdafs

v2.1.1

Published

Efficient (de)compression package for AWS Lambda

Downloads

185,774

Readme

LambdaFS

lambdafs TypeScript Donate

Efficient (de)compression package for AWS Lambda, supporting Brolti, Gzip and Tarballs

Install

npm install lambdafs --save-prod

CLI

This package provides a brotli CLI command to conveniently compress files and/or folders.

npx lambdafs /path/to/compress

The resulting file will be a (potentially tarballed) Brotli compressed file, with the same base name as the source.

Due to the highest compression level, it might take a while to compress large files (100MB ~ 5 minutes).

Usage

The nodejs12.x or nodejs14.x AWS Lambda runtime is required for this package to work properly.

const lambdafs = require('lambdafs');

exports.handler = async (event, context) => {
  try {
    let file = __filename; // /var/task/index.js
    let folder = __dirname; // /var/task

    // Compressing
    let compressed = {
      file: await lambdafs.deflate(file), // /tmp/index.js.gz
      folder: await lambdafs.deflate(folder), // /tmp/task.tar.gz
    };

    // Decompressing
    let decompressed = {
      file: await lambdafs.inflate(compressed.file), // /tmp/index.js
      folder: await lambdafs.inflate(compressed.folder), // /tmp/task
    };

    return context.succeed({ file, folder, compressed, decompressed });
  } catch (error) {
    return context.fail(error);
  }
};

API

deflate(path: string): Promise<string>

Compresses a file/folder with Gzip and returns the path to the compressed (tarballed) file.

The resulting file will be saved under the default temporary directory (/tmp on AWS Lambda).

Due to costly execution time on AWS Lambda, Gzip is always used to compress files.

inflate(path: string): Promise<string>

Decompresses a (tarballed) Brotli or Gzip compressed file and returns the path to the decompressed file/folder.

The resulting file(s) will be saved under the default temporary directory (/tmp on AWS Lambda).

Supported extensions are: .br, .gz, .tar, .tar.br (and .tbr), .tar.gz (and .tgz).

For tarballs, original file modes are perserved. For any other files 0700 is assumed.

Rationale

Getting large resources onto AWS Lambda can be a challenging task due to the deployment package size limit:

| Limit | Context | | ------ | --------------------------- | | 50 MB | Zipped, for direct uploads. | | 250 MB | Unzipped, S3 and layers. |

For this reason, it's important to achieve a very high compression ratio as well as fast decompression times.

This is where the Brotli algorithm comes in:

Brotli Benchmarks

It allows us to get the best compression ratio and fast decompression times (at the expense of a slow compression).

License

MIT