https://github.com/richarddorian/asar-lightweight
A lightweight version of asar
https://github.com/richarddorian/asar-lightweight
Last synced: 3 months ago
JSON representation
A lightweight version of asar
- Host: GitHub
- URL: https://github.com/richarddorian/asar-lightweight
- Owner: RichardDorian
- License: mit
- Created: 2022-05-11T19:03:01.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-01T18:34:35.000Z (almost 3 years ago)
- Last Synced: 2023-03-06T23:39:23.126Z (about 2 years ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/asar-lightweight
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# asar-lightweight
`asar-lightweight` is a lightweight library to read and write asar archives.
It uses the same format as original asar files. Here you can read archives directly using buffers which means you have a total control over the archive, how you get it and how you store it.
# Usage
## Installation
```bash
$ npm install asar-lightweight
```## Importation
```js
const asar = require('asar-lightweight'); // CommonJSimport * as asar from 'asar-lightweight'; // ES6
```## Reading
```js
const asar = require('asar-lightweight');
const fs = require('fs');// Getting the file from the file system (but you can get the Buffer from another source)
const archive = fs.readFileSync('/path/to/archive.asar');// Now you can read it
// Remember the function is asynchronous
(async () => {
const content = await asar.readArchive(archive);
// Do stuff with `content`
})();
```## Writing
```js
const asar = require('asar-lightweight');
const fs = require('fs');// Getting the file from the file system (but you can get the Buffer from another source)
const archive = fs.readFileSync('/path/to/archive.asar');// Now you can read it, edit the data and then write it back
// Remember those functions are asynchronous
(async () => {
const content = await asar.readArchive(archive);// Do stuff with `content`
const packed = await asar.writeArchive(content);
})();
```