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

platesjs

v1.0.3

Published

A lightweight, smart stack tracker that saves space while allowing for version control functionality

Downloads

9

Readme

Plates.js - A Lightweight, Smart Stack Tracker

Plates.js is a simple and intelligent stack tracker that allows you to save space while providing version control functionality for your data. It offers a smart way to keep track of changes to objects by storing only the differences between versions, thus minimizing memory consumption.

Data Storage Efficiency

The Data internal class stores raw data for large changes, eliminating overhead and optimizing space usage. This class is used for larger changes or new data.

The Change internal class stores differences between objects, minimizing the stored data and reducing storage requirements. This class is used for incremental changes or large datasets.

By combining these classes, the "plates" library achieves efficient data management, striking a balance between space optimization and data preservation.

Installation

npm install platesjs

Usage

Constructor

To create a new instance of Plates and initialize it with the first value:

import Plates from 'plates';

const initialData = { name: 'John Doe', age: 30 };
const plates = new Plates(initialData);

Push

Add an object to the stack:

const newData = { name: 'Jane Smith', age: 28, occupation: 'Engineer' };
plates.push(newData);

Get

Retrieve the current top of the stack:

const currentData = plates.get();
console.log(currentData);

Undo

Move the stack pointer backward:

plates.undo();

Redo

Move the stack pointer forward:

plates.redo();

Other functionality

plates.hasUndo(); // Returns true if there is an undo action available
plates.hasRedo(); // Returns true if there is a redo action available
plates.clear(); // Clears the stack
plates.setOptions(options); // Sets the options for the stack
plates.updateOptions(options); // Updates the options for the stack

Example

import Plates from 'plates';

// Create a new instance of Plates and initialize it with the first value
const initialData = { name: 'John Doe', age: 30 };
const plates = new Plates(initialData);

// Push new data to the stack
const newData = { name: 'Jane Smith', age: 28, occupation: 'Engineer' };
plates.push(newData);

// Retrieve the current top of the stack
const currentData = plates.get();
console.log('Current Data:', currentData); // Output: { name: 'Jane Smith', age: 28, occupation: 'Engineer' }

// Perform undo and check the data
plates.undo();
const undoData = plates.get();
console.log('Undo Data:', undoData); // Output: { name: 'John Doe', age: 30 }

// Perform redo and check the data
plates.redo();
const redoData = plates.get();
console.log('Redo Data:', redoData); // Output: { name: 'Jane Smith', age: 28, occupation: 'Engineer' }

Options

The Plates constructor accepts an optional options object as a second parameter. The following options are available with these defaults:

const DEFAULT_OPTIONS = {
    alwaysPushRaw: false, // Always push raw data to the stack
    onStackPush: () => {}, // Callback function to execute when pushing to the stack
    onStackClear: () => {} // Callback function to execute when clearing the stack
}

Contributing

Contributions are welcome! Feel free to submit issues or pull requests on the GitHub repository.

License

Plates.js is licensed under the MIT License.