push all website files

This commit is contained in:
Jacob Levine
2019-01-06 13:14:45 -06:00
parent d7301e26c3
commit d2d5d4c04e
15662 changed files with 2166516 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
'use strict'
var crc
try {
crc = require('fast-crc32c')
} catch (e) {
crc = require('./crc32c.js')
}
var crypto = require('crypto')
var through = require('through2')
module.exports = function (cfg) {
cfg = cfg || {}
var crc32c = cfg.crc32c !== false
var md5 = cfg.md5 !== false
var hashes = {}
if (md5) hashes.md5 = crypto.createHash('md5')
var onData = function (chunk, enc, done) {
if (crc32c) hashes.crc32c = crc.calculate(chunk, hashes.crc32c)
if (md5) hashes.md5.update(chunk)
done(null, chunk)
}
var onFlush = function (done) {
if (crc32c) hashes.crc32c = new Buffer([hashes.crc32c]).toString('base64')
if (md5) hashes.md5 = hashes.md5.digest('base64')
done()
}
var validationStream = through(onData, onFlush)
validationStream.test = function (algo, sum) {
return hashes[algo] === sum
}
return validationStream
}