'use strict';
/**
* @author schukai GmbH
*/
import {Monster} from '../namespace.js';
import '../types/object.js';
let internalCounter = 0;
/**
*
* you can call the method via the monster namespace `new Monster.Types.ID()`.
*
* ```
* <script type="module">
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.1.0/dist/modules/types/id.js';
* console.log(new Monster.Types.ID())
* console.log(new Monster.Types.ID())
* </script>
* ```
*
* Alternatively, you can also integrate this function individually.
*
* ```
* <script type="module">
* import {ObserverList} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.1.0/dist/modules/types/id.js';
* console.log(new ID())
* console.log(new ID())
* </script>
* ```
*
* @since 1.0.0
* @copyright schukai GmbH
* @memberOf Monster/Types
*/
class ID extends Monster.Types.Object {
constructor() {
super();
internalCounter += 1;
this.id = global.btoa(Monster.Math.random(1, 10000))
.replace(/=/g, '')
/** No numbers at the beginning of the ID, because of possible problems with DOM */
.replace(/^[0-9]+/, 'X') + internalCounter;
}
toString() {
return this.id;
}
}
Monster.assignToNamespace('Monster.Types', ID);
export {Monster, ID}