Notes/src/services/source_id.js

28 lines
470 B
JavaScript
Raw Normal View History

const utils = require('./utils');
2020-07-02 22:57:17 +02:00
const localSourceIds = {};
2020-06-20 12:31:38 +02:00
function generateSourceId() {
2020-07-02 22:57:17 +02:00
const sourceId = utils.randomString(12);
2020-07-02 22:57:17 +02:00
localSourceIds[sourceId] = true;
return sourceId;
}
function isLocalSourceId(srcId) {
2020-07-02 22:57:17 +02:00
return !!localSourceIds[srcId];
}
2020-07-02 22:57:17 +02:00
const currentSourceId = generateSourceId();
function getCurrentSourceId() {
return currentSourceId;
}
module.exports = {
generateSourceId,
getCurrentSourceId,
isLocalSourceId
2020-06-20 12:31:38 +02:00
};