Comparing version 2.0.0 to 2.1.0
@@ -0,7 +1,9 @@ | ||
import { Readable } from 'stream'; | ||
interface Hash { | ||
(data: string|Buffer, encoding?: string|undefined): string|Buffer; | ||
(data: string | Buffer, encoding?: string | undefined): string | Buffer; | ||
} | ||
interface Hmac { | ||
(data: string|Buffer, key: string|Buffer, encoding?: string|undefined): string|Buffer; | ||
(data: string | Buffer, key: string | Buffer, encoding?: string | undefined): string | Buffer; | ||
} | ||
@@ -27,3 +29,3 @@ | ||
export function md5(data: string|Buffer, encoding?: string|undefined): string; | ||
export function md5(data: string | Buffer, encoding?: string | undefined): string; | ||
@@ -36,4 +38,6 @@ export function pad2(num: number): string; | ||
export function sha1(data: string|Buffer, key: string, encoding?: string|undefined): string|Buffer; | ||
export function sha1(data: string | Buffer, key: string, encoding?: string | undefined): string | Buffer; | ||
export function sleep(ms: number): Promise<void>; | ||
export function readAll(readable: Readable): Promise<Buffer>; |
@@ -99,3 +99,3 @@ 'use strict'; | ||
*/ | ||
exports.makeNonce = (function() { | ||
exports.makeNonce = (function () { | ||
var counter = 0; | ||
@@ -215,1 +215,40 @@ var last; | ||
}; | ||
/** | ||
* Read all bytes from a readable | ||
* @return {Readable} the readable stream | ||
* @return {Promise} a Promise with all bytes | ||
*/ | ||
exports.readAll = function (readable) { | ||
return new Promise((resolve, reject) => { | ||
var onError, onData, onEnd; | ||
var cleanup = function (err) { | ||
// cleanup | ||
readable.removeListener('error', onError); | ||
readable.removeListener('data', onData); | ||
readable.removeListener('end', onEnd); | ||
}; | ||
var bufs = []; | ||
var size = 0; | ||
onData = function (buf) { | ||
bufs.push(buf); | ||
size += buf.length; | ||
}; | ||
onError = function (err) { | ||
cleanup(); | ||
reject(err); | ||
}; | ||
onEnd = function () { | ||
cleanup(); | ||
resolve(Buffer.concat(bufs, size)); | ||
}; | ||
readable.on('error', onError); | ||
readable.on('data', onData); | ||
readable.on('end', onEnd); | ||
}); | ||
}; |
{ | ||
"name": "kitx", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "toolkit", | ||
@@ -11,3 +11,3 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"lint": "eslint --fix lib", | ||
"lint": "eslint --fix lib test", | ||
"test": "mocha --reporter spec --timeout 3000 test/*.test.js", | ||
@@ -36,2 +36,3 @@ "test-cov": "nyc -r=lcov -r=html -r=text -r=json mocha -t 3000 -R spec test/*.test.js", | ||
"coveralls": "~2.11.9", | ||
"eslint": "^6.8.0", | ||
"expect.js": "^0.3.1", | ||
@@ -38,0 +39,0 @@ "mocha": "^6.2.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10409
247
5