Byteroo - Key-value storage for your Node.js applications

Overview

Byteroo

codecov

Byteroo is a key-value storage for your Node.js applications.

Usage:

const Byteroo = require('byteroo');
const storage = new Byteroo({
	name: 'mystorage',
	path: '/path/to/storage',
});
const container = storage.getContainerSync('users');
/* or
const container = await storage.getContainer('sync');
*/
Property Description
name Name of your storage, used to automatically find a path in case it's not provided
path [optional] Path where all the containers will be stored, created automatically if doesn't exist
// adding new value
container.set('[email protected]', 'value');

// retrieving a value
container.get('[email protected]'); // -> 'value'

// removing a value
container.remove('[email protected]');

// saving data to disk
container.commit();

Storing data in memory

You can store your data in memory by using the IN_MEMORY_STORAGE constant exported by the module.

const constants = require('byteroo/constants');
{
	path: constants.IN_MEMORY_STORAGE;
}

This will disable the commit() function (you can still call it without any error) and the data won't be stored to disk.

You might also like...

A technology stack solution using the AWS Serverless architecture.Atlas stack for building applications focused on generating value.

Atlas A technology stack solution using the AWS Serverless architecture.Atlas stack for building applications focused on generating value. Description

Dec 15, 2022

Sheetzapper imports your account value accross Zapper.fi supported wallets and dapps into a Google Sheet

Sheetzapper imports your account value accross Zapper.fi supported wallets and dapps into a Google Sheet

Overview Sheetzapper imports your account value accross Zapper.fi supported wallets and dapps into a Google Sheet. This allows you to chart your net w

Nov 27, 2022

Utility to show key-presses on your browser

Utility to show key-presses on your browser

Show-Keys Extension A Chrome Extension wrapper around @siddharthkp's script to show Key Press on a website. PS - A lot of websites block this function

Jul 9, 2022

Create your own wrappings with optional key bindings for selected text, a set of useful defaults is also provided.

Create your own wrappings with optional key bindings for selected text, a set of useful defaults is also provided.

Jan 1, 2023

A TypeScript namespace declaration for KeyboardEvent.key strings, just in case your code is allergic to enums.

ts-key-namespace A TypeScript namespace declaration for KeyboardEvent.key strings, just in case you prefer namespaces to enums. Largely based on ts-ke

Apr 5, 2022

Long-press `⌘` key or press `?` to present a shortcut guide for your Web application.

Long-press `⌘` key or press `?` to present a shortcut guide for your Web application.

React Shortcut Guide Status: Alpha Long-press command or press ? to present a shortcut guide for your Web application. Gzip+minify 3kB Install npm i

Jul 29, 2022

Easily create key board shortcuts for your JS functions. Built using JS only with no other dependency. Inspired from MacOS spotlight

floodlightjs Inspired from macOS spotlight, floodlight is simple JS library that will show a search area. How the search is handled is completely on y

Aug 12, 2022

A collection of Aurelia 2 example applications showcasing how to build Aurelia 2 applications and other tasks.

Aurelia 2 Examples A monorepository of a treasure trove of Aurelia 2 example applications you can use as a guide to help you build your own applicatio

Dec 29, 2022

It consists of a recreation of Twitter, to put into practice both Front-end and Back-end knowledge by implementing the MERN Stack together with other technologies to add more value to the project.

Twitter-Clone_Back-end ✨ Demo. 💻 About the project. 📜 Descriptions. It consists of a recreation of Twitter, to put into practice knowledge of both F

Apr 12, 2022
Comments
  • File corruption when calling multiple saves at the same time

    File corruption when calling multiple saves at the same time

    Issue description

    When using set and remove at the same time (or any method that triggers the file-save), the file gets corrupted.

    const Byteroo = require('byteroo').default;
    const storage = new Byteroo({
      name: 'test',
      path: './test',
      autocommit: true
    });
    const container = storage.getContainerSync('users');
    
    container.set('test1', 'test1');
    container.set('test2', 'test2');
    container.remove('test1');
    

    This should result in file having the following contents: {"test2":"test2"}, but it ends up being {"test2":"test2"}"test2":"test2"}.

    The issue originates in src/utils/saveData.ts, where an asynchronous method is used to save the files. Here's a snippet that can replicate the issue:

    const { writeFile } = require('fs');
    
    const saveData = (path, data) => {
    	return new Promise(async (resolve, reject) => {
    		writeFile(path, data, (err) => {
    			if (err) return reject(err);
    			resolve();
    		});
    	});
    };
    
    saveData('./file1.txt', 'HELLO WORLD');
    saveData('./file1.txt', 'TEST');
    

    This is essentially what happens in the Byteroo example shown before, we call two asynchronous methods at the same time and instead of getting "TEST", we get "TESTO WORLD".

    bug 
    opened by JMax45 0
Releases(v1.3.1)
  • v1.3.1(Sep 15, 2022)

    Bug Fixes

    • handle invalid JSON data on deserialize https://github.com/JMax45/byteroo/commit/e84ddca707b1dcc914a9a43433d2ac49a7c44c36
    • file corruption when calling parallel saves https://github.com/JMax45/byteroo/commit/91e35d40750b5da738d26d1f2200836c45ee3c1d
    Source code(tar.gz)
    Source code(zip)
  • v1.3.0(Sep 11, 2022)

    Features

    • add CacheContainer https://github.com/JMax45/byteroo/commit/884b63ad26ad655fffcf1eee2de58866dce708b8
    • add retrieval method for CacheContainer https://github.com/JMax45/byteroo/commit/393f2133205cd2b9387f4c6f2dd148ee36c05c3c

    Documentation

    • add CacheContainer section to README https://github.com/JMax45/byteroo/commit/a2915131506a9b62f882ea203ab1d13cb3f9f36c

    Refactoring

    • rename SimpleStorage to Byteroo https://github.com/JMax45/byteroo/commit/b1379ed1851ee5ea26c6f19a0499b4e76dbd20f7

    Tests

    • add CacheContainer tests https://github.com/JMax45/byteroo/commit/e2f065cdd4f4f021f11fcbcd9091cf3112bf6991
    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Sep 8, 2022)

    Features

    • add list method https://github.com/JMax45/byteroo/commit/a09b174476560c7f55a5ea61589ae995d8999ded
    • rest parameters in remove method https://github.com/JMax45/byteroo/commit/ea23673dfcb605fc580e5c77e0f00fb147b21e0e

    Documentation

    • add rest parameters in remove to README https://github.com/JMax45/byteroo/commit/45a8aafd59ea61ea61a8915fe8ea1730daf8ccc2
    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Aug 28, 2022)

    Features

    • add serialize and deserialize options https://github.com/JMax45/byteroo/commit/73749668f501e249d1e0869b7d8a09288ece2984
    • add has method https://github.com/JMax45/byteroo/commit/f89af77bdb18df1aaec1d8b4f5dce4094608e87a
    • add autocommit option https://github.com/JMax45/byteroo/commit/308ea9b6a08526268c6ec8d8f74d6a51572dc6c4
    • add clear method https://github.com/JMax45/byteroo/commit/ebc249d61fb57aaa268c218a6579c8a5c8de3523
    • add size method https://github.com/JMax45/byteroo/commit/e6739e9fd603de9f1ca04aa9e06ca8c9c786afef

    Documentation

    • generate coverage report in codecov workflow https://github.com/JMax45/byteroo/commit/5fcecfb4f38fa45be7fa941bbe8f9f919b0ecd26
    • add README https://github.com/JMax45/byteroo/commit/2075bb40669e9d4df7b141a8effbd40162f48df4
    • update README https://github.com/JMax45/byteroo/commit/2671990a2adb5335cfdcbf6c0c08f3e45e14c72a
    • add commit method description https://github.com/JMax45/byteroo/commit/b01cdc0516147257ad21752afeca7f5beeaf27a3
    • fix formatting https://github.com/JMax45/byteroo/commit/1f6c2138c5ed5230b991343d69be4a73ba246b4f
    • update README https://github.com/JMax45/byteroo/commit/24ab21a01c93b80ce88e2cbdde153e9b0f114028
    Source code(tar.gz)
    Source code(zip)
Owner
JMax
JMax
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Bookmate - Watch changes in Chrome bookmarks, and use bookmarks as an append-only key-value store via an fs-like API.

?? Bookmate An append-only key-value store built on Chrome bookmarks, plus an asychronous stream of Bookmark changes. For NodeJS Actual production exa

Cris 6 Nov 8, 2022
Resolve parallel promises in key-value pairs whilst maintaining type information

async-kv Resolves promises in key-value pairs maintaining type information. Prerequisites NodeJS 12 or later Installation npm i async-kv yarn add asyn

Tony Tamplin 4 Feb 17, 2022
A common front-end/Service Worker-based Key/Value database based on CacheStorage

Cache-DB A common front-end/Service Worker-based Key/Value database based on CacheStorage > const db = new CacheDB('ChenYFanDB') < undefined > await d

CrazyCreativeDream 4 Sep 30, 2022
A simple in-memory key-value cache for function execution, allowing both sync and async operations using the same methods

A simple in-memory key-value cache for function execution, allowing both sync and async operations using the same methods. It provides an invalidation mechanism based both on exact string and regex.

cadienvan 10 Dec 15, 2022
Tool to sign data with a Cardano-Secret-Key // verify data with a Cardano-Public-Key // generate CIP-8 & CIP-36 data

Tool to sign data with a Cardano-Secret-Key // verify data with a Cardano-Public-Key // generate CIP-8 & CIP-36 data

Martin Lang 11 Dec 21, 2022
Tenzi is a dice game. The player needs to roll dice until they are all the same. Clicking on a dice, freezes it at its current value between rolls. Best scores are saved to local storage.

Roll until all dice are the same Try me! Technologies Used Description Tenzi is a dice game used to demonstrate the use of React Hooks (useState, useE

Michael Kolesidis 7 Nov 23, 2022
Keep the type of storage value unchanged and change array and object directly. Supports listening to the changes and setting expires.

proxy-web-storage A more convenient way to use storage through proxy. try it on codesandbox. Install npm i proxy-web-storage Features Base Keep the ty

null 221 Dec 25, 2022