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

@personal_simple_code/immutable

v1.0.3

Published

A simple logic is used to implement an API to copy only when modifying values, which minimizes the need to copy or cache data.

Downloads

11

Readme

immutable

Introduction

  1. A simple logic is used to implement an API to copy only when modifying values, which minimizes the need to copy or cache data.

  2. Always generate new updated data without changing the original data.

  3. https://github.com/GitHub-MXB/immutable

Software principle

Use proxy response to update, only get and set time shallow clone operands and assign values

  1. Create a map set to store target and its real address

  2. Shallow clone target object is real object

  3. Execute the callback and actually listen to the real object.

  4. When the get is triggered, the Val and its real address are stored, which is used in the set

  5. Shallow clone and assign the read value, and return the new proxy object

  6. When the set is triggered, obtain the real address of the target (the value of the target cannot be assigned directly). If there is: go to step 5, if there is no: assign directly

Installation tutorial

import deepClone from "@personal_simple_code/immutable"

let obj = {
    a: [1, 2, 3, 4, 5],
    b: { c: [123] },
    d: new Map(),
    e: new Set(),
}
let a = deepClone(obj, (x) => {
    x.a = [0, 0, 0]
    x.a[0] = 100
    x.a[1]++
    x.a[0] += x.a[1] + 100

    x.a.push(0)
    x.d.set("a", {
        a: 100,
    })
    x.e.add(1089)
    x.e.add(x.d.get("a"))
    x["f"] = {
        a: x.e,
    }
})

console.error(`target:`, obj)
console.error(`result:`, a)

result

target: { a: [ 1, 2, 3, 4, 5 ], b: { c: [ 123 ] }, d: Map {}, e: Set {} }
result: {
  a: [ 201, 1, 0, 0 ],
  b: { c: [ 123 ] },
  d: Map { 'a' => { a: 100 } },
  e: Set { 1089, { a: 100 } },
  f: { a: Set { 1089, [Object] } }
}

Instructions for use

  1. The current version of object container only supports array, set, map and object types

  2. The values and assignments in the callback function are all directly copied and have no reference relationship