Git Product home page Git Product logo

Comments (5)

eJuke avatar eJuke commented on June 25, 2024 1

Thank you for your response
I created local module with Enumerable extension (patch adds .fromObject method) and updated linq module to have type definition for the new method. It's suitable for me

from linq.

mihaifm avatar mihaifm commented on June 25, 2024

Good find, I don't think we need to keep that logic. I would change it to Array.isArray(obj), but need to check potential problems.

from linq.

mihaifm avatar mihaifm commented on June 25, 2024

I've done some tests and it seems like this change is not a good idea. Using Array.isArray(obj) (or instanceof ) instead of typeof obj.length == Types.Number would exclude array-like objects, most notably the arguments object and return values from DOM functions like document.getElementsByTagName() that return a list of elements.

You can consider this issue a small limitation of the library, but it's probably better to change the name of your length property to avoid other problems down the line.

Also a small correction to your code, when converting to object use .toObject(i => i.key, i => i.value); (without the capitalization)

from linq.

eJuke avatar eJuke commented on June 25, 2024

Is it possible to create method .fromObject or something like this?
We cannot change name of length property because we have too many models with this property. So renaming will take too much time to support it across the system.

from linq.

M0ns1gn0r avatar M0ns1gn0r commented on June 25, 2024

I think it would be odd to create a separate method for such a narrow use-case.

But you can of course create your own helper method which will transform your object to an array of key-value pairs.

from linq.

Related Issues (20)

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.