feat: refactoring project
This commit is contained in:
4
node_modules/webpack/lib/util/hash/md4.js
generated
vendored
4
node_modules/webpack/lib/util/hash/md4.js
generated
vendored
@@ -7,7 +7,7 @@
|
||||
|
||||
const create = require("./wasm-hash");
|
||||
|
||||
//#region wasm code: md4 (../../../assembly/hash/md4.asm.ts) --initialMemory 1
|
||||
// #region wasm code: md4 (../../../assembly/hash/md4.asm.ts) --initialMemory 1
|
||||
const md4 = new WebAssembly.Module(
|
||||
Buffer.from(
|
||||
// 2154 bytes
|
||||
@@ -15,6 +15,6 @@ const md4 = new WebAssembly.Module(
|
||||
"base64"
|
||||
)
|
||||
);
|
||||
//#endregion
|
||||
// #endregion
|
||||
|
||||
module.exports = create.bind(null, md4, [], 64, 32);
|
||||
|
||||
27
node_modules/webpack/lib/util/hash/wasm-hash.js
generated
vendored
27
node_modules/webpack/lib/util/hash/wasm-hash.js
generated
vendored
@@ -133,6 +133,10 @@ class WasmHash {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {BufferEncoding} type type
|
||||
* @returns {Buffer | string} digest
|
||||
*/
|
||||
digest(type) {
|
||||
const { exports, buffered, mem, digestSize } = this;
|
||||
exports.final(buffered);
|
||||
@@ -144,19 +148,26 @@ class WasmHash {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {TODO} wasmModule wasm module
|
||||
* @param {WasmHash[]} instancesPool pool of instances
|
||||
* @param {number} chunkSize size of data chunks passed to wasm
|
||||
* @param {number} digestSize size of digest returned by wasm
|
||||
* @returns {WasmHash} wasm hash
|
||||
*/
|
||||
const create = (wasmModule, instancesPool, chunkSize, digestSize) => {
|
||||
if (instancesPool.length > 0) {
|
||||
const old = instancesPool.pop();
|
||||
const old = /** @type {WasmHash} */ (instancesPool.pop());
|
||||
old.reset();
|
||||
return old;
|
||||
} else {
|
||||
return new WasmHash(
|
||||
new WebAssembly.Instance(wasmModule),
|
||||
instancesPool,
|
||||
chunkSize,
|
||||
digestSize
|
||||
);
|
||||
}
|
||||
|
||||
return new WasmHash(
|
||||
new WebAssembly.Instance(wasmModule),
|
||||
instancesPool,
|
||||
chunkSize,
|
||||
digestSize
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = create;
|
||||
|
||||
4
node_modules/webpack/lib/util/hash/xxhash64.js
generated
vendored
4
node_modules/webpack/lib/util/hash/xxhash64.js
generated
vendored
@@ -7,7 +7,7 @@
|
||||
|
||||
const create = require("./wasm-hash");
|
||||
|
||||
//#region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1
|
||||
// #region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1
|
||||
const xxhash64 = new WebAssembly.Module(
|
||||
Buffer.from(
|
||||
// 1160 bytes
|
||||
@@ -15,6 +15,6 @@ const xxhash64 = new WebAssembly.Module(
|
||||
"base64"
|
||||
)
|
||||
);
|
||||
//#endregion
|
||||
// #endregion
|
||||
|
||||
module.exports = create.bind(null, xxhash64, [], 32, 16);
|
||||
|
||||
Reference in New Issue
Block a user