Add function to rename keys in an object
> var _ = require('underscore');
> var note = {
... '_id': 1,
... 'title': 'Ruby is awesome..',
... 'text': '..and so is CoffeeScript'
... }
> console.log(_.rename(note, [['_id', 'id']]));
{ id: 1,
title: 'Ruby is awesome..',
text: '..and so is CoffeeScript' }
or an array of objects
> var notes = [note, note];
> console.log(_.rename(notes, [['_id', 'id']]));
[ { id: 1,
title: 'Ruby is awesome..',
text: '..and so is CoffeeScript' },
{ id: 1,
title: 'Ruby is awesome..',
text: '..and so is CoffeeScript' } ]
Thanks,
Nisanth
Thanks, but no thanks -- way too special case for core Underscore. Feel free to mix it in for your own purposes.