Git Product home page Git Product logo

Comments (8)

jessie-codes avatar jessie-codes commented on August 23, 2024 1

@ZitRos I guess my question would be why would you pass an object you don't want to be flattened to a flatten function? I'm not sure that I see that as a real use case.

from safe-flat.

kishanio avatar kishanio commented on August 23, 2024 1

@jessie-codes +1 to @ZitRos there's gotta be a way to not flatten things. Maybe a function in user passed options to test if the condition is met continue flattening for values or else stop for that particular node.

from safe-flat.

nikitaeverywhere avatar nikitaeverywhere commented on August 23, 2024

from safe-flat.

nikitaeverywhere avatar nikitaeverywhere commented on August 23, 2024

To bring one more solid argument,

From the pure JavaScript perspective, why for instance the library doesn't flatten Date object? Perhaps Buffer object? BigInt? You don't flatten those intentionally, right?

What if web standards bring more objects like these in the future? Perhaps you would need to update the library with more exceptions which is not that nice. Also, if we enumerate all objects which we should flatten and define how should we — it might be quite a big list. That was my first though when I started to dig in how flatten-like libraries work.

Thus I am wondering what is the typical use case for your library users ;)

P.S. The flatten for pure objects only turned to be just around 15 lines of code, so I switched to using it instead. Everything stated above is knowledge sharing.

from safe-flat.

jessie-codes avatar jessie-codes commented on August 23, 2024

I'm not opposed to this change, but I would like to see some support from the community before making it as it would be a breaking change.

from safe-flat.

nikitaeverywhere avatar nikitaeverywhere commented on August 23, 2024

from safe-flat.

kishanio avatar kishanio commented on August 23, 2024

My use case was Firestore Update which allows to update nested object using "dotted keys". Though it might have data types like Timestamps which doesn't need to get flatten.

from safe-flat.

kishanio avatar kishanio commented on August 23, 2024

I wonder if we do something like this, typeof <value>.constructor.name === Object makes sense? This will ignore date/primitives and cats as above.

from safe-flat.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.