初始化提交
This commit is contained in:
24
common/modules/mixly-modules/common/id-generator.js
Normal file
24
common/modules/mixly-modules/common/id-generator.js
Normal file
@@ -0,0 +1,24 @@
|
||||
goog.loadJs('common', () => {
|
||||
|
||||
goog.require('shortid');
|
||||
goog.require('Mixly');
|
||||
goog.provide('Mixly.IdGenerator');
|
||||
|
||||
const { IdGenerator } = Mixly;
|
||||
|
||||
IdGenerator.generate = function(input) {
|
||||
let output = {};
|
||||
if (input instanceof Array) {
|
||||
for (let i of input) {
|
||||
if (typeof i !== 'string') {
|
||||
continue;
|
||||
}
|
||||
output[i] = shortid.generate();
|
||||
}
|
||||
return output;
|
||||
} else {
|
||||
return shortid.generate();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user