Buenas gente, quiero hacer un objeto iterable y me di cuenta que el metodo magico __iterator__ no funciona en node:
[exos@Coopx ~]$ node
> var a = {};
undefined
> a.__iterator__ = function () {
... return [0,1,2,3,4,5];
... }
[Function]
>
undefined
> for (x in a) console.log(x);
__iterator__
undefined
> a.__iterator__ = function __iterator__ () {
... return [0,1,2,3,4,5];
... }
[Function: __iterator__]
> for (x in a) console.log(x);
__iterator__
undefined
> a = function () {}
[Function]
> a.__iterator__ = function __iterator__ () {
... reuturn [0,1,2,3,4,5];
... }
[Function: __iterator__]
> for (x in a) console.log(x);
__iterator__
undefined
>
Como podría hacer en Node un objeto iterable, mi idea es conservar igualmente sus metodos y propiedades asi que no va la de devolver un array.
--
El Tio ~ Programador, hacker y filósofo
web:
http://blog.exodica.com.arLinked'in:
http://www.linkedin.com/in/ogentilezza
Twitter: @exos, Indeti.ca: @exos
Tels: [+54 11] 638-LINUX (54689) -
[+54 9 11] 6133-2442-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/IT d-- s:++ a- C+++$ UBL+++$ P(-) L+++$ !E--- W+++$ !N !o K-? !w--- !O !M-- V? PS+++@ !PE Y+(++) PGP++ !t--- !5 X++ R(+) tv--? b- DI D-- G e@ h>++ r+++(-) y+++>+++++
------END GEEK CODE BLOCK------