EDITOR'S NOTE: this could have been done with streams! You don't have to (and probably shouldn't) re-write it at this point, this is just illustrative:

```js
const ws = Criteria.createWriteStream()
criteria.map(function(c){ c.badgeId = badgeId; return c }).forEach(ws.write)
ws.end()
ws.on('done', /* success handler */)
ws.on('error', /* error handler */)
```