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

chatdb.js

v2.4.2

Published

[![NPM version](https://img.shields.io/npm/v/chatdb.js?style=flat-square)](https://www.npmjs.com/package/chatdb.js) ![built with typescript](https://camo.githubusercontent.com/92e9f7b1209bab9e3e9cd8cdf62f072a624da461/68747470733a2f2f666c61742e62616467656e

Readme

ChatDB.js

NPM version built with typescript

A library that parses the chat.db file on Macs into a comprehensive data structure using ES6 promises.

Installation

$ npm install chatdb.js

Getting Started

// Import the package
const { Chat } = require('chatdb.js');

(async function () {
    // Create new instance of Chat 
    // and initialize it asynchronously
    const chat = await new Chat('/path/to/chat.db').init();

    // ... Do the thing
}())

Examples

Simple Message Logger

const { Chat } = require('chatdb.js');
const fs = require('fs');

(async function() {
    const chat = await new Chat().init(); // Initialize Client
    const lastId = 0;
    // Declare loop
    async function loop() {
        const msg = (await chat.getMessages(1, true))[0]; // Get the most recent message

        if(msg.id != lastId) { // Check if the most recent message id changed
            lastId = msg.id;
            console.log(`${msg.isFromMe ? "Me" : msg.handle.name}: ${msg.text}`); // Format and log the message
        }
    }

    setInterval(loop, 1000); // Start loop
}());

Common Problems

W.I.P.

Documentation

Constructors

Properties

Methods

Constructors

constructor

+ new Chat(path?: string): Chat

Defined in app.ts:12

Parameters:

Name | Type | ------ | ------ | path? | string |

Returns: Chat

Properties

db

db: DatabaseSqlite‹Database, Statement›

Defined in app.ts:11


json

json: Conversation[]

Defined in app.ts:12


path

path: string

Defined in app.ts:10

Methods

close

close(): Promise‹void›

Defined in app.ts:224

Returns: Promise‹void›


Private dbDateToDate

dbDateToDate(nano: number): Date

Defined in app.ts:228

Parameters:

Name | Type | ------ | ------ | nano | number |

Returns: Date


getConversationCount

getConversationCount(): Promise‹any›

Defined in app.ts:212

Returns: Promise‹any›


getConversations

getConversations(max?: number, reverse?: boolean): Promise‹Conversation[]›

Defined in app.ts:130

Parameters:

Name | Type | ------ | ------ | max? | number | reverse? | boolean |

Returns: Promise‹Conversation[]›


getHandleCount

getHandleCount(): Promise‹any›

Defined in app.ts:216

Returns: Promise‹any›


getHandles

getHandles(max?: number, reverse?: boolean): Promise‹Handle[]›

Defined in app.ts:109

Parameters:

Name | Type | ------ | ------ | max? | number | reverse? | boolean |

Returns: Promise‹Handle[]›


getMessageCount

getMessageCount(): Promise‹any›

Defined in app.ts:220

Returns: Promise‹any›


getMessages

getMessages(max?: number, reverse?: boolean): Promise‹Message[]›

Defined in app.ts:151

Parameters:

Name | Type | ------ | ------ | max? | number | reverse? | boolean |

Returns: Promise‹Message[]›


init

init(): Promise‹Chat

Defined in app.ts:19

Returns: Promise‹Chat


parse

parse(): Promise‹Conversation[]›

Defined in app.ts:28

Returns: Promise‹Conversation[]›