Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Assigning variable to everyone.now object results in array to object conversion #151

Open
dvismans opened this Issue Oct 24, 2011 · 4 comments

Comments

Projects
None yet
3 participants

Here's my code:

// ----- not interesting part
var express = require('express');
var app = express.createServer();
app.configure(function() {
app.use(express.static(__dirname + '/'));
});
var portnow = 80;
app.listen(portnow);
var nowjs = require("now");
var everyone = nowjs.initialize(app);

// ----- interesting part
// assign the value to a variable
var foo = [{'bar':[1,2,3]}];

// prints as expected: [ { foo: [ 1, 2, 3 ] } ]
console.log(foo);

// assign variable to
everyone.now.foo = foo;

//prints, not expected, array indexes converted to object keys: [ { bar: { '0': 1, '1': 2, '2': 3 } } ]
console.log(everyone.now.foo);

When using remote function calls on the same kind of datastructure this conversion does not seem to happen.

Sorry correction for this line:

// prints as expected: [ { foo: [ 1, 2, 3 ] } ]
console.log(foo);

Should of course read:
// prints as expected: [ { bar: [ 1, 2, 3 ] } ]
console.log(foo);

I'm taking a look at it.

Contributor

ericz commented Nov 2, 2011

Hi dvismans, I have reproduced the issue and investigated the cause. The solution is quite non-trivial but I'll work on it.

Eric

dvismans commented Nov 2, 2011

Thanks!

Sent from my iPhone

On 2 nov. 2011, at 14:37, Eric Zhangreply@reply.github.com wrote:

Hi dvismans, I have reproduced the issue and investigated the cause. The solution is quite non-trivial but I'll work on it.

Eric

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment