File size: 454 Bytes
30c32c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class VariablePool {
    /**
     * @param {string} prefix The prefix at the start of the variable name.
     */
    constructor (prefix) {
        if (prefix.trim().length === 0) {
            throw new Error('prefix cannot be empty');
        }
        this.prefix = prefix;
        /**
         * @private
         */
        this.count = 0;
    }

    next () {
        return `${this.prefix}${this.count++}`;
    }
}

module.exports = VariablePool;