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

sm-chat

v1767581.686.835

Published

Professional integration for https://supermaker.ai/chat/

Downloads

78

Readme

sm-chat

A lightweight and versatile JavaScript library for seamless integration with chat services. Simplifies chat interactions within your applications.

Installation

Install the sm-chat package using npm: bash npm install sm-chat

Usage

Here are several examples demonstrating how to use the sm-chat package in different scenarios:

1. Basic Chat Initialization:

This example shows how to initialize a basic chat instance and send a simple message. javascript const smChat = require('sm-chat');

const chatInstance = new smChat.ChatClient({ apiKey: 'YOUR_API_KEY', // Replace with your actual API key userId: 'user123', // Replace with the user's ID });

chatInstance.sendMessage('Hello, world!');

chatInstance.on('message', (message) => { console.log('Received message:', message); });

chatInstance.connect();

2. Handling Incoming Messages:

This example demonstrates how to listen for and handle incoming messages from the chat service. javascript const smChat = require('sm-chat');

const chatInstance = new smChat.ChatClient({ apiKey: 'YOUR_API_KEY', userId: 'user456', });

chatInstance.on('message', (message) => { console.log('New message from:', message.senderId); console.log('Message content:', message.content); });

chatInstance.connect();

3. Sending Messages to a Specific Recipient:

This example shows how to send a direct message to a specific user. javascript const smChat = require('sm-chat');

const chatInstance = new smChat.ChatClient({ apiKey: 'YOUR_API_KEY', userId: 'user789', });

chatInstance.sendMessage('Hello, John!', 'john123'); // Send to user 'john123'

chatInstance.connect();

4. Joining and Leaving Channels:

This demonstrates how to join and leave specific chat channels. javascript const smChat = require('sm-chat');

const chatInstance = new smChat.ChatClient({ apiKey: 'YOUR_API_KEY', userId: 'userabc', });

chatInstance.joinChannel('support-channel');

chatInstance.on('channelMessage', (message, channelId) => { if (channelId === 'support-channel') { console.log('Message in support channel:', message); } });

// Later, leave the channel setTimeout(() => { chatInstance.leaveChannel('support-channel'); console.log('Left support channel.'); }, 60000); // Leave after 1 minute

chatInstance.connect();

5. Advanced Configuration with Custom Events:

This example shows how to configure the chat client with custom event listeners. javascript const smChat = require('sm-chat');

const chatInstance = new smChat.ChatClient({ apiKey: 'YOUR_API_KEY', userId: 'userdef', options: { reconnectAttempts: 5, }, });

chatInstance.on('connected', () => { console.log('Successfully connected to the chat server.'); });

chatInstance.on('disconnected', () => { console.log('Disconnected from the chat server.'); });

chatInstance.on('error', (error) => { console.error('Chat error:', error); });

chatInstance.connect();

API Summary

  • ChatClient(config): Creates a new chat client instance.
    • config: An object containing configuration options.
      • apiKey (string, required): Your API key for accessing the chat service.
      • userId (string, required): The unique identifier for the user.
      • options (object, optional): Additional configuration options.
        • reconnectAttempts (number, optional): The number of reconnection attempts. Defaults to 3.
  • chatInstance.connect(): Establishes a connection to the chat service.
  • chatInstance.disconnect(): Closes the connection to the chat service.
  • chatInstance.sendMessage(message, recipientId): Sends a message.
    • message (string, required): The content of the message.
    • recipientId (string, optional): The ID of the recipient (for direct messages). If omitted, the message is sent to the default channel.
  • chatInstance.joinChannel(channelId): Joins a specific chat channel.
    • channelId (string, required): The ID of the channel to join.
  • chatInstance.leaveChannel(channelId): Leaves a specific chat channel.
    • channelId (string, required): The ID of the channel to leave.
  • chatInstance.on(event, callback): Registers a callback function for a specific event.
    • event (string, required): The name of the event. Possible values: message, channelMessage, connected, disconnected, error.
    • callback (function, required): The function to be called when the event occurs.

License

MIT

This package is part of the sm-chat ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/chat/