Skip to content

Commit

Permalink
fix: fix compatibility with old version
Browse files Browse the repository at this point in the history
  • Loading branch information
MrYuion committed Aug 16, 2022
1 parent 279f89e commit d4787b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
21 changes: 12 additions & 9 deletions build-worker.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
var fs = require('fs');

function cleanJavascriptFile(content) {
content = content.replace(/^.*export.*$/mi, ''); // Remove exports
content = content.replace(/^.*export.*$/mi, ''); // Remove exports
content = content.replace(/^.*export.*$/mi, ''); // Remove exports
content = content.replace(/^.*require.*$/mi, ''); // Remove reqires
content = content.replace(/md5_1\./g, ''); // Fix reference to Md5 class
content = content.replace(/\n\n/g, '\n'); // Reduce new lines
return content;
var output = content;
output = output.replace(/^.*export.*$/mi, ''); // Remove exports
output = output.replace(/^.*export.*$/mi, ''); // Remove exports
output = output.replace(/^.*export.*$/mi, ''); // Remove exports
output = output.replace(/^.*require.*$/mi, ''); // Remove reqires
output = output.replace(/md5_1\./g, ''); // Fix reference to Md5 class
output = output.replace(/\n\n/g, '\n'); // Reduce new lines
return output;
}

console.log("Loading javascript files...");
Expand All @@ -19,8 +20,10 @@ var worker = fs.readFileSync('./src/worker.js').toString();
console.log("Clean javascript files...");

file_hasher = cleanJavascriptFile(file_hasher);
md5 = cleanJavascriptFile(md5);
var md5_clean = cleanJavascriptFile(md5);

console.log("Creating worker javascript...");

fs.writeFileSync('./dist/md5_worker.js', file_hasher + md5 + worker);
fs.writeFileSync('./dist/md5_worker.js', file_hasher + md5_clean + worker);

fs.writeFileSync('./dist/md5.js', md5);
4 changes: 2 additions & 2 deletions src/md5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ interface HasherState {
export class Md5 {

/**
* Hash a UTF8 string on the spot
* Hash a UTF-8 string on the spot
* @param str String to hash
* @param raw Whether to return the value as an `Int32Array`
*/
Expand Down Expand Up @@ -291,7 +291,7 @@ export class Md5 {
// #Example.3A_Fixing_charCodeAt_to_handle_non-Basic-Multilingual-Plane_characters_if_their_presence_earlier_in_the_string_is_unknown

/**
* Append a UTF8 string to the hash buffer
* Append a UTF-8 string to the hash buffer
* @param str String to append
*/
public appendStr(str: string) {
Expand Down

0 comments on commit d4787b3

Please sign in to comment.