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

@medieval/martingale

v1.0.3

Published

> ๐Ÿง™โ€โ™‚๏ธ _"Why juggle state manually, when you can let **Martingale** do it for you?"_ > โ€“ A wise developer somewhere in the multiverse

Downloads

74

Readme

Martingale ๐ŸŽฉ

๐Ÿง™โ€โ™‚๏ธ "Why juggle state manually, when you can let Martingale do it for you?"
โ€“ A wise developer somewhere in the multiverse

๐Ÿช„ Welcome to Martingale โ€“ the enchanting state management library that brings harmony to your application's state while making you feel like a wizard of code!

๐Ÿ’ก Features

  • ๐ŸŽฎ Simple State Management: Easily manage state without the fuss. No more headache-inducing complexity! ๐Ÿคฏ
  • ๐Ÿ•ฐ๏ธ Undo/Redo Magic: Travel back and forth through your state history like a time traveler! โณ
  • ๐Ÿ“œ State History: Keep track of your past states as if you had a magical spell book! ๐Ÿ“–
  • ๐Ÿ” Getters Galore: Access your state like a pro, with built-in methods for fetching the current value.
  • ๐Ÿฐ Flexible Options: Customize your store's options to fit your needs like a well-tailored robe.

๐Ÿ““ Installation

Getting started with Martingale is as simple as casting a spell:

npm install @medieval/martingale --force

๐Ÿ’ก Pro Tip: ๐Ÿง™โ€โ™‚๏ธ Don't forget to run npm install โ€“ your magic won't work without it!


๐Ÿš€ Getting Started

Hereโ€™s how you can start managing your state like a true sorcerer:

import { makestate, Store } from '@medieval/martingale';

// Create a magical state
const initialState = { count: 0 };
const store: Store<typeof initialState> = makestate(initialState);

// Subscribe to state changes
const unsubscribe = store.subscribe((state) => {
  console.log('๐Ÿ”ฎ Current State:', state);
});

// Update the state
store.set({ count: 1 }); // ๐Ÿ’ฅ State updated!

// Perform an undo
store.undo(); // โช Back in time!

// Get the current state
const currentState = store.get();
console.log('๐Ÿ“œ Retrieved State:', currentState);

๐Ÿ“œ Disclaimer: No states were harmed during this state management!

๐Ÿ” Using the Store

With Martingale, you can manage your state like a seasoned wizard. Hereโ€™s how:

Subscribe to State Changes

Subscribe to changes and perform your magic:

const unsubscribe = store.subscribe((state) => {
  console.log('๐ŸŒŸ State Updated:', state);
});

// Unsubscribe when you no longer need to watch the state
unsubscribe();

Update the State

Change your state and watch the magic happen:

store.set({ count: 2 }); // โœจ Update the state!

Undo and Redo

Time travel with undo and redo capabilities:

store.undo(); // โช Go back one state
store.redo(); // โฉ Go forward one state

Get State History

Retrieve the history of your state changes:

const history = store.getStateHistory();
console.log('๐Ÿ“œ State History:', history);

๐Ÿค Contributing

Weโ€™d love your help to make Martingale even more awesome! Submit issues, PRs, or just send us a virtual high-five! ๐Ÿ™Œ

๐Ÿ•ธ๏ธ "With great state management, comes great responsibility." โ€“ Not Spider-Man, but very close

Feel free to contribute at the GitHub repository.

๐Ÿ“œ License

This project is licensed under the MIT License.


๐ŸŽฉ Now go ahead and manage your state like a master wizard with Martingale! Enjoy the magic!