split-hash 0.3.0 → 0.3.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/README.md CHANGED
@@ -40,6 +40,7 @@ for await (const hash of iter) {
40
40
  ```js
41
41
  import { SplitHashValidator } from 'split-hash/nodejs'
42
42
  import * as crypto from 'crypto'
43
+ import { pipeline } from 'stream'
43
44
 
44
45
  const KiB = 1024
45
46
 
@@ -58,11 +59,13 @@ const createHash = () => {
58
59
  const hashList = [/* ... */]
59
60
  const validator = new SplitHashValidator(hashList, 512 * KiB, createHash)
60
61
 
61
- const stream = fs.createReadStream('filename.bin')
62
- stream
63
- .pipe(validator)
64
- .on('data', /* same as stream */)
65
- .on('error', err => console.error('not matched'))
62
+ const stream = pipeline(
63
+ fs.createReadStream('filename.bin')
64
+ , validator
65
+ , err => {
66
+ // ...
67
+ }
68
+ )
66
69
  ```
67
70
 
68
71
  ## API
@@ -82,7 +85,7 @@ function splitHash<T>(
82
85
  stream: NodeJS.ReadableStream
83
86
  , blockSizeBytes: number
84
87
  , createHash: ProgressiveHashFactory<T>
85
- ): AsyncIterable<T>
88
+ ): AsyncIterableIterator<T>
86
89
  ```
87
90
 
88
91
  It throws `StreamEncodingError` when the `stream` encoding is set.
@@ -127,5 +130,5 @@ async function* splitHash<T>(
127
130
  stream: ReadableStream
128
131
  , blockSize: number
129
132
  , createHash: ProgressiveHashFactory<T>
130
- ): AsyncIterable<T>
133
+ ): AsyncIterableIterator<T>
131
134
  ```
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  import { CustomError } from '@blackglory/errors';
3
3
  import { ProgressiveHashFactory } from './types.js';
4
- export declare function splitHash<T>(stream: NodeJS.ReadableStream, blockSizeBytes: number, createHash: ProgressiveHashFactory<T>): AsyncIterable<T>;
4
+ export declare function splitHash<T>(stream: NodeJS.ReadableStream, blockSizeBytes: number, createHash: ProgressiveHashFactory<T>): AsyncIterableIterator<T>;
5
5
  export declare class StreamEncodingError extends CustomError {
6
6
  constructor();
7
7
  }
@@ -1,2 +1,2 @@
1
1
  import { ProgressiveHashFactory } from './types.js';
2
- export declare function splitHash<T>(stream: ReadableStream, blockSizeBytes: number, createHash: ProgressiveHashFactory<T>): AsyncIterable<T>;
2
+ export declare function splitHash<T>(stream: ReadableStream, blockSizeBytes: number, createHash: ProgressiveHashFactory<T>): AsyncIterableIterator<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "split-hash",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Split the stream based on bytes and get digests from each part.",
5
5
  "keywords": [
6
6
  "split",
@@ -51,10 +51,10 @@
51
51
  "@typescript-eslint/parser": "^5.56.0",
52
52
  "cross-env": "^7.0.3",
53
53
  "eslint": "^8.36.0",
54
- "extra-abort": "^0.3.3",
54
+ "extra-abort": "^0.3.4",
55
55
  "extra-promise": "^6.0.5",
56
56
  "husky": "^4.3.0",
57
- "iterable-operator": "^4.0.3",
57
+ "iterable-operator": "^4.0.5",
58
58
  "npm-run-all": "^4.1.5",
59
59
  "return-style": "^3.0.0",
60
60
  "rimraf": "^3.0.2",