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

pure-aid

v1.0.7

Published

A tiny collection of functions to be used in conjunction with normalizr and redux-undo to bridge the "delete" gap of normalizr.

Downloads

6

Readme

Pure-Aid - your purity helper when using normalizr and redux-undo

As described on Stackoverflow (https://stackoverflow.com/questions/34954726/how-do-you-add-remove-to-a-redux-store-generated-with-normalizr) by m0meni, I ran into the exact same problem and got tired of writing the same three lines all over my reducers again and again. So here is a tiny collections of pure functions which covers the little gap in "normalizr". You might not run into an immutability issue, if you do not have an undo functionality. But, as soon as you do, pure-aid saves you some code duplication and helps to keep your reducers short and readable ;-) You can embed pure-aid seamlessly in your es6-style code. If you project is still coded in es5, you will need to add a babel translation step to your pipeline to translate the object spread syntax (https://www.npmjs.com/package/babel-plugin-transform-object-rest-spread).

Install

npm install --save pure-aid

Usage

  import Pure from 'pure-aid';

  const sample = {
    1: {
      id: 1,
      name: 'sample 1'
    },
    3: {
      id: 3,
      name: 'sample 3'
    },    
    5: {
      id: 5,
      name: 'sample 5'
    },
  }

  const newName = 'example';

  // add object (without normalizing, denormalizing everything)
  const extendedSample = Pure.Obj.mergeNestedObject(sample, 4, { id: 4, name: newName });
  // update object
  const mergedSample = Pure.Obj.mergeNestedObject(sample, 3, name: newName });
  // delete one or more objects without normalizing and denormalizing everything
  const cleanedSample = Pure.Obj.deleteNestedObjects(sample, [1, 3]);

  // Objects inside arrays
  const array = [ { id: 10, name: 'item 10'}, { id: 11, name: 'item 11'} ];

  // add object to array
  const extendedArray = Pure.Arr.add(array, 1, { id: 20, name: 'item 20'});
  // order in extendedArray is [10, 20, 11]
  // merge object inside array
  const mergedArray = Pure.Arr.mergeObject(array, 0, { name: newName });
  // change position in array
  const reorderedArray = Pure.Arr.changePosition(array, 0, 1);

  // merge primitive in array
  const primArray = ['a', 'b', 'c'];
  const updatedArray = Pure.Arr.mergeObject(primitiveArray, 1, 'd');