Skip to content

Commit 04498db

Browse files
committed
docs: fix up README and add API docs link
1 parent db29fbd commit 04498db

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

README.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@
22

33
[![Test](https://github.com/electron/asar/actions/workflows/test.yml/badge.svg)](https://github.com/electron/asar/actions/workflows/test.yml)
44
[![npm version](http://img.shields.io/npm/v/@electron/asar.svg)](https://npmjs.org/package/@electron/asar)
5+
[![API docs](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fregistry.npmjs.org%2F%40electron%asar%2Flatest&query=%24.version&logo=typescript&logoColor=white&label=API%20Docs
6+
)](https://packages.electronjs.org/asar)
57

6-
Asar is a simple extensive archive format, it works like `tar` that concatenates
7-
all files together without compression, while having random access support.
8+
ASAR is a simple extensive archive format. It concatenates all files together without compression
9+
(like [`tar`](https://www.gnu.org/software/tar/)) while having random access support.
810

911
## Features
1012

1113
* Support random access
12-
* Use JSON to store files' information
14+
* Use JSON to store file information
1315
* Very easy to write a parser
1416

15-
## Command line utility
17+
## CLI
1618

1719
### Install
1820

1921
This module requires Node 22.12.0 or later.
2022

2123
```bash
22-
$ npm install --engine-strict @electron/asar
24+
npm install --engine-strict @electron/asar
2325
```
2426

2527
### Usage
@@ -54,7 +56,8 @@ $ asar --help
5456
#### Excluding multiple resources from being packed
5557

5658
Given:
57-
```
59+
60+
```text
5861
app
5962
(a) ├── x1
6063
(b) ├── x2
@@ -67,21 +70,26 @@ Given:
6770
```
6871

6972
Exclude: a, b
73+
7074
```bash
71-
$ asar pack app app.asar --unpack-dir "{x1,x2}"
75+
asar pack app app.asar --unpack-dir "{x1,x2}"
7276
```
7377

7478
Exclude: a, b, d, f
79+
7580
```bash
76-
$ asar pack app app.asar --unpack-dir "**/{x1,x2}"
81+
asar pack app app.asar --unpack-dir "**/{x1,x2}"
7782
```
7883

7984
Exclude: a, b, d, f, h
85+
8086
```bash
81-
$ asar pack app app.asar --unpack-dir "{**/x1,**/x2,z4/w1}"
87+
asar pack app app.asar --unpack-dir "{**/x1,**/x2,z4/w1}"
8288
```
8389

84-
## Using programmatically
90+
## Programmatic usage
91+
92+
For full API usage, see the [API documentation](https://packages.electronjs.org/asar).
8593

8694
### Example
8795

@@ -98,6 +106,7 @@ console.log('done.');
98106
Please note that there is currently **no** error handling provided!
99107

100108
### Transform
109+
101110
You can pass in a `transform` option, that is a function, which either returns
102111
nothing, or a `stream.Transform`. The latter will be used on files that will be
103112
in the `.asar` file to transform them (e.g. compress).
@@ -122,7 +131,7 @@ Asar uses [Pickle][pickle] to safely serialize binary value to file.
122131

123132
The format of asar is very flat:
124133

125-
```
134+
```markdown
126135
| UInt32: header_size | String: header | Bytes: file1 | ... | Bytes: file42 |
127136
```
128137

@@ -200,9 +209,10 @@ because file size in Node.js is represented as `Number` and it is not safe to
200209
convert `Number` to UINT64.
201210

202211
`integrity` is an object consisting of a few keys:
212+
203213
* A hashing `algorithm`, currently only `SHA256` is supported.
204214
* A hex encoded `hash` value representing the hash of the entire file.
205-
* An array of hex encoded hashes for the `blocks` of the file. i.e. for a blockSize of 4KB this array contains the hash of every block if you split the file into N 4KB blocks.
206-
* A integer value `blockSize` representing the size in bytes of each block in the `blocks` hashes above
215+
* An array of hex encoded hashes for the `blocks` of the file (i.e. for a blockSize of 4KB, this array contains the hash of every block if you split the file into N 4KB blocks).
216+
* A integer value `blockSize` representing the size in bytes of each block in the `blocks` hashes above.
207217

208218
[pickle]: https://chromium.googlesource.com/chromium/src/+/main/base/pickle.h

0 commit comments

Comments
 (0)