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

chat-delete-utils

v1.0.0

Published

A utility library for handling chat message and conversation deletion operations

Readme

Chat Delete Utils

A utility library for handling chat message and conversation deletion operations with comprehensive localStorage management.

Installation

npm install chat-delete-utils

Usage

import {
  resetAfterBatchDelete,
  resetAfterSingleDelete,
  deleteConversationFromLocalStorage,
  deleteAllConversationsFromLocalStorage,
  deleteMessagesFromConversation,
  clearAllChatData,
  createReactiveObject,
  conversationExistsInLocalStorage
} from 'chat-delete-utils';

// Create reactive objects
const messages = createReactiveObject([]);
const conversations = createReactiveObject([]);
const conversationId = createReactiveObject('');
const currentChat = createReactiveObject(-1);

// Reset after batch deletion
resetAfterBatchDelete(
  { value: 'Welcome to the chat!' },
  conversations,
  messages,
  conversationId,
  currentChat
);

// Reset after single deletion
resetAfterSingleDelete(
  'conversation-123',
  { ok: true },
  { value: 'Welcome to the chat!' },
  conversations,
  messages,
  conversationId,
  currentChat
);

// Delete specific conversation from localStorage
deleteConversationFromLocalStorage('conversation-123');

// Delete all conversations
deleteAllConversationsFromLocalStorage();

// Delete specific messages from a conversation
deleteMessagesFromConversation('conversation-123', ['msg-1', 'msg-2']);

// Clear all chat data
clearAllChatData();

// Check if conversation exists
const exists = conversationExistsInLocalStorage('conversation-123');

API Reference

Core Deletion Functions

  • resetAfterBatchDelete(PROMPT_MESSAGE, conversations, messages, conversationId, currentChat) - Reset state after batch deletion
  • resetAfterSingleDelete(id, response, PROMPT_MESSAGE, conversations, messages, conversationId, currentChat) - Reset state after single deletion

localStorage Management

  • deleteConversationFromLocalStorage(conversationId) - Delete specific conversation from localStorage
  • deleteAllConversationsFromLocalStorage() - Delete all conversations from localStorage
  • deleteMessagesFromConversation(conversationId, messageIds) - Delete specific messages from a conversation
  • clearAllChatData() - Clear all chat-related data from localStorage
  • conversationExistsInLocalStorage(conversationId) - Check if conversation exists in localStorage

Utility Functions

  • createReactiveObject(value) - Create a simple reactive object (Vue compatibility)

Features

  • Comprehensive Deletion: Support for both batch and single conversation deletion
  • Local Storage Management: Complete localStorage operations for chat data
  • State Reset: Proper state reset after deletion operations
  • Error Handling: Robust error handling with detailed logging
  • Vue Compatibility: Helper functions for Vue reactivity patterns
  • Data Validation: Validation checks before performing operations

Use Cases

  1. Conversation Cleanup: Remove old or unwanted conversations
  2. Batch Operations: Delete multiple conversations at once
  3. Message Management: Remove specific messages from conversations
  4. Data Reset: Clear all chat data for testing or privacy
  5. Storage Optimization: Manage localStorage usage efficiently

Error Handling

All functions return boolean values indicating success/failure and include comprehensive error logging:

const success = deleteConversationFromLocalStorage('conversation-123');
if (!success) {
  console.log('Deletion failed');
}

Browser Support

This library requires modern browser features:

  • ES6 Modules
  • localStorage API
  • Console API for error logging

License

MIT