Skip to content

Commit afec3fd

Browse files
committed
Autoformat files
1 parent b0649ff commit afec3fd

File tree

6 files changed

+17
-26
lines changed

6 files changed

+17
-26
lines changed

lib/actions/splitOnJsonata.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
2-
31
const debug = require('debug')('splitter');
42
const _ = require('lodash');
53
const { JsonataTransform } = require('@elastic.io/component-commons-library');
6-
const messages = require('elasticio-node').messages;
4+
const { messages } = require('elasticio-node');
75

86
/**
97
* @this processAction
@@ -16,15 +14,15 @@ async function processAction(msg, cfg) {
1614
return;
1715
}
1816

19-
if (_.find(split, elem => !_.isObject(elem))) {
17+
if (_.find(split, (elem) => !_.isObject(elem))) {
2018
await this.emit('error', new Error('Splitting arrays of objects only!'));
2119
return;
2220
}
2321

2422
const results = [];
25-
split.forEach(elem => results.push(elem));
23+
split.forEach((elem) => results.push(elem));
2624
debug('%s parts to emit found', results.length);
27-
for (let value of results) {
25+
for (const value of results) {
2826
if (value) {
2927
await this.emit('data', messages.newMessageWithBody(value));
3028
}

spec/split/data/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
module.exports = {
42
'should split array of objects users': require('./splitArrayOfObjects.json'),
53
'should split array of arrays users.friends': require('./splitArrayOfArrays.json'),
@@ -10,5 +8,5 @@ module.exports = {
108
'should emit error no such property users.emails': require('./noSuchPropertySplitting.json'),
119
'should emit error for array of primitives userNames': require('./arrayOfPrimitives.json'),
1210
'should emit error when users is primitive': require('./primitiveValue.json'),
13-
'should emit object when users is object': require('./objectValue.json')
11+
'should emit object when users is object': require('./objectValue.json'),
1412
};

spec/split/split.spec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
'use strict';
2-
const expect = require('chai').expect;
1+
const { expect } = require('chai');
32
const sinon = require('sinon');
43
const splitter = require('../../split.js');
54
const data = require('./data');
@@ -9,7 +8,7 @@ describe('Splitter ', () => {
98

109
beforeEach(() => {
1110
self = {
12-
emit: sinon.spy()
11+
emit: sinon.spy(),
1312
};
1413
});
1514

@@ -18,7 +17,7 @@ describe('Splitter ', () => {
1817
const { message, config, results } = data[key];
1918
await splitter.process.call(self, message, config);
2019
for (let i = 0; i < results.length; i++) {
21-
const args = self.emit.getCall(i).args;
20+
const { args } = self.emit.getCall(i);
2221

2322
const expectedEventType = results[i][0];
2423
const actualEventType = args[0];

spec/splitOnJsonata/data/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
module.exports = {
42
'should split array from an array constructor expression': require('./arrayConstructors.json'),
53
'should split array of arrays of objects users.friends': require('./arrayOfArraysOfObjects.json'),
@@ -12,5 +10,5 @@ module.exports = {
1210
'should split array from a range query expression': require('./objectConstructors.json'),
1311
'should split root array': require('./rootArray.json'),
1412
'should split array of arrays': require('./splitArrayOfArrays.json'),
15-
'should split array of objects users': require('./splitArrayOfObjects.json')
13+
'should split array of objects users': require('./splitArrayOfObjects.json'),
1614
};

spec/splitOnJsonata/splitOnJsonata.spec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
'use strict';
2-
const expect = require('chai').expect;
1+
const { expect } = require('chai');
32
const sinon = require('sinon');
43
const splitter = require('../../lib/actions/splitOnJsonata');
54
const data = require('./data');
@@ -9,7 +8,7 @@ describe('Split on JSONata ', () => {
98

109
beforeEach(() => {
1110
self = {
12-
emit: sinon.spy()
11+
emit: sinon.spy(),
1312
};
1413
});
1514

@@ -18,7 +17,7 @@ describe('Split on JSONata ', () => {
1817
const { message, config, results } = data[key];
1918
await splitter.process.call(self, message, config);
2019
for (let i = 0; i < results.length; i++) {
21-
const args = self.emit.getCall(i).args;
20+
const { args } = self.emit.getCall(i);
2221

2322
const expectedEventType = results[i][0];
2423
const actualEventType = args[0];

split.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
'use strict';
21
const debug = require('debug')('splitter');
32
const _ = require('lodash');
4-
const messages = require('elasticio-node').messages;
3+
const { messages } = require('elasticio-node');
54

65
/** @this processAction */
76
async function processAction(msg, conf) {
87
const splitting = conf.splitter || {};
9-
let body = msg.body || {};
8+
const body = msg.body || {};
109

1110
debug('Received new message with body: %j', body);
1211
debug('Config: %j', conf);
@@ -23,22 +22,22 @@ async function processAction(msg, conf) {
2322
return;
2423
}
2524

26-
if (_.isArray(split) && _.find(split, elem => !_.isObject(elem))) {
25+
if (_.isArray(split) && _.find(split, (elem) => !_.isObject(elem))) {
2726
await this.emit('error', new Error('Splitting arrays of objects only!'));
2827
return;
2928
}
3029

3130
const result = [];
3231

3332
if (_.isArray(split)) {
34-
split.forEach(elem => result.push(elem));
33+
split.forEach((elem) => result.push(elem));
3534
} else if (_.isObject(split)) {
3635
debug(`"${splitting}" is not an array. Returning the original object`);
3736
result.push(split);
3837
}
3938

4039
debug('%s parts to emit found', result.length);
41-
for (let value of result) {
40+
for (const value of result) {
4241
if (value) {
4342
await this.emit('data', messages.newMessageWithBody(value));
4443
}

0 commit comments

Comments
 (0)