# a-capsule

> A simple storage module.

Latest version **3.0.0** (published 2019-03-15) · 0 weekly downloads

## Install

```sh
npm install a-capsule
pnpm add a-capsule
yarn add a-capsule
bun add a-capsule
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2019-03-15 |
| First published | 2019-03-15 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | ryzzzen |
| Keywords | storage, simple, encryption, file, json |

## Links

- npm: https://www.npmjs.com/package/a-capsule
- Repository: https://github.com/Ryzzzen/storage-pod
- Issues: https://github.com/Ryzzzen/storage-pod/issues
- npm.io page: https://npm.io/package/a-capsule

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 3.0.0 (latest) — 2019-03-15

## README

# a-capsule

#### Changelog

> - 3.0.0 is out
> - SAMSS (Simple And Modular Storage System) is now a-capsule!

a-capsule is easy to use:

  - Lightweight
  - Contains 3 storage types: Storage, FileStorage and EncryptedStorage.
  - Based on promises and async/await, but also contains synchronous methods.

### Installation

a-capsule requires zero dependencies.

Install a-capsule using npm.

```sh
$ npm i a-capsule
```

## How to use

Using the Base (Memory) Storage
```js
let Storage = require('a-capsule').getStorage();
Storage.set('hello', 'world');
```
Using the File Storage
```js
const { FileStorage } = require('a-capsule');
let Storage = new FileStorage('file.json');

Storage.load().then(() => {
  await Storage.default()
  .add('hello', 'world')
  .add('this', ['is', 'a', 'default', 'value'])
  .end();

	await Storage.save();
}
```

Using the Encrypted Storage
```js
const { EncryptedStorage } = require('a-capsule');
let Storage = new EncryptedStorage('encrypted_file.random.ext', 'THIS_IS_THE_PASSWORD', 'aes256');

await Storage.load();

await Storage.default()
.add('hello', 'world')
.add('this', ['is', 'a', 'default', 'value'])
.end();

await Storage.save();
```
> - Storage#default()#end() tries to save the storage.
>
> - If the file doesn't exist, it gives an empty object, instead of an ENOENT error.

### License

This project is licensed under the MIT License. You can check [here](https://www.opensource.org/licenses/mit-license.php) for more details.

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