UNPKG

510 BJavaScriptView Raw
1
2var through = require('through2');
3
4module.exports = function( index, type ){
5
6 var stream = through.obj( function( item, enc, done ) {
7
8 var id = item.id;
9 delete item.id;
10
11 // allow override of the default type
12 // by setting ._type on the item.
13 var estype = type;
14 if( item.hasOwnProperty('_type') ) {
15 estype = item._type;
16 delete item._type;
17 }
18
19 this.push({
20 _index: index, _type: estype, _id: id,
21 data: item
22 });
23
24 done();
25
26 });
27
28 return stream;
29}
\No newline at end of file