UNPKG

1.61 kBJavaScriptView Raw
1// Generated by CoffeeScript 1.11.1
2(function() {
3 var jsonStream, mixin, through2, toBulk;
4
5 through2 = require('through2');
6
7 mixin = require('./mixin');
8
9 toBulk = function() {
10 return through2.obj(function(doc, enc, callback) {
11 this.push({
12 settings: doc
13 });
14 return callback();
15 });
16 };
17
18 jsonStream = function() {
19 return through2.obj(function(chunk, enc, callback) {
20 this.push(JSON.stringify(chunk) + "\n");
21 return callback();
22 });
23 };
24
25 module.exports = function(client, _opts) {
26 var exec, instream, opts, sink, stream;
27 opts = mixin(_opts);
28 instream = toBulk();
29 sink = instream.write.bind(instream);
30 exec = function() {
31 return client.indices.getSettings(opts).then(function(v) {
32 var index, ref, results, settings;
33 results = [];
34 for (index in v) {
35 settings = v[index].settings;
36 delete settings.index.uuid;
37 delete settings.index.version;
38 delete settings.index.creation_date;
39 if ((ref = settings.index) != null ? ref.analysis : void 0) {
40 settings.analysis = settings.index.analysis;
41 delete settings.index.analysis;
42 }
43 results.push({
44 _index: index,
45 _settings: settings
46 });
47 }
48 return results;
49 });
50 };
51 exec().then(function(docs) {
52 return docs.forEach(sink);
53 })["catch"](function(err) {
54 return stream.emit('error', err);
55 });
56 return stream = instream.pipe(jsonStream());
57 };
58
59}).call(this);
60
61//# sourceMappingURL=settings.js.map