File tree Expand file tree Collapse file tree 3 files changed +0
-48
lines changed
Expand file tree Collapse file tree 3 files changed +0
-48
lines changed Original file line number Diff line number Diff line change @@ -259,21 +259,6 @@ hash('123456');
259259// <Buffer 7c 4a 8d 09 ca 37 62 af 61 e5 95 20 94 3d c2 64 94 f8 94 1b>
260260```
261261
262- ### HashStream()
263- ** \[ deprecated\] ** use [ ` createSha1Hash() ` ] ( #createsha1hash ) .
264-
265- Generates SHA1 hash with a transform stream.
266-
267- ``` js
268- var stream = new HashStream ();
269-
270- fs .createReadStream (' /path/to/file' )
271- .pipe (stream)
272- .on (' finish' , function (){
273- console .log (stream .read ());
274- });
275- ```
276-
277262### highlight(str, [ options] )
278263
279264Syntax highlighting for a code block.
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- const { Transform } = require ( 'stream' ) ;
43const crypto = require ( 'crypto' ) ;
54
65const ALGORITHM = 'sha1' ;
@@ -9,32 +8,10 @@ function createSha1Hash() {
98 return crypto . createHash ( ALGORITHM ) ;
109}
1110
12- /**
13- * @deprecated
14- * createHash() is stream class.
15- */
16- function HashStream ( ) {
17- Transform . call ( this ) ;
18- this . _hash = createSha1Hash ( ) ;
19- }
20-
21- require ( 'util' ) . inherits ( HashStream , Transform ) ;
22-
23- HashStream . prototype . _transform = function ( chunk , enc , callback ) {
24- this . _hash . update ( chunk ) ;
25- callback ( ) ;
26- } ;
27-
28- HashStream . prototype . _flush = function ( callback ) {
29- this . push ( this . _hash . digest ( ) ) ;
30- callback ( ) ;
31- } ;
32-
3311exports . hash = content => {
3412 const hash = createSha1Hash ( ) ;
3513 hash . update ( content ) ;
3614 return hash . digest ( ) ;
3715} ;
3816
39- exports . HashStream = HashStream ;
4017exports . createSha1Hash = createSha1Hash ;
Original file line number Diff line number Diff line change @@ -18,16 +18,6 @@ describe('hash', () => {
1818 hash . hash ( content ) . should . eql ( sha1 ( content ) ) ;
1919 } ) ;
2020
21- it ( 'HashStream' , ( ) => {
22- const content = '123456' ;
23- const stream = new hash . HashStream ( ) ;
24-
25- stream . write ( Buffer . from ( content ) ) ;
26- stream . end ( ) ;
27-
28- stream . read ( ) . should . eql ( sha1 ( content ) ) ;
29- } ) ;
30-
3121 it ( 'createSha1Hash' , ( ) => {
3222 const _sha1 = hash . createSha1Hash ( ) ;
3323 const content = '123456' ;
You can’t perform that action at this time.
0 commit comments