Extract IIFE into separate function
This commit is contained in:
parent
11f98474ba
commit
b7b6195cfc
1 changed files with 23 additions and 22 deletions
|
@ -91,7 +91,11 @@ const createRandomMessage = ({ conversationId } = {}) => {
|
||||||
type,
|
type,
|
||||||
};
|
};
|
||||||
|
|
||||||
const message = (() => {
|
const message = _createMessage({ commonProperties, conversationId, type });
|
||||||
|
return Message.initializeSchemaVersion(message);
|
||||||
|
};
|
||||||
|
|
||||||
|
const _createMessage = ({ commonProperties, conversationId, type } = {}) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'incoming':
|
case 'incoming':
|
||||||
return Object.assign({}, commonProperties, {
|
return Object.assign({}, commonProperties, {
|
||||||
|
@ -111,9 +115,6 @@ const createRandomMessage = ({ conversationId } = {}) => {
|
||||||
default:
|
default:
|
||||||
throw new TypeError(`Unknown message type: '${type}'`);
|
throw new TypeError(`Unknown message type: '${type}'`);
|
||||||
}
|
}
|
||||||
})();
|
|
||||||
|
|
||||||
return Message.initializeSchemaVersion(message);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const MEGA_BYTE = 1e6;
|
const MEGA_BYTE = 1e6;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue