# fast-asar

> A faster implementation of Electron's ASAR archive format.

Latest version **1.0.9** (published 2023-10-30) · 0 weekly downloads

## Install

```sh
npm install fast-asar
pnpm add fast-asar
yarn add fast-asar
bun add fast-asar
```

Provides the command `fast-asar`.

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2023-10-30 |
| First published | 2023-10-14 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 177.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | luisafk |

## Links

- npm: https://www.npmjs.com/package/fast-asar
- npm.io page: https://npm.io/package/fast-asar

## Dependencies (2)

- [ansi-colors](https://npm.io/package/ansi-colors.md) ^4.1.3
- [chromium-pickle-js](https://npm.io/package/chromium-pickle-js.md) ^0.2.0

## Recent versions

- 1.0.9 (latest) — 2023-10-30
- 1.0.8 — 2023-10-28
- 1.0.7 — 2023-10-26
- 1.0.5 — 2023-10-17
- 1.0.4 — 2023-10-16
- 1.0.3 — 2023-10-15
- 1.0.2 — 2023-10-14
- 1.0.1 — 2023-10-14
- 1.0.0 — 2023-10-14

## README

# fast-asar

A faster implementation of Electron's ASAR archive format.

This is both a library and a CLI tool.

## Installation

You can install `fast-asar` from NPM (or your preferred package manager):

```sh
npm install fast-asar
```

## Usage

### CLI

You can use the CLI tool to extract and create ASAR archives.

```sh
npx fast-asar help
```

### Library

The library exports an `Asar` class, which can be used to read and write ASAR archives.

For example, to extract an ASAR archive to a directory:

```ts
import { Asar } from "fast-asar";
import { readFile } from "fs/promises";

const asarBytes = await readFile("./app.asar");

const asar = new Asar(asarBytes);

await asar.extract("./app-extracted");
```

For more information, see the [API documentation](https://lafkpages.github.io/fast-asar/).

## Compatibility

This library can be run with [Node.js](https://nodejs.org) and [Bun](https://bun.sh).

Browser support is planned.

## Benchmarks

The following benchmarks were run with [hyperfine](https://github.com/sharkdp/hyperfine) on a 2016 MacBook Pro with a 2.9 GHz Quad-Core Intel Core i7 processor and 16 GB of RAM.

### Extract files

This benchmark extracts all files in the Replit Desktop app's `app.asar` file.

| Command                                                                  |     Mean [ms] | Min [ms] | Max [ms] |    Relative |
| :----------------------------------------------------------------------- | ------------: | -------: | -------: | ----------: |
| `./node_modules/.bin/asar extract test/ignore/app.asar test/ignore/app1` |  670.0 ± 52.6 |    614.6 |    739.4 | 1.54 ± 0.41 |
| `bun ./src/cli/index.ts extract test/ignore/app.asar test/ignore/app2`   | 435.1 ± 110.9 |    373.7 |    632.3 |        1.00 |

Summary: `fast-asar` is 1.54 ± 0.41 times faster than `@electron/asar`.

To run this benchmark yourself, run `bun run benchmark:extract`.

### Pack directories

This benchmark packs the `src` directory into an ASAR archive at `test/ignore/src.asar`.

| Command                                                  |    Mean [ms] | Min [ms] | Max [ms] |    Relative |
| :------------------------------------------------------- | -----------: | -------: | -------: | ----------: |
| `./node_modules/.bin/asar pack src test/ignore/src.asar` | 154.7 ± 45.3 |    123.4 |    231.7 | 1.93 ± 0.57 |
| `bun ./src/cli/index.ts pack src test/ignore/src.asar`   |   80.0 ± 3.1 |     77.6 |     85.4 |        1.00 |

Summary: `fast-asar` is 1.93 ± 0.57 times faster than `@electron/asar`.

To run this benchmark yourself, run `bun run benchmark:pack`.

### List files

This benchmark lists all files in the Replit Desktop app's `app.asar` file.

| Command                                              |    Mean [ms] | Min [ms] | Max [ms] |    Relative |
| :--------------------------------------------------- | -----------: | -------: | -------: | ----------: |
| `./node_modules/.bin/asar list test/ignore/app.asar` | 136.0 ± 31.3 |    117.5 |    191.5 | 1.28 ± 0.30 |
| `bun ./src/cli/index.ts list test/ignore/app.asar`   |  106.0 ± 5.9 |    101.3 |    116.2 |        1.00 |

Summary: `fast-asar` is 1.28 ± 0.30 times faster than `@electron/asar`.

To run this benchmark yourself, run `bun run benchmark:list`.

## Contributing

### Running tests

For the tests, you must have the Replit Desktop app's `app.asar` file in the `test/ignore` directory.
You can get this file by installing the Replit Desktop app and copying the `app.asar` file from the installation directory.

Then, to run all tests:

```sh
bun pretest
bun test
```

---
_Source: https://npm.io/package/fast-asar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
