You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
634 B
JavaScript

"use strict";
// TODO: If the derivation logic changes, these IDs may not be stable. Need to figure out whether that's going to be an issue or not, and whether we may need to replace it with a deterministic algorithm that eg. takes a key-returning callback (which uses the event data to generate it).
module.exports = function numberDerivedEvents(id, events) {
// NOTE: Mutates `events`!
let i = 0;
for (let event of events) {
// NOTE: We do this so that each derived event has a unique ID, but it is still possible to refer back to the original event ID
event.id = `${id}_${i}`;
event.sourceEventID = id;
i += 1;
}
};