diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-04-04 21:03:28 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-04-04 21:03:28 +0200 |
| commit | a6b1c4139a485595fd858fa447d893725d43a015 (patch) | |
| tree | dfa4f895da50dd55d520ab6e56b0d6e22d8cdec3 | |
| parent | de9bd96b5ccda3b9a354cf3e02d49012bdc177d4 (diff) | |
| download | compiler-a6b1c4139a485595fd858fa447d893725d43a015.tar.gz compiler-a6b1c4139a485595fd858fa447d893725d43a015.zip | |
filter undefined or null objects
| -rw-r--r-- | worker.js | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -64,8 +64,10 @@ var RABBITMQ_URI = process.env.RABBITMQ_URI || "amqp://localhost", // processor sends to queue with a custom "type" so compiler can filter // m.content: player.api_id - let players = msgs.filter((m) => m.properties.type == "player").map((m) => JSON.parse(m.content)), - participants = msgs.filter((m) => m.properties.type == "participant").map((m) => JSON.parse(m.content)); + let players = msgs.filter((m) => m.properties.type == "player").map( + (m) => JSON.parse(m.content)).filter((p) => p != undefined), + participants = msgs.filter((m) => m.properties.type == "participant").map( + (m) => JSON.parse(m.content)).filter((p) => p != undefined); // collect information and populate _record arrays await Promise.all([ |
