1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- "use strict";
- const { DEFAULTS } = require("./config/defaults");
- const createHash = require("./util/createHash");
- class DependencyTemplates {
-
- constructor(hashFunction = DEFAULTS.HASH_FUNCTION) {
-
- this._map = new Map();
-
- this._hash = "31d6cfe0d16ae931b73c59d7e0c089c0";
- this._hashFunction = hashFunction;
- }
-
- get(dependency) {
- return this._map.get(dependency);
- }
-
- set(dependency, dependencyTemplate) {
- this._map.set(dependency, dependencyTemplate);
- }
-
- updateHash(part) {
- const hash = createHash(this._hashFunction);
- hash.update(`${this._hash}${part}`);
- this._hash = (hash.digest("hex"));
- }
- getHash() {
- return this._hash;
- }
- clone() {
- const newInstance = new DependencyTemplates(this._hashFunction);
- newInstance._map = new Map(this._map);
- newInstance._hash = this._hash;
- return newInstance;
- }
- }
- module.exports = DependencyTemplates;
|