Hi all, i'm trying to do this, I have an array that looks like this:

[ { rId: { id: '123455667' },
    form: 'layer',
    timeStamp: '2015-11-20T10:28:26-03:00',
    exa: '32144B5A0000200000000001' },
  { rId: { id: '123455667'},
    form: 'item',
    timeStamp: '2015-11-20T10:28:28-03:00',
    exa: '30142F13F0138D0000000057' },
  { rId: { id: '123455667' },
    format: 'item',
    timeStamp: '2015-11-20T10:28:27-03:00',
    exa: '30142F13F0138D0000000054' },
  { rId: { id: '123455667' },
    format: 'layer',
    timeStamp: '2015-11-20T10:29:09-03:00',
    exa: '32144B5A00002000000001AB' },
  { rId: { id: '123455667' },
    form: 'item',
    timeStamp: '2015-11-20T10:30:19-03:00',
    exa: '30142F13F0138D0000000055' } ]

And I want to create to separete arrayas that look likes:

[ { rId: { id: '123455667' },
    form: 'layer',
    timeStamp: '2015-11-20T10:28:26-03:00',
    exa: '32144B5A0000200000000001' },
    items: [
                { rId: { id: '123455667'},
                  form: 'item',
                  timeStamp: '2015-11-20T10:28:28-03:00',
                  exa: '30142F13F0138D0000000057' },
              { rId: { id: '123455667' },
                format: 'item',
                timeStamp: '2015-11-20T10:28:27-03:00',
                exa: '30142F13F0138D0000000054' }
            ]
]
 [ { rId: { id: '123455667' },
     format: 'layer',
     timeStamp: '2015-11-20T10:29:09-03:00',
     exa: '32144B5A00002000000001AB' },
     items: [
                 { rId: { id: '123455667' },
                   form: 'item',
                   timeStamp: '2015-11-20T10:30:19-03:00',
                  exa: '30142F13F0138D0000000055' } 
     ]
]

So in simple words, if there are two elements with format layer add 
elements with format item to the first element with format layer and those 
who are after the second layer to the second layer, and in the event that 
there is only one layer add all items formatted items to that layer

This may be silly but do not know where to start.

Thanks.

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/5e417144-e42e-43f7-b8dc-fdf63723be48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to