pure-md5 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/README.md +38 -24
  2. package/dist/adapters/ie11.cjs +1 -2
  3. package/dist/adapters/ie11.js +1 -2
  4. package/dist/adapters/node.cjs +1 -2
  5. package/dist/adapters/node.js +1 -2
  6. package/dist/adapters/webcrypto.cjs +1 -2
  7. package/dist/adapters/webcrypto.js +1 -2
  8. package/dist/index.cjs +1 -2
  9. package/dist/index.d.ts +149 -5
  10. package/dist/index.js +3 -2
  11. package/dist/md5.cjs +1 -0
  12. package/dist/md5.d.ts +20 -0
  13. package/dist/md5.js +1 -0
  14. package/dist/stream/md5-stream.cjs +1 -2
  15. package/dist/stream/md5-stream.js +1 -2
  16. package/dist/stream/whatwg-stream.cjs +1 -2
  17. package/dist/stream/whatwg-stream.js +1 -2
  18. package/dist/utils/detect.cjs +1 -2
  19. package/dist/utils/detect.js +3 -2
  20. package/package.json +10 -15
  21. package/pure-md5-0.2.1.tgz +0 -0
  22. package/test-tree-shake.mjs +12 -0
  23. package/.aliases +0 -19
  24. package/.bash_profile +0 -12
  25. package/.bash_prompt +0 -56
  26. package/.changeset/README.md +0 -32
  27. package/.changeset/config.json +0 -16
  28. package/.continue/mcpServers/new-mcp-server.yaml +0 -10
  29. package/.continue/rules +0 -29
  30. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -35
  31. package/.github/ISSUE_TEMPLATE/documentation.md +0 -20
  32. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  33. package/.github/PULL_REQUEST_TEMPLATE.md +0 -35
  34. package/.github/workflows/npm-publish.yml +0 -33
  35. package/.github/workflows/release.yml +0 -42
  36. package/CHANGELOG.md +0 -9
  37. package/CONTRIBUTING.md +0 -203
  38. package/MIGRATION_GUIDE_STREAMS.md +0 -374
  39. package/STREAM_API.md +0 -582
  40. package/STREAM_BENCHMARKS.md +0 -232
  41. package/STREAM_EXAMPLES.md +0 -669
  42. package/STREAM_OPTIMIZATION_REPORT.md +0 -136
  43. package/STREAM_TROUBLESHOOTING.md +0 -537
  44. package/WEB_CRYPTO_TESTS_SUMMARY.md +0 -140
  45. package/WHATWG_STREAMS.md +0 -191
  46. package/__tests__/adapters/node-crypto.test.ts +0 -167
  47. package/__tests__/adapters/web-crypto-node.test.ts +0 -73
  48. package/__tests__/adapters/web-crypto.test.ts +0 -195
  49. package/__tests__/add32.test.ts +0 -33
  50. package/__tests__/fallback.test.ts +0 -345
  51. package/__tests__/hex.test.ts +0 -38
  52. package/__tests__/hex_chr.test.ts +0 -20
  53. package/__tests__/index.test.ts +0 -87
  54. package/__tests__/integration/fixtures/test-file.txt +0 -1
  55. package/__tests__/integration/md5-stream-file.test.ts +0 -293
  56. package/__tests__/integration/node-crypto-file.test.ts +0 -86
  57. package/__tests__/integration/web-crypto.test.ts +0 -38
  58. package/__tests__/md51.test.ts +0 -73
  59. package/__tests__/md5block.test.ts +0 -61
  60. package/__tests__/md5cycle.test.ts +0 -48
  61. package/__tests__/round-functions.test.ts +0 -87
  62. package/__tests__/stream/fs-utils.test.ts +0 -209
  63. package/__tests__/stream/md5-stream-edge-cases.test.ts +0 -461
  64. package/__tests__/stream/md5-stream.test.ts +0 -418
  65. package/__tests__/stream/whatwg-stream.test.ts +0 -355
  66. package/__tests__/stream/whatwg-stream.test.ts.bak2 +0 -335
  67. package/benchmarks/md5-stream.bench.ts +0 -212
  68. package/benchmarks/whatwg-stream.bench.ts +0 -180
  69. package/dist/adapters/ie11.cjs.map +0 -1
  70. package/dist/adapters/ie11.js.map +0 -1
  71. package/dist/adapters/node.cjs.map +0 -1
  72. package/dist/adapters/node.js.map +0 -1
  73. package/dist/adapters/webcrypto.cjs.map +0 -1
  74. package/dist/adapters/webcrypto.js.map +0 -1
  75. package/dist/chunk-2YXXFGBV.js +0 -2
  76. package/dist/chunk-2YXXFGBV.js.map +0 -1
  77. package/dist/chunk-4KSCMS4Q.js +0 -2
  78. package/dist/chunk-4KSCMS4Q.js.map +0 -1
  79. package/dist/chunk-6P2QV5SR.js +0 -4
  80. package/dist/chunk-6P2QV5SR.js.map +0 -1
  81. package/dist/chunk-G5WHEAIQ.js +0 -2
  82. package/dist/chunk-G5WHEAIQ.js.map +0 -1
  83. package/dist/chunk-H2K353LR.js +0 -2
  84. package/dist/chunk-H2K353LR.js.map +0 -1
  85. package/dist/chunk-JKVD5LHZ.js +0 -2
  86. package/dist/chunk-JKVD5LHZ.js.map +0 -1
  87. package/dist/chunk-NWQ4N5RX.js +0 -2
  88. package/dist/chunk-NWQ4N5RX.js.map +0 -1
  89. package/dist/chunk-PHZ7FTYF.js +0 -2
  90. package/dist/chunk-PHZ7FTYF.js.map +0 -1
  91. package/dist/chunk-PNZTVQA7.js +0 -2
  92. package/dist/chunk-PNZTVQA7.js.map +0 -1
  93. package/dist/chunk-R4JB5MBR.js +0 -2
  94. package/dist/chunk-R4JB5MBR.js.map +0 -1
  95. package/dist/chunk-VFOAY6XI.js +0 -2
  96. package/dist/chunk-VFOAY6XI.js.map +0 -1
  97. package/dist/chunk-XB5BQIEX.js +0 -2
  98. package/dist/chunk-XB5BQIEX.js.map +0 -1
  99. package/dist/core/index.cjs +0 -2
  100. package/dist/core/index.cjs.map +0 -1
  101. package/dist/core/index.d.cts +0 -19
  102. package/dist/core/index.d.ts +0 -19
  103. package/dist/core/index.js +0 -2
  104. package/dist/core/index.js.map +0 -1
  105. package/dist/index.cjs.map +0 -1
  106. package/dist/index.d.cts +0 -84
  107. package/dist/index.js.map +0 -1
  108. package/dist/stream/adapter.cjs +0 -2
  109. package/dist/stream/adapter.cjs.map +0 -1
  110. package/dist/stream/adapter.d.cts +0 -63
  111. package/dist/stream/adapter.d.ts +0 -63
  112. package/dist/stream/adapter.js +0 -2
  113. package/dist/stream/adapter.js.map +0 -1
  114. package/dist/stream/fs-utils.cjs +0 -2
  115. package/dist/stream/fs-utils.cjs.map +0 -1
  116. package/dist/stream/fs-utils.d.cts +0 -137
  117. package/dist/stream/fs-utils.d.ts +0 -137
  118. package/dist/stream/fs-utils.js +0 -2
  119. package/dist/stream/fs-utils.js.map +0 -1
  120. package/dist/stream/index.cjs +0 -2
  121. package/dist/stream/index.cjs.map +0 -1
  122. package/dist/stream/index.d.cts +0 -4
  123. package/dist/stream/index.d.ts +0 -4
  124. package/dist/stream/index.js +0 -2
  125. package/dist/stream/index.js.map +0 -1
  126. package/dist/stream/light/index.cjs +0 -2
  127. package/dist/stream/light/index.cjs.map +0 -1
  128. package/dist/stream/light/index.d.cts +0 -4
  129. package/dist/stream/light/index.d.ts +0 -4
  130. package/dist/stream/light/index.js +0 -2
  131. package/dist/stream/light/index.js.map +0 -1
  132. package/dist/stream/md5-stream.cjs.map +0 -1
  133. package/dist/stream/md5-stream.js.map +0 -1
  134. package/dist/stream/whatwg-stream.cjs.map +0 -1
  135. package/dist/stream/whatwg-stream.js.map +0 -1
  136. package/dist/types-edGoGJ5V.d.cts +0 -42
  137. package/dist/types-edGoGJ5V.d.ts +0 -42
  138. package/dist/utils/detect.cjs.map +0 -1
  139. package/dist/utils/detect.js.map +0 -1
  140. package/planning/03-optimization-size-tree-shaking/01-es-modules-tree-shaking.md +0 -152
  141. package/planning/03-optimization-size-tree-shaking/02-consolidate-modules.md +0 -65
  142. package/planning/03-optimization-size-tree-shaking/03-remove-duplicate-add32.md +0 -93
  143. package/planning/03-optimization-size-tree-shaking/04-remove-runtime-check.md +0 -102
  144. package/planning/03-optimization-size-tree-shaking/05-optimize-loops-performance.md +0 -107
  145. package/planning/03-optimization-size-tree-shaking/06-tsup-formats-configuration.md +0 -227
  146. package/planning/03-optimization-size-tree-shaking/07-multiple-build-formats.md +0 -228
  147. package/planning/03-optimization-size-tree-shaking/08-benchmarks-metrics.md +0 -34
  148. package/planning/03-optimization-size-tree-shaking/MIGRATION_GUIDE.md +0 -260
  149. package/planning/03-optimization-size-tree-shaking/README.md +0 -173
  150. package/planning/03-optimization-size-tree-shaking/SUMMARY.md +0 -168
  151. package/planning/04-adapter-backend/03-backend-web-crypto.md +0 -149
  152. package/planning/04-adapter-backend/04-backend-node-crypto.md +0 -181
  153. package/planning/04-adapter-backend/05-backend-pure-js.md +0 -174
  154. package/planning/04-adapter-backend/06-backend-ie11.md +0 -158
  155. package/planning/04-adapter-backend/07-detection-environment.md +0 -232
  156. package/planning/04-adapter-backend/08-detection-backend.md +0 -210
  157. package/planning/04-adapter-backend/09-adapter-unified.md +0 -255
  158. package/planning/04-adapter-backend/10-fallback-mechanism.md +0 -333
  159. package/planning/04-adapter-backend/11-tests-backend-web-crypto.md +0 -191
  160. package/planning/04-adapter-backend/12-tests-backend-node-crypto.md +0 -222
  161. package/planning/04-adapter-backend/README.md +0 -45
  162. package/planning/05-documentation-publishing/01-README-optimization.md +0 -105
  163. package/planning/05-documentation-publishing/02-VitePress-site-evaluation.md +0 -136
  164. package/planning/05-documentation-publishing/03-Changeset-setup.md +0 -192
  165. package/planning/05-documentation-publishing/04-GitHub-templates.md +0 -252
  166. package/planning/05-documentation-publishing/README.md +0 -22
  167. package/planning/05-documentation-publishing/STATUS.md +0 -222
  168. package/planning/prd.md +0 -405
  169. package/planning/streams/01-create-md5stream-class.md +0 -69
  170. package/planning/streams/02-create-factory-api.md +0 -65
  171. package/planning/streams/03-fs-integration.md +0 -37
  172. package/planning/streams/04-whatwg-streams-support.md +0 -37
  173. package/planning/streams/05-audit-optimization.md +0 -121
  174. package/planning/streams/06-comprehensive-tests-docs.md +0 -137
  175. package/planning/streams/07-architecture-integration.md +0 -38
  176. package/planning/streams/README.md +0 -98
  177. package/tsup.config.ts +0 -24
@@ -1,87 +0,0 @@
1
- import { ff, gg, hh, ii } from '../src/round-functions';
2
- import add32 from '../src/add32';
3
-
4
- describe('Round Functions', () => {
5
- const fn = add32;
6
- const a = 0x12345678;
7
- const b = 0x9abcdef0;
8
- const c = 0xfedcba98;
9
- const d = 0x76543210;
10
- const x = 0x13579bdf;
11
- const s = 7;
12
- const t = 0x5a827999;
13
-
14
- describe('ff', () => {
15
- test('should compute F function correctly', () => {
16
- const result = ff(fn, a, b, c, d, x, s, t);
17
-
18
- // Manually compute expected value
19
- const f = (b & c) | (~b & d);
20
- const add = fn;
21
- let expected = add(a, f);
22
- expected = add(expected, x);
23
- expected = add(expected, t);
24
- expected = add((expected << s) | (expected >>> (32 - s)), b);
25
-
26
- expect(result).toBe(expected);
27
- });
28
-
29
- test('should handle different inputs', () => {
30
- const result1 = ff(fn, 0, 0, 0, 0, 0, 0, 0);
31
- expect(result1).toBe(0);
32
-
33
- const result2 = ff(fn, -1, -1, -1, -1, -1, 1, -1);
34
- // Result should be a 32-bit integer (can be negative in two's complement)
35
- expect(result2).toBeGreaterThanOrEqual(-0x80000000);
36
- expect(result2).toBeLessThanOrEqual(0xffffffff);
37
- });
38
- });
39
-
40
- describe('gg', () => {
41
- test('should compute G function correctly', () => {
42
- const result = gg(fn, a, b, c, d, x, s, t);
43
-
44
- // Manually compute expected value
45
- const g = (b & d) | (c & ~d);
46
- const add = fn;
47
- let expected = add(a, g);
48
- expected = add(expected, x);
49
- expected = add(expected, t);
50
- expected = add((expected << s) | (expected >>> (32 - s)), b);
51
-
52
- expect(result).toBe(expected);
53
- });
54
- });
55
-
56
- describe('hh', () => {
57
- test('should compute H function correctly', () => {
58
- const result = hh(fn, a, b, c, d, x, s, t);
59
-
60
- // Manually compute expected value
61
- const h = b ^ c ^ d;
62
- const add = fn;
63
- let expected = add(a, h);
64
- expected = add(expected, x);
65
- expected = add(expected, t);
66
- expected = add((expected << s) | (expected >>> (32 - s)), b);
67
-
68
- expect(result).toBe(expected);
69
- });
70
- });
71
-
72
- describe('ii', () => {
73
- test('should compute I function correctly', () => {
74
- const result = ii(fn, a, b, c, d, x, s, t);
75
-
76
- // Manually compute expected value
77
- const i = c ^ (b | ~d);
78
- const add = fn;
79
- let expected = add(a, i);
80
- expected = add(expected, x);
81
- expected = add(expected, t);
82
- expected = add((expected << s) | (expected >>> (32 - s)), b);
83
-
84
- expect(result).toBe(expected);
85
- });
86
- });
87
- });
@@ -1,209 +0,0 @@
1
- /**
2
- * Tests for file system utilities (fs-utils)
3
- */
4
-
5
- import fs from 'fs';
6
- import path from 'path';
7
- import { Readable } from 'stream';
8
- import {
9
- hashFile,
10
- hashFileStream,
11
- hashFileSync,
12
- verifyFile,
13
- createProgressTracker
14
- } from '../../src/stream/fs-utils.js';
15
- import { md5Core } from '../../src/core/index.js';
16
-
17
- describe('File System Utilities', () => {
18
- const fixturesDir = path.join(__dirname, '..', 'integration', 'fixtures');
19
- const testFile = path.join(fixturesDir, 'test-file.txt');
20
- const nonExistentFile = path.join(fixturesDir, 'non-existent.txt');
21
-
22
- describe('hashFile', () => {
23
- test('should hash a text file correctly', async () => {
24
- const result = await hashFile(testFile);
25
-
26
- expect(result.digest).toBe(md5Core('Hello, World!\n'));
27
- expect(result.bytesProcessed).toBe(14);
28
- expect(typeof result.digest).toBe('string');
29
- expect(result.digest.length).toBe(32);
30
- });
31
-
32
- test('should hash a binary file correctly', async () => {
33
- const tempFile = path.join(fixturesDir, 'temp-binary.bin');
34
- const buffer = Buffer.from([0x00, 0x01, 0x02, 0xff, 0xfe, 0xfd]);
35
-
36
- try {
37
- fs.writeFileSync(tempFile, buffer);
38
- const result = await hashFile(tempFile);
39
-
40
- expect(/^[0-9a-f]{32}$/.test(result.digest)).toBe(true);
41
- expect(result.bytesProcessed).toBe(6);
42
- } finally {
43
- if (fs.existsSync(tempFile)) {
44
- fs.unlinkSync(tempFile);
45
- }
46
- }
47
- });
48
-
49
- test('should handle large files', async () => {
50
- const tempFile = path.join(fixturesDir, 'temp-large.bin');
51
- const bufferSize = 1024 * 1024;
52
- const buffer = Buffer.alloc(bufferSize, 'a');
53
-
54
- try {
55
- fs.writeFileSync(tempFile, buffer);
56
- const result = await hashFile(tempFile);
57
-
58
- expect(result.bytesProcessed).toBe(bufferSize);
59
- expect(result.digest.length).toBe(32);
60
- } finally {
61
- if (fs.existsSync(tempFile)) {
62
- fs.unlinkSync(tempFile);
63
- }
64
- }
65
- });
66
-
67
- test('should throw error for non-existent file', async () => {
68
- await expect(hashFile(nonExistentFile)).rejects.toThrow('File not found');
69
- });
70
-
71
- test('should throw error for directory instead of file', async () => {
72
- await expect(hashFile(fixturesDir)).rejects.toThrow('Path is not a file');
73
- });
74
-
75
- test('should support chunkSize option', async () => {
76
- const result = await hashFile(testFile, { chunkSize: 1024 });
77
- expect(result.digest).toBe(md5Core('Hello, World!\n'));
78
- });
79
-
80
- test('should support onProgress option', async () => {
81
- const progressValues: number[] = [];
82
- const result = await hashFile(testFile, {
83
- onProgress: (current) => {
84
- progressValues.push(current);
85
- }
86
- });
87
-
88
- expect(result.digest).toBe(md5Core('Hello, World!\n'));
89
- expect(progressValues.length).toBeGreaterThan(0);
90
- expect(progressValues[progressValues.length - 1]).toBe(14);
91
- });
92
- });
93
-
94
- describe('hashFileStream', () => {
95
- test('should hash a readable stream correctly', async () => {
96
- const stream = fs.createReadStream(testFile);
97
- const result = await hashFileStream(stream);
98
-
99
- expect(result.digest).toBe(md5Core('Hello, World!\n'));
100
- expect(result.bytesProcessed).toBe(14);
101
- });
102
-
103
- test('should handle buffer input through stream', async () => {
104
- const buffer = Buffer.from('stream test data');
105
- const stream = Readable.from([buffer]);
106
- const result = await hashFileStream(stream);
107
-
108
- expect(result.digest).toBe(md5Core('stream test data'));
109
- expect(result.bytesProcessed).toBe(16);
110
- });
111
-
112
- test('should handle empty stream', async () => {
113
- const stream = Readable.from([]);
114
- const result = await hashFileStream(stream);
115
-
116
- expect(result.digest).toBe(md5Core(''));
117
- expect(result.bytesProcessed).toBe(0);
118
- });
119
-
120
- test('should throw error for invalid stream', async () => {
121
- await expect(hashFileStream(null as any)).rejects.toThrow('Invalid readable stream');
122
- });
123
- });
124
-
125
- describe('hashFileSync', () => {
126
- test('should hash a text file synchronously', () => {
127
- const digest = hashFileSync(testFile);
128
-
129
- expect(typeof digest).toBe('string');
130
- expect(digest.length).toBe(32);
131
- expect(digest).toBe(md5Core('Hello, World!\n'));
132
- });
133
-
134
- test('should hash a binary file synchronously', () => {
135
- const tempFile = path.join(fixturesDir, 'temp-sync.bin');
136
- const buffer = Buffer.from([0x10, 0x20, 0x30]);
137
-
138
- try {
139
- fs.writeFileSync(tempFile, buffer);
140
- const digest = hashFileSync(tempFile);
141
-
142
- expect(/^[0-9a-f]{32}$/.test(digest)).toBe(true);
143
- } finally {
144
- if (fs.existsSync(tempFile)) {
145
- fs.unlinkSync(tempFile);
146
- }
147
- }
148
- });
149
-
150
- test('should throw error for non-existent file', () => {
151
- expect(() => hashFileSync(nonExistentFile)).toThrow('File not found');
152
- });
153
-
154
- test('should throw error for directory', () => {
155
- expect(() => hashFileSync(fixturesDir)).toThrow('Path is not a file');
156
- });
157
- });
158
-
159
- describe('verifyFile', () => {
160
- test('should verify correct digest', async () => {
161
- const digest = md5Core('Hello, World!\n');
162
- const result = await verifyFile(testFile, digest);
163
-
164
- expect(result).toBe(true);
165
- });
166
-
167
- test('should reject incorrect digest', async () => {
168
- const result = await verifyFile(testFile, 'invalid digest');
169
-
170
- expect(result).toBe(false);
171
- });
172
-
173
- test('should be case-insensitive for digest', async () => {
174
- const digest = md5Core('Hello, World!\n').toUpperCase();
175
- const result = await verifyFile(testFile, digest);
176
-
177
- expect(result).toBe(true);
178
- });
179
- });
180
-
181
- describe('createProgressTracker', () => {
182
- test('should create a progress callback', () => {
183
- const progressValues: number[] = [];
184
- const tracker = createProgressTracker(100, (percent) => {
185
- progressValues.push(percent);
186
- });
187
-
188
- tracker(25);
189
- tracker(50);
190
- tracker(75);
191
- tracker(100);
192
-
193
- expect(progressValues.length).toBeGreaterThan(0);
194
- expect(progressValues[progressValues.length - 1]).toBe(100);
195
- });
196
- });
197
-
198
- describe('integration with MD5Stream', () => {
199
- test('should produce same hash as MD5Stream', async () => {
200
- const stream = fs.createReadStream(testFile);
201
- const { MD5Stream, pipeThroughMD5 } = require('../../src/stream/md5-stream.js');
202
- const md5Stream = new MD5Stream();
203
- const streamResult = await pipeThroughMD5.call(md5Stream, stream);
204
- const fileResult = await hashFile(testFile);
205
-
206
- expect(streamResult.digest).toBe(fileResult.digest);
207
- });
208
- });
209
- });