Giter Site home page Giter Site logo

Comments (11)

magnushiie avatar magnushiie commented on May 20, 2024 1

Should the typings of Iterable<K, V> be updated to include the method?

[Symbol.iterator](): Iterator<T>;

I'm not sure this is the right way for 2 reasons:

  • The Symbol symbol is declared only for TypeScript ES6 target - for backwards compatibility, should SymbolConstructor and Symbol be defined in immutable.d.ts also?
  • From source it seems KeyedIterable returns entries() instead of values(), so the type of it is different. Maybe it's enough to override the iterable method in Iterable.Keyed to return the appropriate type instead.

from immutable-js.

leebyron avatar leebyron commented on May 20, 2024

0164a55 Adds Iterator methods to Vector, Map, Set, OrderedMap

from immutable-js.

leebyron avatar leebyron commented on May 20, 2024

049eff1 Adds ES6 Symbol.iterator polyfill

from immutable-js.

jsilvestre avatar jsilvestre commented on May 20, 2024

Hi,

I'm not sure it's the right place to ask/tell but I've tried to use orderedMap.values() but the result does not seem to have a done property nor next() method. Is it a bug or am I just misusing it?

Thanks.

from immutable-js.

leebyron avatar leebyron commented on May 20, 2024

Hey Joseph, what version are you using?—
Sent from Mailbox

On Fri, Aug 29, 2014 at 1:51 AM, Joseph Silvestre
[email protected] wrote:

Hi,
I'm not sure it's the right place to ask/tell but I've tried to use orderedMap.values() but the result does not seem to have a done property nor next() method. Is it a bug or am I just misusing it?

Thanks.

Reply to this email directly or view it on GitHub:
#68 (comment)

from immutable-js.

jsilvestre avatar jsilvestre commented on May 20, 2024

Sorry, I've tried the latest one, 2.0.16

from immutable-js.

voodoohop avatar voodoohop commented on May 20, 2024

is there any way to create a lazy Sequence directly from an ES6 generator?

from immutable-js.

leebyron avatar leebyron commented on May 20, 2024

Not yet, but I have that on my short list!—
Sent from Mailbox

On Mon, Sep 22, 2014 at 8:54 PM, voodoohop [email protected]
wrote:

is there any way to create a lazy Sequence directly from an ES6 generator?

Reply to this email directly or view it on GitHub:
#68 (comment)

from immutable-js.

leebyron avatar leebyron commented on May 20, 2024

As of v2.3.0, all Sequences can be iterated and all collections can be constructed from an Iterator or Iterable.

from immutable-js.

samwgoldman avatar samwgoldman commented on May 20, 2024

From source it seems KeyedIterable returns entries() instead of values()

You hit the nail on the head here. This is the real issue with making the base class iterable. Consider the following function:

function f(iter: Iterable<A,B>): Array<?> {
  out = [];
  for (let x of iter) {
    out.push(x);
  }
  return out;
}

What type belongs in ?? If I pass a KeyedIterable, it would be [K,V], if I pass anything else, it would be V.

from immutable-js.

magnushiie avatar magnushiie commented on May 20, 2024

It seems then that Immutable.Iterable itself should not be Iterable in the ES6 sense (as defined in lib.core.es6.d.ts), because its type is ill-defined. Instead, Iterable.Indexed and Iterable.Keyed should be ES6-iterable. It's bit of a pain because the Iterable methods like map aren't typed as returning this, but it would still be better than nothing.

from immutable-js.

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.