Flotype/now — Issue #151: Assigning variable to everyone.now object results in array to object conversion
Author: dvismans
Created: 2011-10-24 20:48:32+00:00
State: open

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.