3.0.0 • Published 5 years ago

a-capsule v3.0.0

Weekly downloads
33
License
-
Repository
github
Last release
5 years ago

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.

$ npm i a-capsule

How to use

Using the Base (Memory) Storage

let Storage = require('a-capsule').getStorage();
Storage.set('hello', 'world');

Using the File Storage

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

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 for more details.

3.0.0

5 years ago