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 🙏

© 2026 – Pkg Stats / Ryan Hefner

glancy

v1.0.1

Published

A secure and efficient storage solution with support for compression and encryption.

Readme

🚀 Glancy Storage Library

Quality Gate Status

Glancy is a powerful, flexible, and efficient client-side storage library for modern JavaScript applications. It provides a range of features including key-value storage, item expiration (TTL), encryption, compression, and the ability to handle multiple items at once. This project is designed to be simple to use while also providing advanced features for complex storage needs.

✨ Features

  • 🗂️ Namespace Support: All items are stored under a unique namespace.
  • ⏱️ Time-to-Live (TTL): You can set an expiration time for stored items.
  • 🗜️ Compression: Built-in gzip compression for optimizing storage space.
  • 🔒 Encryption: AES-256-GCM encryption with PBKDF2 key derivation for secure storage of sensitive data.
  • ⚠️ Error Handling: Graceful error handling with custom error classes.
  • 📦 Batch Operations: Methods to get/set multiple items in a single operation.
  • 🛡️ Storage Integrity: Validations and checks to ensure safe storage usage.

📦 Installation

Install the package via npm:

npm install glancy

Then, import the Glancy class:

import { Glancy } from 'glancy';

const storage = new Glancy({ namespace: 'my_app' });

🛠️ Usage

🗝️ Basic Storage Operations

Easily set, get, and remove items:

const storage = new Glancy({ namespace: 'my_app' });

interface MyData {
  value: string;
}

// 🔑 Set a value
await storage.set<MyData>('my_key', { value: 'Hello, world!' }, 60000); // TTL of 1 minute

// 🔍 Get a value
const { data } = await storage.get<MyData>('my_key');
console.log(data?.value); // Outputs: Hello, world!

// 🗑️ Remove a value
storage.remove('my_key');

// 🧹 Clear all items in the namespace
storage.clear();

🔒 Compression and Encryption

Optimize storage and secure your data with built-in compression and encryption:

const storage = new Glancy({
  namespace: 'my_app',
  encryption: {
    enabled: true, // 🔒 Enable encryption
    key: 'my-secret-key',
  },
  compress: true, // 🗜️ Enable compression
  compressionLevel: 6, // Optional: Set compression level (0-9)
});

interface SecureData {
  value: string;
}

// 🔑 Set a value securely
await storage.set<SecureData>(
  'secure_key',
  { value: 'Sensitive Information' },
  60000
);

// 🔍 Retrieve the secure value
const { data } = await storage.get<SecureData>('secure_key');
console.log(data?.value); // Outputs: Sensitive Information

🔧 Tip: You can generate a secure key using openssl by running openssl rand -base64 32

🤹‍♂️ Batch Operations

Perform operations on multiple keys at once:

interface MyData {
  value: string;
}

// 🔑 Set multiple items
await storage.setMany<MyData>({
  key1: { value: 'value1' },
  key2: { value: 'value2' },
});

// 🔍 Get multiple items
const { data } = await storage.getMany<MyData>(['key1', 'key2']);
console.log(data['key1']); // Outputs: value1

⏳ Expiration (TTL)

Store items with a lifespan:

await storage.set('temporary_data', { value: 'Expires Soon' }, 5000); // Expires in 5 seconds

setTimeout(async () => {
  const data = await storage.get('temporary_data');
  console.log(data); // Should be null after 5 seconds
}, 6000);

📖 API Reference

📦 Class Options

| Option | Description | Default | | ------------------ | --------------------------------------------------- | ----------------------------- | | namespace | A unique identifier for the storage namespace. | glancy | | encryption | An object containing encryption configuration. | { enabled: false, key: '' } | | defaultTTL | The default TTL (in milliseconds) for stored items. | null | | compress | Whether to enable compression for stored items. | false | | compressionLevel | The gzip compression level (0-9). | 6 |

⚙️ Methods

get<T>(key: string): Promise<GlancyResponse<T>>

Retrieves a value. Returns null if the key doesn't exist or has expired.

set(key: string, value: T, ttl?: number): Promise<GlancyResponse<void>>

Stores a value with an optional TTL.

getMany<T>(keys: string[]): Promise<GlancyResponse<Record<string, T | null>>>

Retrieves multiple values at once.

setMany<T>(values: Record<string, T>, ttl?: number): Promise<GlancyResponse<void>>

Stores multiple values at once.

remove(key: string): GlancyResponse<void>

Deletes an item from storage.

clear(): GlancyResponse<void>

Removes all items in the current namespace.

keys(): GlancyResponse<string[]>

Lists all keys in the namespace.

has(key: string): Promise<GlancyResponse<boolean>>

Checks if a key exists and is not expired.

touch(key: string, ttl?: number): Promise<GlancyResponse<boolean>>

Updates the TTL for an existing item.

getTTL(key: string): Promise<GlancyResponse<number | null>>

Gets the remaining TTL for a key.

size(): GlancyResponse<number>

Calculates the total size (in bytes) of all items in the namespace.

📚 Types Reference

GlancyResponse<T>

Represents the response from a storage operation.

| Property | Description | | --------- | ----------------------------------------------- | | success | Indicates whether the operation was successful. | | message | A message associated with the response. | | data | The data returned by the operation. |

interface GlancyResponse<T> {
  success: boolean;
  message: string;
  data: T | null | undefined;
}

For more details, visit the Glancy Storage Library Documentation.

🤝 Contributing

We ❤️ contributions! Here's how to get started:

  1. 🍴 Fork the repository
  2. 🌱 Create a new branch (git checkout -b feat/my-feature)
  3. 💻 Commit your changes (git commit -am 'feat: add new feature')
  4. 🚀 Push to your branch (git push origin feat/my-feature)
  5. 🛠️ Create a Pull Request

📜 License

This project is licensed under the Apache 2.0 License.

🔧 Pro Tip: If you encounter any issues or have feature requests, feel free to open an issue or submit a pull request. Let's make Glancy even better!