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

object-chronicler

v1.1.1

Published

Object usage chronicler

Downloads

11

Readme

Object Chronicler

npm version Deploy Coverage Status

Object Chronicler empowers developers to gain unprecedented insights into the behavior of their JavaScript objects and functions. Acting as a meticulous observer, this utility allows you to effortlessly create spies that diligently record every interaction within your complex data structures.

Key Features

  • Observation Made Easy: Utilize createSpy to seamlessly spy on objects and functions, generating proxies with built-in history tracking.

  • Detailed Histories: BasicHistory provides a simple yet powerful implementation of the History interface, enabling the storage of detailed records about property accesses, method calls, and more.

  • Flexible Testing: Perfect for unit testing, debugging, and gaining a deeper understanding of your code's runtime behavior.

Why Object Chronicler?

Object Chronicler is your ally in navigating the intricacies of JavaScript objects and functions. Whether you're debugging, testing, or simply seeking a deeper understanding of your code's runtime behavior, this library empowers you to chronicle every interaction, ensuring you have the insights needed for confident and effective development.

Explore new possibilities with Object Chronicler today!

Installation

npm install object-chronicler

Usage

createSpy

createSpy is the main function for creating spies on objects or functions. It returns a proxied object with a history property to retrieve the recorded interactions.

import { createSpy, BasicHistory } from 'object-chronicler';

const obj = {
  method1: (x: unknown) => 'result1',
  method2: (y: unknown) => 'result2',
};

const history = new BasicHistory();
const spiedObj = createSpy(obj, history);

console.log(spiedObj.method1(1)); // Output: 'result1'
console.log(spiedObj.method2({ b: [] })); // Output: 'result2'

console.log(history.getAll());

BasicHistory

BasicHistory is a simple implementation of the History interface. It records interactions in a key-value store.

import { BasicHistory } from 'object-chronicler';

const history = new BasicHistory();

history.put({ type: 'get', key: 'key1' });
history.put({ type: 'set', key: 'key2', value: 'value2' });

console.log(history.getAll());

Contributing

Feel free to contribute by opening issues or pull requests on the GitHub repository.

Keywords

object, chronicler, spy, testing, history, tracking