npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nixabase

v1.0.0

Published

A lightweight and flexible database for JSON and TXT with memory caching and image compression

Downloads

67

Readme

Nixabase

Nixabase is a lightweight, flexible, and efficient database management system for Node.js applications. It provides a simple interface for storing and retrieving data in both JSON and TXT formats, with additional features like memory caching and image compression.

Features

  • Dual Format Support: Store data in either JSON or TXT format.
  • Memory Caching: Improve read performance with optional in-memory caching.
  • File Upload: Built-in support for file uploads, including image compression.
  • Asynchronous Operations: All database operations are asynchronous for better performance.
  • Error Handling: Robust error handling for database operations.
  • Flexible Configuration: Customize database behavior through various options.

Installation

Install Nixabase using npm:

npm install nixabase

Usage

Initializing the Database

const Nixabase = require('nixabase');

const db = new Nixabase('path/to/database.json', {
  format: 'json', // or 'txt'
  performance: {
    memory: {
      enabled: true,
      maxItemCount: 1000
    },
    imageCompression: {
      enabled: true,
      level: 6,
      quality: 80,
      resize: { width: 800, height: 600 }
    }
  }
});

Basic Operations

// Save data
await db.save('user1', { name: 'John Doe', age: 30 });

// Retrieve data
const user = await db.get('user1');
console.log(user); // { name: 'John Doe', age: 30 }

// Update data
await db.update('user1', { name: 'John Doe', age: 31 });

// Delete data
await db.delete('user1');

File Operations

// Upload a file
await db.uploadFile('path/to/image.jpg', 'profile_pic');

// Retrieve a file
const fileBuffer = await db.getFile('profile_pic');

API Reference

constructor(filePath, options)

Creates a new Nixabase instance.

  • filePath: Path to the database file.
  • options: Configuration options (optional).
    • format: 'json' or 'txt' (default: 'json').
    • performance: Performance-related options.

async save(key, value)

Saves a key-value pair to the database.

async get(key)

Retrieves a value from the database by its key.

async update(key, value)

Updates an existing key-value pair in the database.

async delete(key)

Deletes a key-value pair from the database.

async uploadFile(sourcePath, destinationKey)

Uploads a file to the database with optional image compression.

async getFile(key)

Retrieves a file from the database.

Performance Optimization

Nixabase offers performance optimization through memory caching and image compression. These features can be enabled and configured in the constructor options.

Error Handling

Nixabase uses async/await and throws errors when operations fail. It's recommended to use try-catch blocks when working with Nixabase methods.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Author

Nixabase is created and maintained by Nixaut.