- 1 :
/**
- 2 :
* @file guid.js
- 3 :
* @module guid
- 4 :
*/
- 5 :
- 6 :
// Default value for GUIDs. This allows us to reset the GUID counter in tests.
- 7 :
//
- 8 :
// The initial GUID is 3 because some users have come to rely on the first
- 9 :
// default player ID ending up as `vjs_video_3`.
- 10 :
//
- 11 :
// See: https://github.com/videojs/video.js/pull/6216
- 12 :
const _initialGuid = 3;
- 13 :
- 14 :
/**
- 15 :
* Unique ID for an element or function
- 16 :
*
- 17 :
* @type {Number}
- 18 :
*/
- 19 :
let _guid = _initialGuid;
- 20 :
- 21 :
/**
- 22 :
* Get a unique auto-incrementing ID by number that has not been returned before.
- 23 :
*
- 24 :
* @return {number}
- 25 :
* A new unique ID.
- 26 :
*/
- 27 :
export function newGUID() {
- 28 :
return _guid++;
- 29 :
}
- 30 :
- 31 :
/**
- 32 :
* Reset the unique auto-incrementing ID for testing only.
- 33 :
*/
- 34 :
export function resetGuidInTestsOnly() {
- 35 :
_guid = _initialGuid;
- 36 :
}