Git Product home page Git Product logo

Comments (4)

dalefrancis88 avatar dalefrancis88 commented on May 15, 2024

how would this be implemented without changing the type or mutating the value? the value of using the known functions is that they take care of creating the correct type but i think filter/map/reduce won't work without mutation or changing type

I think though most of the others should be fine

from crocks.

dalefrancis88 avatar dalefrancis88 commented on May 15, 2024

hey @evilsoft I am wondering if you have some magical idea for this? cause i can't quite think of how to do many of these without returning an array instead of the original iterable?

from crocks.

HenriqueLimas avatar HenriqueLimas commented on May 15, 2024

I think we need to define a function that clone the object in a way that it doesn't loose the structure. We need some checks for base constructors like (Date, Array, String etc..) and clone it in the right way, and when its a normal object use something like Object.create and assign.
Something like (pretty basic without the base constructor checks)

let object = Object.create(Object.getPrototypeOf(source))
Object.assign(object, source)

let symbols = Object.getOwnPropertySymbols(source)
symbols.forEach(key => object[key] = source[key])

return object

To make it easier, we should clone only after isIterable(), so we could call it cloneIterable

from crocks.

dalefrancis88 avatar dalefrancis88 commented on May 15, 2024

@HenriqueLimas @evilsoft I think we may have made a mistake on this one when we did head. I am thinking that the behavior we started with in head is wrong. I'm thinking that it should be if a generator function is passed in, then we will invoke it and iterate, however if you pass in the result of a generator call then your expectation is that you want it iterated over.
What do you guys think?

from crocks.

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.