@guanghechen/filesplit 2.0.1

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,727 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file. See
4
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 1.0.0-alpha.23 (2024-09-18)
7
+
8
+ - :wrench: chore: upgrade devDependencies and fix configs
9
+ ([230fb63](https://github.com/guanghechen/sora/commit/230fb63))
10
+
11
+ # Change Log
12
+
13
+ All notable changes to this project will be documented in this file. See
14
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
15
+
16
+ # [1.0.0-alpha.22](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.21...@guanghechen/file-split@1.0.0-alpha.22) (2024-03-10)
17
+
18
+ ### Performance Improvements
19
+
20
+ - :art: format codes
21
+ ([177eb54](https://github.com/guanghechen/sora/commit/177eb5407fe9209269541a327d42084901a63090))
22
+
23
+ # Change Log
24
+
25
+ All notable changes to this project will be documented in this file. See
26
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
27
+
28
+ # [1.0.0-alpha.21](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.20...@guanghechen/file-split@1.0.0-alpha.21) (2024-03-09)
29
+
30
+ **Note:** Version bump only for package @guanghechen/file-split
31
+
32
+ # Change Log
33
+
34
+ All notable changes to this project will be documented in this file. See
35
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
36
+
37
+ # [1.0.0-alpha.20](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.19...@guanghechen/file-split@1.0.0-alpha.20) (2024-02-03)
38
+
39
+ ### Performance Improvements
40
+
41
+ - 💄 fix lint
42
+ ([2d5bb6f](https://github.com/guanghechen/sora/commit/2d5bb6f03d0312a42c1117d95181df8b69de827a))
43
+ - 🔧 fix nx scripts
44
+ ([47bc4e6](https://github.com/guanghechen/sora/commit/47bc4e66df825cb37127219bccf60dc81d6a9b48))
45
+ - 🔧 update tsconfig
46
+ ([98855bc](https://github.com/guanghechen/sora/commit/98855bcc245d98c61217c5bafc6a1b2506b7824d))
47
+
48
+ # Change Log
49
+
50
+ All notable changes to this project will be documented in this file. See
51
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
52
+
53
+ # [1.0.0-alpha.19](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.18...@guanghechen/file-split@1.0.0-alpha.19) (2024-01-15)
54
+
55
+ **Note:** Version bump only for package @guanghechen/file-split
56
+
57
+ # [1.0.0-alpha.18](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.17...@guanghechen/file-split@1.0.0-alpha.18) (2024-01-02)
58
+
59
+ **Note:** Version bump only for package @guanghechen/file-split
60
+
61
+ # [1.0.0-alpha.17](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.16...@guanghechen/file-split@1.0.0-alpha.17) (2023-12-10)
62
+
63
+ ### Performance Improvements
64
+
65
+ - 🎨 export const DEFAULT_FILEPART_CODE_PREFIX from @guanghechen/filepart.types
66
+ ([d6d2b1d](https://github.com/guanghechen/sora/commit/d6d2b1d960a9a02b3315c4cbd32cdc1fa53cccc3))
67
+ - 🎨 make methods return iterator instead of array
68
+ ([1fddedd](https://github.com/guanghechen/sora/commit/1fddedd8a8de6b21c0431bdacf2a7d8a17bd2c86))
69
+ - 🎨 move filepart related code from @guanghechen/file-split to new package @guanghechen/filepart
70
+ ([833aa10](https://github.com/guanghechen/sora/commit/833aa10f4eee38b09a375b221a0a763f96d8fd4c))
71
+
72
+ # [1.0.0-alpha.16](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.15...@guanghechen/file-split@1.0.0-alpha.16) (2023-12-07)
73
+
74
+ ### Performance Improvements
75
+
76
+ - 🎨 add interface for FileSplitter
77
+ ([0aefc92](https://github.com/guanghechen/sora/commit/0aefc92678d981d10e5cef4bab9227d1c0fc9d7d))
78
+
79
+ # [1.0.0-alpha.15](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.14...@guanghechen/file-split@1.0.0-alpha.15) (2023-12-04)
80
+
81
+ **Note:** Version bump only for package @guanghechen/file-split
82
+
83
+ # [1.0.0-alpha.14](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.13...@guanghechen/file-split@1.0.0-alpha.14) (2023-12-03)
84
+
85
+ **Note:** Version bump only for package @guanghechen/file-split
86
+
87
+ # [1.0.0-alpha.13](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.12...@guanghechen/file-split@1.0.0-alpha.13) (2023-12-02)
88
+
89
+ **Note:** Version bump only for package @guanghechen/file-split
90
+
91
+ # [1.0.0-alpha.12](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.11...@guanghechen/file-split@1.0.0-alpha.12) (2023-11-29)
92
+
93
+ ### Performance Improvements
94
+
95
+ - 🔧 no longer to require node engine version in packages
96
+ ([6dc2014](https://github.com/guanghechen/sora/commit/6dc2014122dd44bcadc893e2ee98697265e7d61e))
97
+
98
+ # [1.0.0-alpha.11](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.10...@guanghechen/file-split@1.0.0-alpha.11) (2023-11-18)
99
+
100
+ **Note:** Version bump only for package @guanghechen/file-split
101
+
102
+ # [1.0.0-alpha.10](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.9...@guanghechen/file-split@1.0.0-alpha.10) (2023-11-18)
103
+
104
+ **Note:** Version bump only for package @guanghechen/file-split
105
+
106
+ # [1.0.0-alpha.9](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.8...@guanghechen/file-split@1.0.0-alpha.9) (2023-11-18)
107
+
108
+ ### Performance Improvements
109
+
110
+ - 🔧 upgrade engine version requirement from '>= 16.0.0' to '>= 18.0.0'
111
+ ([ddb9521](https://github.com/guanghechen/sora/commit/ddb9521b529b2ca838554794339b9e27ac80b8aa))
112
+
113
+ # [1.0.0-alpha.8](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.7...@guanghechen/file-split@1.0.0-alpha.8) (2023-11-07)
114
+
115
+ **Note:** Version bump only for package @guanghechen/file-split
116
+
117
+ # [1.0.0-alpha.7](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.6...@guanghechen/file-split@1.0.0-alpha.7) (2023-10-26)
118
+
119
+ **Note:** Version bump only for package @guanghechen/file-split
120
+
121
+ # [1.0.0-alpha.6](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.5...@guanghechen/file-split@1.0.0-alpha.6) (2023-10-25)
122
+
123
+ **Note:** Version bump only for package @guanghechen/file-split
124
+
125
+ # [1.0.0-alpha.5](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.4...@guanghechen/file-split@1.0.0-alpha.5) (2023-10-22)
126
+
127
+ ### Performance Improvements
128
+
129
+ - 🎨 prefer Uint8Array instead of Buffer
130
+ ([0789b58](https://github.com/guanghechen/sora/commit/0789b58deb7c8d0f6fc8d2ae1eb0cf2b71390552))
131
+
132
+ # [1.0.0-alpha.4](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.3...@guanghechen/file-split@1.0.0-alpha.4) (2023-10-16)
133
+
134
+ ### Performance Improvements
135
+
136
+ - 🔧 remove unnecessary devDependencies
137
+ ([944f3ae](https://github.com/guanghechen/sora/commit/944f3aee64e68ce52ca30237c7d0240a82c9c58f))
138
+
139
+ # [1.0.0-alpha.3](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.2...@guanghechen/file-split@1.0.0-alpha.3) (2023-10-10)
140
+
141
+ **Note:** Version bump only for package @guanghechen/file-split
142
+
143
+ # [1.0.0-alpha.2](https://github.com/guanghechen/sora/compare/@guanghechen/file-split@1.0.0-alpha.1...@guanghechen/file-split@1.0.0-alpha.2) (2023-10-09)
144
+
145
+ ### Performance Improvements
146
+
147
+ - 🎨 make codes tidy
148
+ ([3ca94af](https://github.com/guanghechen/sora/commit/3ca94af8bb8c3ef1a9bf2995a9f2dd9e4081b6d3))
149
+
150
+ # 1.0.0-alpha.1 (2023-10-04)
151
+
152
+ ### Features
153
+
154
+ - ✨ add @guagnhechen/file-split (migrate from @guanghechen/helper-file)
155
+ ([56ef3f1](https://github.com/guanghechen/sora/commit/56ef3f163dd6ae2e40d93ea78aacecc80886220f))
156
+
157
+ ### Performance Improvements
158
+
159
+ - 🎨 move @guagnhechen/invariant to @guanghechen/internal
160
+ ([e8341be](https://github.com/guanghechen/sora/commit/e8341be562e92d08142187d59dad099ac2e4a4e4))
161
+ - ⬆️ the version of subpackage devDependencies is not matter
162
+ ([3287c22](https://github.com/guanghechen/sora/commit/3287c22fb150af6620c1c9f6f4b186498aea815b))
163
+
164
+ ## [5.0.7](https://github.com/guanghechen/node-scaffolds/compare/@guanghechen/helper-file@5.0.6...@guanghechen/helper-file@5.0.7) (2023-09-07)
165
+
166
+ ### Performance Improvements
167
+
168
+ - ⬆️ upgrade dependencies
169
+ ([83e3f3e](https://github.com/guanghechen/node-scaffolds/commit/83e3f3eaf4c3a354e2ddf167fa1a4bb75e750427))
170
+
171
+ ## [5.0.6](https://github.com/guanghechen/node-scaffolds/compare/@guanghechen/helper-file@5.0.5...@guanghechen/helper-file@5.0.6) (2023-08-27)
172
+
173
+ ### Performance Improvements
174
+
175
+ - ⬆️ upgrade dependencies
176
+ ([8fa97de](https://github.com/guanghechen/node-scaffolds/commit/8fa97dee952f55565a2ac9b6680256c406df72ab))
177
+
178
+ ## [5.0.5](https://github.com/guanghechen/node-scaffolds/compare/@guanghechen/helper-file@5.0.4...@guanghechen/helper-file@5.0.5) (2023-08-19)
179
+
180
+ ### Performance Improvements
181
+
182
+ - ⬆️ upgrade dependencies
183
+ ([2c25097](https://github.com/guanghechen/node-scaffolds/commit/2c25097d9733f3e17d9725fede8dc960073099fe))
184
+
185
+ ## [5.0.4](https://github.com/guanghechen/node-scaffolds/compare/@guanghechen/helper-file@5.0.3...@guanghechen/helper-file@5.0.4) (2023-08-08)
186
+
187
+ ### Performance Improvements
188
+
189
+ - ⬆️ upgrade dependencies
190
+ ([bbc1ae6](https://github.com/guanghechen/node-scaffolds/commit/bbc1ae6b40aa4030f4103035f062dd4040a35b08))
191
+
192
+ ## [5.0.3](https://github.com/guanghechen/node-scaffolds/compare/@guanghechen/helper-file@5.0.2...@guanghechen/helper-file@5.0.3) (2023-07-25)
193
+
194
+ ### Performance Improvements
195
+
196
+ - 🔧 update npm script
197
+ ([4ffc90a](https://github.com/guanghechen/node-scaffolds/commit/4ffc90aff15c75fcc6afeeabf4d83dbc8c1b7933))
198
+ - ⬆️ upgrade dependencies
199
+ ([a9b6097](https://github.com/guanghechen/node-scaffolds/commit/a9b609785175e91903ca8215a807691ba6fbc419))
200
+
201
+ ## [5.0.2](https://github.com/guanghechen/node-scaffolds/compare/@guanghechen/helper-file@5.0.1...@guanghechen/helper-file@5.0.2) (2023-07-15)
202
+
203
+ ### Performance Improvements
204
+
205
+ - ⬆️ upgrade dependencies
206
+ ([4f0f471](https://github.com/guanghechen/node-scaffolds/commit/4f0f4712d061099ea9d5605efeb54357e4479f6a))
207
+
208
+ ## [5.0.1](https://github.com/guanghechen/node-scaffolds/compare/@guanghechen/helper-file@5.0.0...@guanghechen/helper-file@5.0.1) (2023-05-26)
209
+
210
+ ### Performance Improvements
211
+
212
+ - 🔧 update jest config to reuse tsconfig for test
213
+ ([54883f0](https://github.com/guanghechen/node-scaffolds/commit/54883f032cbba78af4609d6d4fb2b5e1ac68b518))
214
+
215
+ # 5.0.0 (2023-05-13)
216
+
217
+ ### Performance Improvements
218
+
219
+ - 📝 remove all CHANGELOG in repo
220
+ ([40909ed](https://github.com/guanghechen/node-scaffolds/commit/40909ed439632e0c4b0cd817614e24fdeac2fa23))
221
+
222
+ # 5.0.0-alpha.3 (2023-05-07)
223
+
224
+ ### Performance Improvements
225
+
226
+ - :bookmark: release
227
+ ([b5a3423](https://github.com/guanghechen/node-scaffolds/commit/b5a3423a3dd338d13ac4247c2651f4693f9fe363))
228
+ - ⬆️ upgrade devDependencies
229
+ ([30a9c27](https://github.com/guanghechen/node-scaffolds/commit/30a9c27c22b8debcf8dd5b2652ec335458caf31c))
230
+
231
+ # 5.0.0-alpha.2 (2023-05-01)
232
+
233
+ ### Performance Improvements
234
+
235
+ - 🔖 publish v5.0.0-alpha.2
236
+ ([708dd6d](https://github.com/guanghechen/node-scaffolds/commit/708dd6d721059e902c375e628c939b28664f3058))
237
+ - ⬆️ upgrade dependencies
238
+ ([d7f49fe](https://github.com/guanghechen/node-scaffolds/commit/d7f49fe9a0cedfbb2a7584da196a1bcc7b78bacd))
239
+
240
+ # 5.0.0-alpha.1 (2023-04-09)
241
+
242
+ ### Performance Improvements
243
+
244
+ - 🔖 publish v5.0.0-alpha.1
245
+ ([45d61b7](https://github.com/guanghechen/node-scaffolds/commit/45d61b7ac2bd92cd6fbbfb5c310bd6bbb95f49f8))
246
+
247
+ # 5.0.0-alpha.0 (2023-04-02)
248
+
249
+ ### Performance Improvements
250
+
251
+ - ⬆️ don't pack src/ folder in tarball
252
+ ([69671c5](https://github.com/guanghechen/node-scaffolds/commit/69671c533e15278052bf7b99bec2d70eab141393))
253
+ - 🔖 publish v5.0.0-alpha.0
254
+ ([cf3e9a2](https://github.com/guanghechen/node-scaffolds/commit/cf3e9a2293c95fe113aa3515409276d5c50a794d))
255
+ - 📝 update links for release-5.x.x
256
+ ([672ea87](https://github.com/guanghechen/node-scaffolds/commit/672ea87c86f2eca1adfd136e74a4a4f7c58592a2))
257
+
258
+ ## 4.7.4 (2023-03-26)
259
+
260
+ ### Performance Improvements
261
+
262
+ - 🔖 publish v4.7.4
263
+ ([c30d5c4](https://github.com/guanghechen/node-scaffolds/commit/c30d5c42d2b5671118ab0261390e17ae45d279c6))
264
+ - ⬆️ upgrade devDependencies
265
+ ([8bfcfc5](https://github.com/guanghechen/node-scaffolds/commit/8bfcfc5931cb388a7e93c17b417507f0ce964bb5))
266
+
267
+ ## 4.7.3 (2023-03-25)
268
+
269
+ ### Performance Improvements
270
+
271
+ - 🔖 publish v4.7.3
272
+ ([5c5cb47](https://github.com/guanghechen/node-scaffolds/commit/5c5cb4750d7d4e455e0b39565c0a304f736a3251))
273
+ - 🎨 update options
274
+ ([2c75565](https://github.com/guanghechen/node-scaffolds/commit/2c75565e3d59b19fde37cb7c4f0eea677859fedb))
275
+
276
+ ## 4.7.2 (2023-03-23)
277
+
278
+ ### Performance Improvements
279
+
280
+ - 🔖 publish v4.7.2
281
+ ([e628cc9](https://github.com/guanghechen/node-scaffolds/commit/e628cc99eb2dcd8665bbac124ec587824382c698))
282
+ - ⬆️ upgrade devDependencies
283
+ ([2be4555](https://github.com/guanghechen/node-scaffolds/commit/2be4555e58cc40bd290faa66f160751be3e22bee))
284
+
285
+ ## 4.7.1 (2023-03-19)
286
+
287
+ ### Performance Improvements
288
+
289
+ - 🔖 publish v4.7.1
290
+ ([1349c5c](https://github.com/guanghechen/node-scaffolds/commit/1349c5cf88890817b259b579449884bafb598d86))
291
+ - ⬆️ upgrade devDependencies
292
+ ([ce172dd](https://github.com/guanghechen/node-scaffolds/commit/ce172ddfc3899902475fa14795e70f261ed35b37))
293
+
294
+ # 4.7.0 (2023-03-12)
295
+
296
+ ### Performance Improvements
297
+
298
+ - 🔖 publish v4.7.0
299
+ ([0641367](https://github.com/guanghechen/node-scaffolds/commit/06413670b283538876023c66d0f2afa45074b016))
300
+
301
+ ## 4.6.5 (2023-03-12)
302
+
303
+ ### Performance Improvements
304
+
305
+ - 🔖 publish v4.6.5
306
+ ([83a48e7](https://github.com/guanghechen/node-scaffolds/commit/83a48e74ac5875200e8c30c332ffc1a4ff57e79f))
307
+
308
+ ## 4.6.4 (2023-03-12)
309
+
310
+ ### Performance Improvements
311
+
312
+ - 🔖 publish v4.6.4
313
+ ([1ad9150](https://github.com/guanghechen/node-scaffolds/commit/1ad9150445f9c7d03153f81f54bf0815b7510f50))
314
+
315
+ ## 4.6.3 (2023-03-11)
316
+
317
+ ### Performance Improvements
318
+
319
+ - 🔖 publish v4.6.3
320
+ ([16683dd](https://github.com/guanghechen/node-scaffolds/commit/16683dd3e64ea492c1b49d0dea7e81b98ea9d71c))
321
+
322
+ ## 4.6.2 (2023-03-10)
323
+
324
+ ### Performance Improvements
325
+
326
+ - 🔖 publish v4.6.2
327
+ ([3547f1c](https://github.com/guanghechen/node-scaffolds/commit/3547f1ca30871d8065c3c075d360d23df3fe84f2))
328
+ - ⬆️ upgrade devDependencies
329
+ ([5f4cfd5](https://github.com/guanghechen/node-scaffolds/commit/5f4cfd5c9d5b8f371d54d9a4c2a3882f7498b882))
330
+
331
+ ## 4.6.1 (2023-03-05)
332
+
333
+ ### Performance Improvements
334
+
335
+ - 🔖 publish v4.6.1
336
+ ([2d88cf7](https://github.com/guanghechen/node-scaffolds/commit/2d88cf7835c017183a5fd097ebf2a7c7fe622692))
337
+ - ⬆️ upgrade devDependencies
338
+ ([b358df3](https://github.com/guanghechen/node-scaffolds/commit/b358df3c4da109260dbd4ab43e72f80ffdf3cecd))
339
+
340
+ # 4.6.0 (2023-02-28)
341
+
342
+ ### Performance Improvements
343
+
344
+ - 🔖 publish v4.6.0
345
+ ([d45f55f](https://github.com/guanghechen/node-scaffolds/commit/d45f55f4cd4d8214beb0724a45de4f36baa431c1))
346
+
347
+ # 4.5.0 (2023-02-27)
348
+
349
+ ### Performance Improvements
350
+
351
+ - 🔖 publish v4.5.0
352
+ ([a361eb1](https://github.com/guanghechen/node-scaffolds/commit/a361eb1b21a9fa55e7da7c44584dfc4f04c0af36))
353
+
354
+ ## 4.4.3 (2023-02-27)
355
+
356
+ ### Performance Improvements
357
+
358
+ - 🔖 publish v4.4.3
359
+ ([29113fb](https://github.com/guanghechen/node-scaffolds/commit/29113fb651d40ec8144059875e2dd36b103e25b8))
360
+
361
+ ## 4.4.2 (2023-02-26)
362
+
363
+ ### Performance Improvements
364
+
365
+ - 🔖 publish v4.4.2
366
+ ([e864740](https://github.com/guanghechen/node-scaffolds/commit/e8647409675f14054b6ba4eee770377e3d68ec1e))
367
+
368
+ ## 4.4.1 (2023-02-25)
369
+
370
+ ### Performance Improvements
371
+
372
+ - 🔖 publish v4.4.1
373
+ ([332c5ff](https://github.com/guanghechen/node-scaffolds/commit/332c5ff77ef74b08a5349e80c64cc35a7ea1bbed))
374
+
375
+ # 4.4.0 (2023-02-25)
376
+
377
+ ### Performance Improvements
378
+
379
+ - 🔖 publish v4.4.0
380
+ ([c54cc52](https://github.com/guanghechen/node-scaffolds/commit/c54cc52236ed01f80b310cb8c0a07fe0beb42755))
381
+ - ⬆️ upgrade devDependencies
382
+ ([3a4d2de](https://github.com/guanghechen/node-scaffolds/commit/3a4d2def1cc59fdabe58888da7970da348de538a))
383
+
384
+ # 4.3.0 (2023-02-21)
385
+
386
+ ### Performance Improvements
387
+
388
+ - 🔖 publish v4.3.0
389
+ ([501a8df](https://github.com/guanghechen/node-scaffolds/commit/501a8dfb2cf7ff8302af41cf24acf99ca5c254c8))
390
+
391
+ ## 4.2.2 (2023-02-20)
392
+
393
+ ### Performance Improvements
394
+
395
+ - 🔖 publish v4.2.2
396
+ ([bf0f251](https://github.com/guanghechen/node-scaffolds/commit/bf0f251214e1eac2056911e2ad7895dfa19959d7))
397
+
398
+ ## 4.2.1 (2023-02-20)
399
+
400
+ ### Performance Improvements
401
+
402
+ - 🔖 publish v4.2.1
403
+ ([6a117ec](https://github.com/guanghechen/node-scaffolds/commit/6a117ece78cfaeff8d7d14da548e07d20a2816a7))
404
+
405
+ # 4.2.0 (2023-02-19)
406
+
407
+ ### Performance Improvements
408
+
409
+ - 🔖 publish v4.2.0
410
+ ([ee9c6e2](https://github.com/guanghechen/node-scaffolds/commit/ee9c6e246278aa1bd6a2f5802891b4b41f5fbb6f))
411
+
412
+ ## 4.1.3 (2023-02-18)
413
+
414
+ ### Performance Improvements
415
+
416
+ - 🔖 publish v4.1.3
417
+ ([89ce0d8](https://github.com/guanghechen/node-scaffolds/commit/89ce0d84e973cc87444db249ea6a6eeb6572a524))
418
+
419
+ ## 4.1.2 (2023-02-18)
420
+
421
+ ### Performance Improvements
422
+
423
+ - 🔖 publish v4.1.2
424
+ ([ff461e9](https://github.com/guanghechen/node-scaffolds/commit/ff461e94432c8baa395c4d82af81f53448ff5084))
425
+
426
+ ## 4.1.1 (2023-02-18)
427
+
428
+ ### Performance Improvements
429
+
430
+ - 🔖 publish v4.1.1
431
+ ([01f6698](https://github.com/guanghechen/node-scaffolds/commit/01f6698a7456bddbfe1c62df41d500e83a68de0d))
432
+ - 🔧 remove unnecessary devDependencies
433
+ ([f717518](https://github.com/guanghechen/node-scaffolds/commit/f71751803558970cccde05f96bff63436db8e2aa))
434
+ - ⬆️ upgrade devDependencies
435
+ ([e46df0d](https://github.com/guanghechen/node-scaffolds/commit/e46df0def851adee643918b6626f1f867eb729e4))
436
+
437
+ # 4.1.0 (2023-02-18)
438
+
439
+ ### Performance Improvements
440
+
441
+ - 🔖 publish v4.1.0
442
+ ([a2eb1f3](https://github.com/guanghechen/node-scaffolds/commit/a2eb1f37d4646e3e612f3b407a6cf078daf436a6))
443
+
444
+ # 4.0.0 (2023-02-13)
445
+
446
+ ### Performance Improvements
447
+
448
+ - 🔖 publish v4.0.0
449
+ ([a635369](https://github.com/guanghechen/node-scaffolds/commit/a63536936a3d9886579f405da75606be0dc2bb81))
450
+
451
+ # 4.0.0-alpha.8 (2023-02-12)
452
+
453
+ ### Performance Improvements
454
+
455
+ - 🔖 publish v4.0.0-alpha.8
456
+ ([07368f1](https://github.com/guanghechen/node-scaffolds/commit/07368f180b4184a9a1a56a7b4699d11c02375fa9))
457
+
458
+ # 4.0.0-alpha.7 (2023-02-12)
459
+
460
+ ### Performance Improvements
461
+
462
+ - 🔖 publish v4.0.0-alpha.7
463
+ ([c93c32c](https://github.com/guanghechen/node-scaffolds/commit/c93c32cdebd9525f5db4e9219eb2fb6d750bffea))
464
+ - 🔧 upgrade devDependencies
465
+ ([320adbe](https://github.com/guanghechen/node-scaffolds/commit/320adbe4fdd15f859933c1eb913518e687942004))
466
+
467
+ # 4.0.0-alpha.6 (2023-02-08)
468
+
469
+ ### Performance Improvements
470
+
471
+ - 🔖 publish v4.0.0-alpha.6
472
+ ([a9e5548](https://github.com/guanghechen/node-scaffolds/commit/a9e55488e45affeedc069037e18743c1856b208b))
473
+
474
+ # 4.0.0-alpha.5 (2023-02-05)
475
+
476
+ ### Performance Improvements
477
+
478
+ - 🔖 publish v4.0.0-alpha.5
479
+ ([df74a71](https://github.com/guanghechen/node-scaffolds/commit/df74a71a3ac9afa7a54e423e691e5bbf7122deeb))
480
+
481
+ # 4.0.0-alpha.4 (2023-02-04)
482
+
483
+ ### Performance Improvements
484
+
485
+ - 🔖 publish v4.0.0-alpha.4
486
+ ([bbbbb92](https://github.com/guanghechen/node-scaffolds/commit/bbbbb92773cd18e39a848bc1a3e54e0d80388c23))
487
+
488
+ # 4.0.0-alpha.3 (2023-02-04)
489
+
490
+ ### Performance Improvements
491
+
492
+ - 🔖 publish v4.0.0-alpha.3
493
+ ([1f3b9e1](https://github.com/guanghechen/node-scaffolds/commit/1f3b9e198486a47e8d400f89e581985e03b57ded))
494
+
495
+ # 4.0.0-alpha.2 (2023-02-04)
496
+
497
+ ### Performance Improvements
498
+
499
+ - 🔖 publish v4.0.0-alpha.2
500
+ ([42930f9](https://github.com/guanghechen/node-scaffolds/commit/42930f930e2f81eb227fd61dd8af9c9afd40528f))
501
+
502
+ # 4.0.0-alpha.1 (2023-02-04)
503
+
504
+ ### Performance Improvements
505
+
506
+ - 🔖 publish v4.0.0-alpha.1
507
+ ([66bd5c7](https://github.com/guanghechen/node-scaffolds/commit/66bd5c7f0ee9b32f269cc366c33575fcef01fa97))
508
+ - ⬆️ upgrade devDependencies
509
+ ([75c3da9](https://github.com/guanghechen/node-scaffolds/commit/75c3da99c657543aaa9a8c1517766f0044898b22))
510
+
511
+ # 4.0.0-alpha.0 (2023-02-04)
512
+
513
+ ### Bug Fixes
514
+
515
+ - 🐛 should always use `undefined` encoding to get raw buffer instead of any pretreated data
516
+ ([53ba810](https://github.com/guanghechen/node-scaffolds/commit/53ba81011213f0955444477d7e4683be6452b961))
517
+
518
+ ### Features
519
+
520
+ - ✨ implement @guanghechen/helper-cipher-file (abstract from helper-cipher)
521
+ ([a661a46](https://github.com/guanghechen/node-scaffolds/commit/a661a46e94ab6942b3283fefce97404c52837861))
522
+
523
+ ### Performance Improvements
524
+
525
+ - [BREAKING] improve: prefer fileSize instead of a filepath in calcFilePartItemsBySize and
526
+ calcFilePartItemsByCount
527
+ ([9412c29](https://github.com/guanghechen/node-scaffolds/commit/9412c2951f475cb7f26913d6570e04d504879034))
528
+ - :sparkles: [BREAKING] feat: implement @guanghechen/helper-fs & move some methods from
529
+ @guanghechen/helper-file and @guanghechen/helper-path to it
530
+ ([51e1a57](https://github.com/guanghechen/node-scaffolds/commit/51e1a57838940bfba81d9c7b2b4c316b209c5d10))
531
+ - 🎨 extract calcFilePartNames from BigFileHelper
532
+ ([f8758b3](https://github.com/guanghechen/node-scaffolds/commit/f8758b3de0042932cf82142ed4b2d17fda194a91))
533
+ - 🎨 narrow types
534
+ ([36dd01b](https://github.com/guanghechen/node-scaffolds/commit/36dd01bf91628d46c67b55c4cbd489ba0ac2aafb))
535
+ - ✅ refactor tests
536
+ ([2d4a7e0](https://github.com/guanghechen/node-scaffolds/commit/2d4a7e0b71a8565f86bbe65ca4bb4cf5e3e4c08f))
537
+ - 🔖 publish v4.0.0-alpha.0
538
+ ([2e04d90](https://github.com/guanghechen/node-scaffolds/commit/2e04d90202c630a1bbef60440b9504c993bb37fb))
539
+ - 📝 update doc url
540
+ ([c99c7f8](https://github.com/guanghechen/node-scaffolds/commit/c99c7f8849dc96e800d0fd166ac8fe748b1356f0))
541
+ - ✅ update tests
542
+ ([c1866e1](https://github.com/guanghechen/node-scaffolds/commit/c1866e1ea03bb0923eadcd5eb8d4329a9721b613))
543
+ - ✅ update tests
544
+ ([d06290d](https://github.com/guanghechen/node-scaffolds/commit/d06290dafb3a71341de17abfb92f0d0189a1cdf1))
545
+ - ⬆️ upgrade dependencies
546
+ ([f72ecb0](https://github.com/guanghechen/node-scaffolds/commit/f72ecb02a5c74f791c465aefacf11fe24e2fa1e2))
547
+ - ⬆️ upgrade devDependencies
548
+ ([325e12d](https://github.com/guanghechen/node-scaffolds/commit/325e12d78a76d205ad82a1c8a6758a34df404c34))
549
+ - ⬆️ upgrade devDependencies
550
+ ([5abb430](https://github.com/guanghechen/node-scaffolds/commit/5abb430a3b59da5ab02c2b55cc30cc46e6a627b5))
551
+
552
+ ## 3.0.2 (2023-01-14)
553
+
554
+ ### Performance Improvements
555
+
556
+ - 🔖 publish v3.0.2
557
+ ([6837f48](https://github.com/guanghechen/node-scaffolds/commit/6837f483f60ac736a14941616f36600043b0b992))
558
+
559
+ ## 3.0.1 (2023-01-14)
560
+
561
+ ### Performance Improvements
562
+
563
+ - 🔖 publish v3.0.1
564
+ ([d10a768](https://github.com/guanghechen/node-scaffolds/commit/d10a768cddab80934dcd6c0fc6316383e8f44a52))
565
+ - ⬆️ upgrade devDependencies
566
+ ([2993a46](https://github.com/guanghechen/node-scaffolds/commit/2993a46e3665c7cfb23858f44812498cb2f39573))
567
+
568
+ # 3.0.0 (2023-01-09)
569
+
570
+ ### Performance Improvements
571
+
572
+ - 🔖 publish v3.0.0
573
+ ([a8cbe2a](https://github.com/guanghechen/node-scaffolds/commit/a8cbe2af542ccc3e112c9ee7cf564a496312a1e2))
574
+
575
+ # 3.0.0-alpha.5 (2023-01-05)
576
+
577
+ ### Performance Improvements
578
+
579
+ - :bug: fix jest-config within esm
580
+ ([4050e62](https://github.com/guanghechen/node-scaffolds/commit/4050e629536ae003c99ef9eeafa59c8aa8e1f0b3))
581
+ - 🔖 publish v3.0.0-alpha.5
582
+ ([ff359c7](https://github.com/guanghechen/node-scaffolds/commit/ff359c7d9fcd48603b88b87698d825992ff55886))
583
+
584
+ # 3.0.0-alpha.4 (2023-01-04)
585
+
586
+ ### Performance Improvements
587
+
588
+ - :wrench: fix commonjs entry
589
+ ([259e185](https://github.com/guanghechen/node-scaffolds/commit/259e185ee811cebc4cf9b41d8c27c937460ef6d4))
590
+ - 🔖 publish v3.0.0-alpha.4
591
+ ([ac69bef](https://github.com/guanghechen/node-scaffolds/commit/ac69bef736b78ddb90fd6830371118dcadaececa))
592
+
593
+ # 3.0.0-alpha.3 (2023-01-04)
594
+
595
+ ### Performance Improvements
596
+
597
+ - 🔖 publish v3.0.0-alpha.3
598
+ ([d05d30a](https://github.com/guanghechen/node-scaffolds/commit/d05d30a9812564cd3e19835bf1b6462df64fdda4))
599
+ - 🔧 support dual esm/commonjs packages
600
+ ([90363f5](https://github.com/guanghechen/node-scaffolds/commit/90363f585471b527063133dedb1dff50d8b2a890))
601
+
602
+ # 3.0.0-alpha.2 (2023-01-02)
603
+
604
+ ### Performance Improvements
605
+
606
+ - :wrench: [BREAKING] chore: support ESM only
607
+ ([29b8c42](https://github.com/guanghechen/node-scaffolds/commit/29b8c421c0a2dfdd04cf4d7ff3ef0e5a93d70e16))
608
+ - 🔖 publish v3.0.0-alpha.2
609
+ ([76c56b7](https://github.com/guanghechen/node-scaffolds/commit/76c56b76cb6b1fb368d47a8c20d2c06398f0009b))
610
+
611
+ # 3.0.0-alpha.1 (2023-01-02)
612
+
613
+ ### Performance Improvements
614
+
615
+ - 🔖 publish v3.0.0-alpha.1
616
+ ([69dd141](https://github.com/guanghechen/node-scaffolds/commit/69dd141feb9fae875cf252ac6f6404542425a147))
617
+
618
+ # 3.0.0-alpha.0 (2022-12-31)
619
+
620
+ ### Performance Improvements
621
+
622
+ - 🔧 fix build scripts
623
+ ([b24918c](https://github.com/guanghechen/node-scaffolds/commit/b24918c278188a043f7aabfc30739fa97d5ad060))
624
+ - 🔧 fix test
625
+ ([6f911d4](https://github.com/guanghechen/node-scaffolds/commit/6f911d421240af2f17e6283bc4cbd53a32ac3bdc))
626
+ - 🔖 publish v3.0.0-alpha.0
627
+ ([cf4b41a](https://github.com/guanghechen/node-scaffolds/commit/cf4b41a4fbd48d5ef5237b6827ddef1fe9484576))
628
+ - 📝 update link for v3.x.x
629
+ ([f39886b](https://github.com/guanghechen/node-scaffolds/commit/f39886b5568ad9ba3d9e09bc56947725c363c5f3))
630
+
631
+ ## 2.1.4 (2022-11-03)
632
+
633
+ ### Performance Improvements
634
+
635
+ - 🔖 publish v2.1.4
636
+ ([8eedd0e](https://github.com/guanghechen/node-scaffolds/commit/8eedd0e65701ed9c63e7b5682dfbd96545136c0f))
637
+
638
+ ## 2.1.3 (2022-11-03)
639
+
640
+ ### Performance Improvements
641
+
642
+ - 🔖 publish v2.1.3
643
+ ([79de5ac](https://github.com/guanghechen/node-scaffolds/commit/79de5ac90778283d4405357b50a2d291eecf4040))
644
+
645
+ ## 2.1.2 (2022-10-20)
646
+
647
+ ### Performance Improvements
648
+
649
+ - 🔖 publish v2.1.2
650
+ ([1815a70](https://github.com/guanghechen/node-scaffolds/commit/1815a70b6f81b50d08b3de21692c51c32aeb4d10))
651
+
652
+ ## 2.1.1 (2022-10-13)
653
+
654
+ ### Performance Improvements
655
+
656
+ - 🔖 publish v2.1.1
657
+ ([717d5f1](https://github.com/guanghechen/node-scaffolds/commit/717d5f12e96e7cf93340c75eb100356220e5e9ca))
658
+
659
+ # 2.1.0 (2022-09-18)
660
+
661
+ ### Performance Improvements
662
+
663
+ - 🔖 publish v2.1.0
664
+ ([43dcadd](https://github.com/guanghechen/node-scaffolds/commit/43dcadd72fe3ce0c0aa040c0b810e286769a9a24))
665
+ - ⬆️ ugprade jest to v29.x.x & update jest-config
666
+ ([d54145c](https://github.com/guanghechen/node-scaffolds/commit/d54145ce1e8b59780828a259ed6ddca6aa6e6b5f))
667
+
668
+ # 2.0.0 (2022-09-17)
669
+
670
+ ### Performance Improvements
671
+
672
+ - ✅ fix test
673
+ ([4a39ef8](https://github.com/guanghechen/node-scaffolds/commit/4a39ef83035ce3a65fdd5bc36f5f57869fef456d))
674
+ - 🔖 publish v2.0.0
675
+ ([543c55f](https://github.com/guanghechen/node-scaffolds/commit/543c55f065895fef8fc2d3865cf6a4b72091355a))
676
+ - 🔧 support node >= 16
677
+ ([208522b](https://github.com/guanghechen/node-scaffolds/commit/208522b6a7f8eba53a2562595706b25d63e91c29))
678
+ - 📝 update READMEs
679
+ ([d6743d2](https://github.com/guanghechen/node-scaffolds/commit/d6743d24c94ea6c7a24ff4a2dc48113a2c2f96ce))
680
+
681
+ # 2.0.0-alpha.3 (2022-09-15)
682
+
683
+ ### Performance Improvements
684
+
685
+ - :truck: move some filepath relative methods from @algorithm.ts/helper-file to
686
+ @algorithm/helper-path
687
+ ([1da75c9](https://github.com/guanghechen/node-scaffolds/commit/1da75c9901b828d7b477b8c24f5dda483d3c1e3e))
688
+ - 🔖 publish v2.0.0-alpha.3
689
+ ([3214b8d](https://github.com/guanghechen/node-scaffolds/commit/3214b8d4b812707ccf1358d0f0fe1dc5c462a343))
690
+
691
+ # 2.0.0-alpha.2 (2022-08-27)
692
+
693
+ ### Performance Improvements
694
+
695
+ - 🔖 publish v2.0.0-alpha.2
696
+ ([2d52783](https://github.com/guanghechen/node-scaffolds/commit/2d5278386a2d9503cb5c88d237d3a2dd34488446))
697
+ - 🔧 update build configs
698
+ ([1770796](https://github.com/guanghechen/node-scaffolds/commit/177079603d8884e550cbc015f691f13939da056e))
699
+
700
+ # 2.0.0-alpha.1 (2022-08-13)
701
+
702
+ ### Performance Improvements
703
+
704
+ - 🔖 publish v2.0.0-alpha.1
705
+ ([55e1c7c](https://github.com/guanghechen/node-scaffolds/commit/55e1c7c75cf158298376c0a6dcd903cc6686a423))
706
+
707
+ # 2.0.0-alpha.0 (2022-08-05)
708
+
709
+ ### Features
710
+
711
+ - ✨ abstract stream utilities to @guanghechen/helper-stream
712
+ ([921396f](https://github.com/guanghechen/node-scaffolds/commit/921396fa5e922d3c308d04840cdbf5d5c5b2b700))
713
+
714
+ ### Performance Improvements
715
+
716
+ - 🔧 modify build script
717
+ ([4234bc0](https://github.com/guanghechen/node-scaffolds/commit/4234bc058bd9ade25778cb43ee5db939d8e630a9))
718
+ - 🔖 publish v2.0.0-alpha.0
719
+ ([fe24ebd](https://github.com/guanghechen/node-scaffolds/commit/fe24ebdb066667fadbea415d33f564f9823b51d9))
720
+ - 💥 refactor @guanghechen/chalk-logger
721
+ ([7d8c62a](https://github.com/guanghechen/node-scaffolds/commit/7d8c62a2efe6f1c907be0a75b74913da98fac27c))
722
+ - 💥 rename @guanghechen/commander-helper to @guanghechen/helper-commander
723
+ ([9f42244](https://github.com/guanghechen/node-scaffolds/commit/9f422444af5087d539a0f733b96bd64ad03198e7))
724
+ - 💥 rename @guanghechen/jest-helper to @guanghechen/helper-jest
725
+ ([8545bc2](https://github.com/guanghechen/node-scaffolds/commit/8545bc27992418b69a78106d1ba3d65c31486314))
726
+ - 💥 rename @guanghehcen/file-helper to @guanghechen/helper-file
727
+ ([2859ff4](https://github.com/guanghechen/node-scaffolds/commit/2859ff4ebf307188d6bf59b0fcb6c1d52f785a28))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present guanghechen (https://github.com/guanghechen)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,145 @@
1
+ <header>
2
+ <h1 align="center">
3
+ <a href="https://github.com/guanghechen/sora/tree/@guanghechen/filesplit@2.0.0/packages/filesplit#readme">@guanghechen/filesplit</a>
4
+ </h1>
5
+ <div align="center">
6
+ <a href="https://www.npmjs.com/package/@guanghechen/filesplit">
7
+ <img
8
+ alt="Npm Version"
9
+ src="https://img.shields.io/npm/v/@guanghechen/filesplit.svg"
10
+ />
11
+ </a>
12
+ <a href="https://www.npmjs.com/package/@guanghechen/filesplit">
13
+ <img
14
+ alt="Npm Download"
15
+ src="https://img.shields.io/npm/dm/@guanghechen/filesplit.svg"
16
+ />
17
+ </a>
18
+ <a href="https://www.npmjs.com/package/@guanghechen/filesplit">
19
+ <img
20
+ alt="Npm License"
21
+ src="https://img.shields.io/npm/l/@guanghechen/filesplit.svg"
22
+ />
23
+ </a>
24
+ <a href="#install">
25
+ <img
26
+ alt="Module Formats: cjs"
27
+ src="https://img.shields.io/badge/module_formats-cjs-green.svg"
28
+ />
29
+ </a>
30
+ <a href="https://github.com/nodejs/node">
31
+ <img
32
+ alt="Node.js Version"
33
+ src="https://img.shields.io/node/v/@guanghechen/filesplit"
34
+ />
35
+ </a>
36
+ <a href="https://github.com/facebook/jest">
37
+ <img
38
+ alt="Tested with Jest"
39
+ src="https://img.shields.io/badge/tested_with-jest-9c465e.svg"
40
+ />
41
+ </a>
42
+ <a href="https://github.com/prettier/prettier">
43
+ <img
44
+ alt="Code Style: prettier"
45
+ src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square"
46
+ />
47
+ </a>
48
+ </div>
49
+ </header>
50
+ <br/>
51
+
52
+ A utility class for splitting large files into smaller chunks and merging them back. Inspired by
53
+ [node-split-file](https://github.com/tomvlk/node-split-file).
54
+
55
+ ## Install
56
+
57
+ - npm
58
+
59
+ ```bash
60
+ npm install --save @guanghechen/filesplit
61
+ ```
62
+
63
+ - yarn
64
+
65
+ ```bash
66
+ yarn add @guanghechen/filesplit
67
+ ```
68
+
69
+ ## Usage
70
+
71
+ ### Split a File
72
+
73
+ ```typescript
74
+ import { FileSplitter } from '@guanghechen/filesplit'
75
+ import { calcFilePartItemsBySize } from '@guanghechen/filepart'
76
+ import fs from 'node:fs'
77
+
78
+ async function splitFile(filepath: string): Promise<string[]> {
79
+ const splitter = new FileSplitter()
80
+ const fileSize = fs.statSync(filepath).size
81
+ const parts = [...calcFilePartItemsBySize(fileSize, 1024 * 1024 * 80)] // 80MB per chunk
82
+ const partFilepaths: string[] = await splitter.split(filepath, parts)
83
+ return partFilepaths
84
+ }
85
+
86
+ // Split 'large-file.zip' into 80MB chunks
87
+ // Result: ['large-file.zip.ghc-part01', 'large-file.zip.ghc-part02', ...]
88
+ await splitFile('large-file.zip')
89
+ ```
90
+
91
+ ### Merge Files
92
+
93
+ ```typescript
94
+ import { FileSplitter } from '@guanghechen/filesplit'
95
+
96
+ const splitter = new FileSplitter()
97
+
98
+ // Merge chunks back into original file
99
+ await splitter.merge(
100
+ ['large-file.zip.ghc-part01', 'large-file.zip.ghc-part02', 'large-file.zip.ghc-part03'],
101
+ 'large-file-restored.zip'
102
+ )
103
+ ```
104
+
105
+ ### Custom Part Code Prefix
106
+
107
+ ```typescript
108
+ import { FileSplitter } from '@guanghechen/filesplit'
109
+
110
+ // Use custom suffix for part files
111
+ const splitter = new FileSplitter({ partCodePrefix: '.chunk' })
112
+
113
+ // Split will create: file.txt.chunk01, file.txt.chunk02, etc.
114
+ ```
115
+
116
+ ### Using Default Instance
117
+
118
+ ```typescript
119
+ import { fileSplitter } from '@guanghechen/filesplit'
120
+
121
+ // Use the default singleton instance
122
+ await fileSplitter.split(filepath, parts)
123
+ await fileSplitter.merge(inputFilepaths, outputFilepath)
124
+ ```
125
+
126
+ ### Calculate Part Filepaths
127
+
128
+ ```typescript
129
+ import { FileSplitter } from '@guanghechen/filesplit'
130
+ import { calcFilePartItemsByCount } from '@guanghechen/filepart'
131
+
132
+ const splitter = new FileSplitter()
133
+ const parts = [...calcFilePartItemsByCount(1000000, 3)]
134
+
135
+ // Get the expected part filepaths without actually splitting
136
+ const partFilepaths = splitter.calcPartFilepaths('/path/to/file.zip', parts)
137
+ // Result: ['/path/to/file.zip.ghc-part1', '/path/to/file.zip.ghc-part2', '/path/to/file.zip.ghc-part3']
138
+ ```
139
+
140
+ ## Reference
141
+
142
+ - [homepage][homepage]
143
+
144
+ [homepage]:
145
+ https://github.com/guanghechen/sora/tree/@guanghechen/filesplit@2.0.0/packages/filesplit#readme
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ var filepart = require('@guanghechen/filepart');
4
+ var invariant = require('@guanghechen/invariant');
5
+ var stream = require('@guanghechen/stream');
6
+ var node_fs = require('node:fs');
7
+
8
+ class FileSplitter {
9
+ partCodePrefix;
10
+ #encoding = undefined;
11
+ constructor(options = {}) {
12
+ this.partCodePrefix = options.partCodePrefix ?? filepart.DEFAULT_FILEPART_CODE_PREFIX;
13
+ }
14
+ calcPartFilepaths(filepath, parts) {
15
+ if (parts.length <= 1)
16
+ return [filepath];
17
+ const partFilepaths = [];
18
+ for (const partName of filepart.calcFilePartNames(parts, this.partCodePrefix)) {
19
+ const partFilepath = filepath + partName;
20
+ partFilepaths.push(partFilepath);
21
+ }
22
+ return partFilepaths;
23
+ }
24
+ async split(filepath, parts, outputFilepath) {
25
+ if (parts.length <= 1)
26
+ return [filepath];
27
+ const tasks = [];
28
+ const partFilepaths = this.calcPartFilepaths(outputFilepath ?? filepath, parts);
29
+ for (let i = 0; i < partFilepaths.length; ++i) {
30
+ const part = parts[i];
31
+ const partFilepath = partFilepaths[i];
32
+ const reader = node_fs.createReadStream(filepath, {
33
+ encoding: this.#encoding,
34
+ start: part.start,
35
+ end: part.end - 1,
36
+ });
37
+ const writer = node_fs.createWriteStream(partFilepath);
38
+ const task = stream.consumeStream(reader, writer);
39
+ tasks.push(task);
40
+ }
41
+ await Promise.all(tasks);
42
+ return partFilepaths;
43
+ }
44
+ async merge(inputFilepaths, outputFilepath) {
45
+ invariant.invariant(inputFilepaths.length > 0, 'Input file list is empty!');
46
+ const readers = inputFilepaths.map(filepath => node_fs.createReadStream(filepath, { encoding: this.#encoding }));
47
+ const writer = node_fs.createWriteStream(outputFilepath, {
48
+ encoding: this.#encoding,
49
+ });
50
+ await stream.consumeStreams(readers, writer);
51
+ }
52
+ }
53
+ const fileSplitter = new FileSplitter();
54
+
55
+ exports.FileSplitter = FileSplitter;
56
+ exports.fileSplitter = fileSplitter;
@@ -0,0 +1,53 @@
1
+ import { DEFAULT_FILEPART_CODE_PREFIX, calcFilePartNames } from '@guanghechen/filepart';
2
+ import { invariant } from '@guanghechen/invariant';
3
+ import { consumeStream, consumeStreams } from '@guanghechen/stream';
4
+ import { createReadStream, createWriteStream } from 'node:fs';
5
+
6
+ class FileSplitter {
7
+ partCodePrefix;
8
+ #encoding = undefined;
9
+ constructor(options = {}) {
10
+ this.partCodePrefix = options.partCodePrefix ?? DEFAULT_FILEPART_CODE_PREFIX;
11
+ }
12
+ calcPartFilepaths(filepath, parts) {
13
+ if (parts.length <= 1)
14
+ return [filepath];
15
+ const partFilepaths = [];
16
+ for (const partName of calcFilePartNames(parts, this.partCodePrefix)) {
17
+ const partFilepath = filepath + partName;
18
+ partFilepaths.push(partFilepath);
19
+ }
20
+ return partFilepaths;
21
+ }
22
+ async split(filepath, parts, outputFilepath) {
23
+ if (parts.length <= 1)
24
+ return [filepath];
25
+ const tasks = [];
26
+ const partFilepaths = this.calcPartFilepaths(outputFilepath ?? filepath, parts);
27
+ for (let i = 0; i < partFilepaths.length; ++i) {
28
+ const part = parts[i];
29
+ const partFilepath = partFilepaths[i];
30
+ const reader = createReadStream(filepath, {
31
+ encoding: this.#encoding,
32
+ start: part.start,
33
+ end: part.end - 1,
34
+ });
35
+ const writer = createWriteStream(partFilepath);
36
+ const task = consumeStream(reader, writer);
37
+ tasks.push(task);
38
+ }
39
+ await Promise.all(tasks);
40
+ return partFilepaths;
41
+ }
42
+ async merge(inputFilepaths, outputFilepath) {
43
+ invariant(inputFilepaths.length > 0, 'Input file list is empty!');
44
+ const readers = inputFilepaths.map(filepath => createReadStream(filepath, { encoding: this.#encoding }));
45
+ const writer = createWriteStream(outputFilepath, {
46
+ encoding: this.#encoding,
47
+ });
48
+ await consumeStreams(readers, writer);
49
+ }
50
+ }
51
+ const fileSplitter = new FileSplitter();
52
+
53
+ export { FileSplitter, fileSplitter };
@@ -0,0 +1,49 @@
1
+ import { IFilePartItem } from '@guanghechen/filepart';
2
+
3
+ interface IFileSplitter {
4
+ /**
5
+ * File part code prefix.
6
+ */
7
+ readonly partCodePrefix: string;
8
+ /**
9
+ * Calculate the name of parts of sourcefile respectively.
10
+ *
11
+ * @param filepath
12
+ * @param parts
13
+ * @returns
14
+ */
15
+ calcPartFilepaths(filepath: string, parts: IFilePartItem[]): string[];
16
+ /**
17
+ * Split file with part descriptions.
18
+ */
19
+ split(filepath: string, parts: IFilePartItem[], outputFilepath?: string): Promise<string[]>;
20
+ /**
21
+ * Merge files
22
+ *
23
+ * @param inputFilepaths
24
+ * @param outputFilepath
25
+ */
26
+ merge(inputFilepaths: string[], outputFilepath: string): Promise<void>;
27
+ }
28
+
29
+ interface IProps {
30
+ /**
31
+ * The suffix name of a file part.
32
+ */
33
+ readonly partCodePrefix?: string;
34
+ }
35
+ /**
36
+ * Inspired by https://github.com/tomvlk/node-split-file.
37
+ */
38
+ declare class FileSplitter implements IFileSplitter {
39
+ #private;
40
+ readonly partCodePrefix: string;
41
+ constructor(options?: IProps);
42
+ calcPartFilepaths(filepath: string, parts: IFilePartItem[]): string[];
43
+ split(filepath: string, parts: IFilePartItem[], outputFilepath?: string): Promise<string[]>;
44
+ merge(inputFilepaths: string[], outputFilepath: string): Promise<void>;
45
+ }
46
+ declare const fileSplitter: FileSplitter;
47
+
48
+ export { FileSplitter, fileSplitter };
49
+ export type { IFileSplitter };
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@guanghechen/filesplit",
3
+ "version": "2.0.1",
4
+ "description": "File helper",
5
+ "author": {
6
+ "name": "guanghechen",
7
+ "url": "https://github.com/guanghechen/"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/guanghechen/sora/tree/@guanghechen/filesplit@2.0.0",
12
+ "directory": "packages/filesplit"
13
+ },
14
+ "homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/filesplit@2.0.0/packages/filesplit#readme",
15
+ "keywords": [
16
+ "file helper",
17
+ "split file",
18
+ "merge streams"
19
+ ],
20
+ "type": "module",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./lib/types/index.d.ts",
24
+ "source": "./src/index.ts",
25
+ "import": "./lib/esm/index.mjs",
26
+ "require": "./lib/cjs/index.cjs"
27
+ }
28
+ },
29
+ "source": "./src/index.ts",
30
+ "main": "./lib/cjs/index.cjs",
31
+ "module": "./lib/esm/index.mjs",
32
+ "types": "./lib/types/index.d.ts",
33
+ "license": "MIT",
34
+ "files": [
35
+ "lib/",
36
+ "!lib/**/*.map",
37
+ "package.json",
38
+ "CHANGELOG.md",
39
+ "LICENSE",
40
+ "README.md"
41
+ ],
42
+ "dependencies": {
43
+ "@guanghechen/filepart": "^2.0.1",
44
+ "@guanghechen/invariant": "^7.0.1",
45
+ "@guanghechen/stream": "^2.0.1"
46
+ },
47
+ "scripts": {
48
+ "build": "rollup -c ../../rollup.config.mjs",
49
+ "clean": "rimraf lib",
50
+ "test": "vitest run --config ../../vitest.config.ts",
51
+ "test:coverage": "vitest run --config ../../vitest.config.ts --coverage",
52
+ "test:update": "vitest run --config ../../vitest.config.ts -u"
53
+ }
54
+ }