From eba795b6a87684215d22e19249de14cceb395851 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 14 Jan 2016 03:13:22 +0500 Subject: [PATCH 1/2] brorand: module definiton added --- brorand/brorand.d.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 brorand/brorand.d.ts diff --git a/brorand/brorand.d.ts b/brorand/brorand.d.ts new file mode 100644 index 000000000..aa0e6ff5d --- /dev/null +++ b/brorand/brorand.d.ts @@ -0,0 +1,30 @@ +// Type definitions for Brorand v1.0.5 +// Project: https://github.com/indutny/brorand +// Definitions by: Ilya Mochalov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +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; +} From 331b62ebb426bfd8f4fd30116a7b52a910297f0c Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Fri, 15 Jan 2016 01:24:53 +0500 Subject: [PATCH 2/2] brorand: tests added --- brorand/brorand-tests.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 brorand/brorand-tests.ts diff --git a/brorand/brorand-tests.ts b/brorand/brorand-tests.ts new file mode 100644 index 000000000..1adb7b114 --- /dev/null +++ b/brorand/brorand-tests.ts @@ -0,0 +1,13 @@ +/// + +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); +}