From 161395bce8a735fe7bcfc6517cf636780192b885 Mon Sep 17 00:00:00 2001 From: CodeAnimal Date: Sat, 27 Sep 2014 18:19:07 +0100 Subject: [PATCH] Add precise definitions and tests. --- precise/precise-tests.ts | 9 +++++++++ precise/precise.d.ts | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 precise/precise-tests.ts create mode 100644 precise/precise.d.ts diff --git a/precise/precise-tests.ts b/precise/precise-tests.ts new file mode 100644 index 000000000..029a69a3e --- /dev/null +++ b/precise/precise-tests.ts @@ -0,0 +1,9 @@ +/// + +import precise = require("precise"); + +var timer = precise().start(); + +setTimeout(function () { + console.log(timer.stop().diff()); +}, 1000); \ No newline at end of file diff --git a/precise/precise.d.ts b/precise/precise.d.ts new file mode 100644 index 000000000..3caba0297 --- /dev/null +++ b/precise/precise.d.ts @@ -0,0 +1,34 @@ +// Type definitions for precise +// Project: https://github.com/avoidwork/precise +// Definitions by: Peter Harris +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "precise" { + /** + * Precise factory + */ + function _precise(): _precise.Precise; + + module _precise { + class Precise { + constructor(); + + /** + * Starts a timer + */ + start(): Precise; + + /** + * Stops a timer + */ + stop(): Precise; + + /** + * Returns the nanoseconds from `start()` to `stop()` + */ + diff(): number; + } + } + + export = _precise; +} \ No newline at end of file