Skip to content

Commit d4787b3

Browse files
committed
fix: fix compatibility with old version
1 parent 279f89e commit d4787b3

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

build-worker.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
var fs = require('fs');
22

33
function cleanJavascriptFile(content) {
4-
content = content.replace(/^.*export.*$/mi, ''); // Remove exports
5-
content = content.replace(/^.*export.*$/mi, ''); // Remove exports
6-
content = content.replace(/^.*export.*$/mi, ''); // Remove exports
7-
content = content.replace(/^.*require.*$/mi, ''); // Remove reqires
8-
content = content.replace(/md5_1\./g, ''); // Fix reference to Md5 class
9-
content = content.replace(/\n\n/g, '\n'); // Reduce new lines
10-
return content;
4+
var output = content;
5+
output = output.replace(/^.*export.*$/mi, ''); // Remove exports
6+
output = output.replace(/^.*export.*$/mi, ''); // Remove exports
7+
output = output.replace(/^.*export.*$/mi, ''); // Remove exports
8+
output = output.replace(/^.*require.*$/mi, ''); // Remove reqires
9+
output = output.replace(/md5_1\./g, ''); // Fix reference to Md5 class
10+
output = output.replace(/\n\n/g, '\n'); // Reduce new lines
11+
return output;
1112
}
1213

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

2122
file_hasher = cleanJavascriptFile(file_hasher);
22-
md5 = cleanJavascriptFile(md5);
23+
var md5_clean = cleanJavascriptFile(md5);
2324

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

26-
fs.writeFileSync('./dist/md5_worker.js', file_hasher + md5 + worker);
27+
fs.writeFileSync('./dist/md5_worker.js', file_hasher + md5_clean + worker);
28+
29+
fs.writeFileSync('./dist/md5.js', md5);

src/md5.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ interface HasherState {
6262
export class Md5 {
6363

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

293293
/**
294-
* Append a UTF8 string to the hash buffer
294+
* Append a UTF-8 string to the hash buffer
295295
* @param str String to append
296296
*/
297297
public appendStr(str: string) {

0 commit comments

Comments
 (0)