Urara-Blog/node_modules/.pnpm-store/v3/files/4d/088954cd9a0f961b141cd67fc1cdc48bb50c014f0d422bec5db641a72333e457901cdb93f4edb75129bf8ee0b140c80c9be15d09ab48dc2f66d8bf21a80ad3
2022-08-14 01:14:53 +08:00

45 lines
950 B
Text

/**
* @fileoverview A class of identifiers generator for code path segments.
*
* Each rule uses the identifier of code path segments to store additional
* information of the code path.
*
* @author Toru Nagashima
*/
"use strict";
//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------
/**
* A generator for unique ids.
*/
class IdGenerator {
/**
* @param {string} prefix Optional. A prefix of generated ids.
*/
constructor(prefix) {
this.prefix = String(prefix);
this.n = 0;
}
/**
* Generates id.
* @returns {string} A generated id.
*/
next() {
this.n = 1 + this.n | 0;
/* istanbul ignore if */
if (this.n < 0) {
this.n = 1;
}
return this.prefix + this.n;
}
}
module.exports = IdGenerator;