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

immer-lite

v0.2.8

Published

a simple lite version of immer

Downloads

18

Readme

similar to Immer but smaller and faster

Updating immutable state in react can be very hard, especially when dealing with deeply nested objects. immer-lite makes it easy — you can update state just like regular JavaScript objects. This keeps your code simple, clean, and easy to maintain. It works with objects, arrays, maps, sets, and more. This is not a state management library but a utility and can be used with other state management libraries like redux, zustand, x-plus and others. Goal of this library is to help the developer to spend less time on state management.

It'll handle immutability and destructuring for you so you don't have to

Usage

consider this is your state

import { i } from "immer-lite";

// consider this state
let state = {
  name: "John",
  age: 30,
  details: {
    address: {
      city: "New York",
      contact: {
        emails: ["[email protected]", "[email protected]"],
        phone: "+1234567890",
        social: new Map([
          ["facebook", "https://www.facebook.com/john"],
          ["twitter", "https://www.twitter.com/john"],
          ["instagram", "https://www.instagram.com/john"],
        ]),
      },
    },
  },
};

without immer-lite : adding email

state = {
  ...state,
  details: {
    ...state.details,
    address: {
      ...state.details.address,
      contact: {
        ...state.details.address.contact,
        emails: [...state.details.address.contact.emails, "[email protected]"],
      },
    },
  },
};

with immer-lite : adding email

It'll destructure the parents objects internally.

state = i(state, (currentState) => {
  currentState.details.address.contact.emails.push("[email protected]");
});

without immer-lite : adding social media link

state = {
  ...state,
  details: {
    ...state.details,
    address: {
      ...state.details.address,
      contact: {
        ...state.details.address.contact,
        social: new Map([
          ...state.details.address.contact.social,
          ["linkedin", "https://www.linkedin.com/in/john"],
        ]),
      },
    },
  },
};

with immer-lite : adding social media link

It'll destructure the parents objects internally.

state = i(state, (draft) => {
  draft.details.address.contact.social.set(
    "linkedin",
    "https://www.linkedin.com/in/john"
  );
});

updating a 2D immutable array

const state = [
  [1, 2, 3],
  [4, 5, 6],
];

// using immer-lite
const newState = i(state, (s) => {
  s[0][0] = 10;
});

// without using immer-lite
const newState = state.map((row, rowIndex) => {
  return row.map((cell, cellIndex) => {
    if (rowIndex === 0 && cellIndex === 0) {
      return 10;
    }
    return cell;
  });
});

using with Redux

import { i } from "immer-lite";
function countReducer(state = initialState, action: ActionTypes) {
  switch (action.type) {
    case SET_STREET:
      return i(state, (s) => {
        s.address.street = "new street";
      });
    case DECR:
      return i(state, (s) => {
        s.count--;
      });
    case INCR:
      return i(state, (s) => s.count++);
    default:
      return state;
  }
}

using with x-plus

x-plus is a state management library for react.

import { x } from "x-plus";
import { i } from "immer-lite";

const store = x({ address: { street: "old street" } });

store.update((state) => {
  state.address.street = "new street";
});

API

i(state, fn) : returns the new state after applying the fn to the state

  • arguments[0] : state : currently, maps, sets, objects, arrays are supported
  • arguments[1] : fn(currentState, currentDraft): function that will be applied to the state

Draft function takes the current state and mutates it as needed while immer-lite takes care of the rest.

Caveats

  • immer-lite only supports objects, arrays, maps, sets.
  • immer-lite does not support functions, symbols, and more.

License

MIT

Contributing

Contributions are welcome! Please open an issue or a pull request.

Acknowledgements

  • immer for the inspiration

Author

Sean Freman