-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed date helper doesn't support timezone
- Loading branch information
Showing
5 changed files
with
172 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
|
||
var Stream = require('stream'); | ||
var Transform = Stream.Transform; | ||
var crypto = require('crypto'); | ||
|
||
function ShasumStream(options){ | ||
Transform.call(this, options); | ||
|
||
this._hash = crypto.createHash('sha1'); | ||
this._shasum = ''; | ||
} | ||
|
||
require('util').inherits(ShasumStream, Transform); | ||
|
||
ShasumStream.prototype._transform = function(chunk, enc, callback){ | ||
var buffer = chunk instanceof Buffer ? chunk : new Buffer(chunk, enc); | ||
|
||
this._hash.update(buffer); | ||
callback(); | ||
}; | ||
|
||
ShasumStream.prototype._flush = function(callback){ | ||
this._shasum = this._hash.digest('hex'); | ||
callback(); | ||
}; | ||
|
||
ShasumStream.prototype.getShasum = function(){ | ||
return this._shasum; | ||
}; | ||
|
||
module.exports = ShasumStream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.