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

object-reducer-js

v1.0.0

Published

objet reducer for javascript

Readme

OBJECT-REDUCER

codecov Generic badge Generic badge

Package to reduce object to one level access

object-reducer is a simple package to reduce any object to perform a one-level access

How to use

object-reducer is very easy to use. You just need to import the package and pass to him the object that you want to reduce. This is usefull when you want do simplify the access for an object, or you dont know or dont want to know the internal structure of an object. Here is a example.

const { reduceObjectSync } = require('object-reducer');
const object = {
"prop1": "1",
"prop2":"2"
    "nestedObject":{
        "prop3":"3",
        "prop4":"4"
        "nestedObject2":{
            "prop5":"5"
        }
    }
}

const reducedObject  = reduceObjectSync(object);

reducedObject will be like this
{
    "prop1": "1",
    "prop2": "2",
    "prop3": "3",
    "prop4": "4",
    "prop5": "5",
}

This way you can perform a one level access, which is faster and simpler An asynchronous version of the method is also available, called reduceObjectAsync in case you want to use it asynchronously. by default both methods will check the passed object againts circular reference, that can lead to an infinity recursive loop. If you trust the data that you are reducing, then you can disable the circular reference check , this way.

const checkForCircularReference = false;

reduceObjectAsync(object,checkForCircularReference)
or
reduceObjectSync(object,checkForCircularReference)

If you want to perform other behavior for when an object has a circular reference, you can use the exposed checkForCyclicReferences method to check if an object has a circular reference. The method will return true or false, according to the presence or lack of circular references in the passed object

Performance

To test the performance of the package, I've created an simple benchmark. This test is in tests/benchmark folder.

In this test we have an variable called numberOfSamplesToReduce that represents the number of objects that will be tested. This test creates an vector of objects like the model in tests/payload.js and then process using bot methods ( sync and async versions). To reduce one sample, we have lest than 1 second for the sync version and 0.001 second for the async version. For 1000 samples the times was 0.025 seconds for the sync version and 0.017 seconds for the async version. See the screen capture

Image

That 's all !!

Hope this package help you to code more 😀😀

License

buils

About the author

Dev, security enthusiast, Gamer :D

LinkedIn: www.linkedin.com/in/ronaldo-mp

Github: https://github.com/R9n