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

simply-immutable

v2.1.1

Published

Fast, lightweight, and type safe immutable utilities for working with simple POJOs

Downloads

78

Readme

simply-immutable

ZERO dependencies! FAST! See the benchmarks. Minimal object changes on updates. Type safety for CRUD operations in TypeScript. Immutable in - immutable out: deep clones incoming objects/arrays for safety.

cloneImmutable

Deep clone of an object/array. Returns a deeply frozen clone.

cloneMutable

Deep clone of an object/array. Does not freeze anything in the result, so this is a good way to remove immutability.

shallowCloneMutable

Shallow clone of an object/array. First level of the result is not frozen.

replaceImmutable

Replaces object/array fields in the target object/array. Deep compare on replacing object to minimally change structure. Creates intermediate objects/arrays as necessary.

updateImmutable

Merges object/array fields into the target object/array. Deep compare on updating object fields to minimally change structure. Creates intermediate objects/arrays as necessary.

deepUpdateImmutable

Merges object/array fields into the target object/array; merging happens recursively (unlike updateImmutable, which only merges at the first level). Merging after the first level only happens on objects, not arrays. Deep compare on updating object fields to minimally change structure. Creates intermediate objects/arrays as necessary.

deleteImmutable

Removes target field.

incrementImmutable

Adds to an existing numeric value. If the target value is not a number then it is treated as 0. obj = incrementImmutable(obj, ['foo', 'count'], 1);

arrayPushImmutable

Adds new values to the end of an array. If the target is not an array then it will be replaced by a new array with only the new values in it. obj = arrayPushImmutable(obj, ['foo', 'vals'], 'newVal1', 'newVal2');

arrayPopImmutable

Removes the last value from the end of an array. If the target is not an array then it will be replaced by an empty array. obj = arrayPopImmutable(obj, ['foo', 'vals']);

arrayUnshiftImmutable

Adds new values to the front of an array. If the target is not an array then it will be replaced by a new array with only the new values in it. obj = arrayUnshiftImmutable(obj, ['foo', 'vals'], 'newVal1', 'newVal2');

arrayShiftImmutable

Removes the first value from the front of an array. If the target is not an array then it will be replaced by an empty array. obj = arrayShiftImmutable(obj, ['foo', 'vals']);

arrayConcatImmutable

Adds an array of new values to the end of an array. If the target is not an array then it will be replaced by a new array with only the new values in it. obj = arrayConcatImmutable(obj, ['foo', 'vals'], ['newVal1', 'newVal2']);

arraySliceImmutable

Works just like Array.slice(). If the target is not an array then it will be replaced by an empty array. obj = arraySliceImmutable(obj, ['foo', 'vals'], 2, -1); obj = arraySliceImmutable(obj, ['foo', 'vals'], 1);

arraySpliceImmutable

Works just like Array.splice(). If the target is not an array then it will be replaced by a new array with only the new values in it. If the target is not an array then it will be replaced by an empty array. This function is much preferable to replaceImmutable for arrays when the change operations are known, because replaceImmutable diffs by array index so a deleted or inserted value will break diffing. arraySpliceImmutable does not have this problem. obj = arraySpliceImmutable(obj, ['foo', 'vals'], 3, 1, 'insertedVal');

diffImmutable

Given two objects/arrays, generates a diff that can be applied to the second parameter (using applyDiffImmutable) to get the first parameter.

applyDiffImmutable

Applies a diff generated by diffImmutable. Works almost the same as deepUpdateImmutable, except that nested arrays are also merged.

filterImmutable

Filters out members of an object/array based on a filter function.

mapImmutable

Remaps members of an object/array based on a callback function.

deepFreeze

Recursively freezes an object/array and all children.

isFrozen

Checks if an object/array is frozen.

isDeepFrozen

Recursively checks if object/array and all children are frozen.

freezeImmutableStructures

Enables or disables deep freezing of the outputs of the *Immutable functions. Enabled by default, but recommended to turn off in production builds (benchmarks have deep freezing turned off).