2017-10-31 00:15:49 -04:00
|
|
|
const utils = require('./utils');
|
2017-12-23 13:55:13 -05:00
|
|
|
|
2020-07-02 22:57:17 +02:00
|
|
|
const localSourceIds = {};
|
2017-12-23 13:55:13 -05:00
|
|
|
|
2020-06-20 12:31:38 +02:00
|
|
|
function generateSourceId() {
|
2020-07-02 22:57:17 +02:00
|
|
|
const sourceId = utils.randomString(12);
|
2017-12-23 13:55:13 -05:00
|
|
|
|
2020-07-02 22:57:17 +02:00
|
|
|
localSourceIds[sourceId] = true;
|
2017-12-16 20:48:34 -05:00
|
|
|
|
|
|
|
return sourceId;
|
|
|
|
}
|
2017-11-16 21:50:00 -05:00
|
|
|
|
|
|
|
function isLocalSourceId(srcId) {
|
2020-07-02 22:57:17 +02:00
|
|
|
return !!localSourceIds[srcId];
|
2017-11-16 21:50:00 -05:00
|
|
|
}
|
|
|
|
|
2020-07-02 22:57:17 +02:00
|
|
|
const currentSourceId = generateSourceId();
|
2017-12-16 21:23:35 -05:00
|
|
|
|
2017-12-23 13:55:13 -05:00
|
|
|
function getCurrentSourceId() {
|
|
|
|
return currentSourceId;
|
2017-12-16 21:23:35 -05:00
|
|
|
}
|
2017-12-16 20:48:34 -05:00
|
|
|
|
2017-11-16 21:50:00 -05:00
|
|
|
module.exports = {
|
2017-12-16 20:48:34 -05:00
|
|
|
generateSourceId,
|
2017-12-16 21:23:35 -05:00
|
|
|
getCurrentSourceId,
|
2017-11-16 21:50:00 -05:00
|
|
|
isLocalSourceId
|
2020-06-20 12:31:38 +02:00
|
|
|
};
|