Merge pull request #7628 from chrootsu/brorand

brorand: module definition and tests added
This commit is contained in:
Masahiro Wakame
2016-01-23 22:33:37 +09:00
2 changed files with 43 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
/// <reference path="./brorand.d.ts" />
import * as brorand from 'brorand';
{
let result: Buffer|Uint8Array = brorand(42);
}
{
let Rand = new brorand.Rand({getByte: () => 255});
let rand: {getByte: () => number} = Rand.rand;
let result: Buffer|Uint8Array = Rand.generate(42);
}
+30
View File
@@ -0,0 +1,30 @@
// Type definitions for Brorand v1.0.5
// Project: https://github.com/indutny/brorand
// Definitions by: Ilya Mochalov <https://github.com/chrootsu>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module "brorand" {
type rand = {getByte: () => number};
interface RandStatic {
new (rand: rand): RandInstance;
}
interface RandInstance {
rand: rand;
generate(len: number): Buffer|Uint8Array;
}
interface BrorandStatic {
(len: number): Buffer|Uint8Array;
Rand: RandStatic;
}
namespace Brorand {}
let Brorand: BrorandStatic;
export = Brorand;
}